diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-17 08:39:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-17 08:39:06 +0000 |
commit | bff5c512af8ca7ac92e974e04c06ff4f820e4ee1 (patch) | |
tree | dbd4754151bf3b4a876ad07573116b46d5444677 /lib/Basic/SourceManager.cpp | |
parent | ba27e2a5c2ba49c0f3d84118508f761bf8fb762d (diff) | |
download | clang-bff5c512af8ca7ac92e974e04c06ff4f820e4ee1.tar.gz |
add an accessor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r-- | lib/Basic/SourceManager.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 3f652274b8..2b581bb1ed 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -857,6 +857,15 @@ SourceManager::getFileCharacteristic(SourceLocation Loc) const { return Entry->FileKind; } +/// Return the filename or buffer identifier of the buffer the location is in. +/// Note that this name does not respect #line directives. Use getPresumedLoc +/// for normal clients. +const char *SourceManager::getBufferName(SourceLocation Loc) const { + if (Loc.isInvalid()) return "<invalid loc>"; + + return getBuffer(getFileID(Loc))->getBufferIdentifier(); +} + /// getPresumedLoc - This method returns the "presumed" location of a /// SourceLocation specifies. A "presumed location" can be modified by #line |