summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-17 08:04:48 +0000
committerChris Lattner <sabre@nondot.org>2009-02-17 08:04:48 +0000
commit8ad52d5068927e9bd858c82bcbd3edaae135f29e (patch)
treef2dcc8596963db0f0565e700763684baa2366370 /clang/lib/Basic/SourceManager.cpp
parentc9feeb54a515e1ca6499c32b1c89e4cfc1248e29 (diff)
downloadbcm5719-llvm-8ad52d5068927e9bd858c82bcbd3edaae135f29e.tar.gz
bcm5719-llvm-8ad52d5068927e9bd858c82bcbd3edaae135f29e.zip
add an accessor.
llvm-svn: 64758
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 88980efcdaa..3f652274b80 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -597,6 +597,18 @@ SourceManager::getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
return std::make_pair(FID, Offset);
}
+/// getImmediateSpellingLoc - Given a SourceLocation object, return the
+/// spelling location referenced by the ID. This is the first level down
+/// towards the place where the characters that make up the lexed token can be
+/// found. This should not generally be used by clients.
+SourceLocation SourceManager::getImmediateSpellingLoc(SourceLocation Loc) const{
+ if (Loc.isFileID()) return Loc;
+ std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
+ Loc = getSLocEntry(LocInfo.first).getInstantiation().getSpellingLoc();
+ return Loc.getFileLocWithOffset(LocInfo.second);
+}
+
+
/// getImmediateInstantiationRange - Loc is required to be an instantiation
/// location. Return the start/end of the instantiation information.
std::pair<SourceLocation,SourceLocation>
OpenPOWER on IntegriCloud