[cfe-commits] r63033 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp
Chris Lattner
sabre at nondot.org
Mon Jan 26 12:04:19 PST 2009
Author: lattner
Date: Mon Jan 26 14:04:19 2009
New Revision: 63033
URL: http://llvm.org/viewvc/llvm-project?rev=63033&view=rev
Log:
make getInstantiationLoc and getSpellingLoc handle multiply instantiated
locations, and move the slow case out of line. No perf change on cocoa.h
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/Basic/SourceManager.cpp
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=63033&r1=63032&r2=63033&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jan 26 14:04:19 2009
@@ -415,24 +415,20 @@
/// Given a SourceLocation object, return the instantiation location
/// referenced by the ID.
SourceLocation getInstantiationLoc(SourceLocation Loc) const {
- // File locations work!
+ // Handle the non-mapped case inline, defer to out of line code to handle
+ // instantiations.
if (Loc.isFileID()) return Loc;
-
- std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
- Loc = getSLocEntry(LocInfo.first).getInstantiation().getInstantiationLoc();
- return Loc.getFileLocWithOffset(LocInfo.second);
+ return getInstantiationLocSlowCase(Loc);
}
/// getSpellingLoc - Given a SourceLocation object, return the spelling
/// location referenced by the ID. This is the place where the characters
/// that make up the lexed token can be found.
SourceLocation getSpellingLoc(SourceLocation Loc) const {
- // File locations work!
+ // Handle the non-mapped case inline, defer to out of line code to handle
+ // instantiations.
if (Loc.isFileID()) return Loc;
-
- std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
- Loc = getSLocEntry(LocInfo.first).getInstantiation().getSpellingLoc();
- return Loc.getFileLocWithOffset(LocInfo.second);
+ return getSpellingLocSlowCase(Loc);
}
/// getDecomposedLoc - Decompose the specified location into a raw FileID +
@@ -614,6 +610,9 @@
FileID getFileIDSlow(unsigned SLocOffset) const;
+ SourceLocation getInstantiationLocSlowCase(SourceLocation Loc) const;
+ SourceLocation getSpellingLocSlowCase(SourceLocation Loc) const;
+
std::pair<FileID, unsigned>
getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E,
unsigned Offset) const;
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=63033&r1=63032&r2=63033&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Mon Jan 26 14:04:19 2009
@@ -328,6 +328,27 @@
}
}
+SourceLocation SourceManager::
+getInstantiationLocSlowCase(SourceLocation Loc) const {
+ do {
+ std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
+ Loc =getSLocEntry(LocInfo.first).getInstantiation().getInstantiationLoc();
+ Loc = Loc.getFileLocWithOffset(LocInfo.second);
+ } while (!Loc.isFileID());
+
+ return Loc;
+}
+
+SourceLocation SourceManager::getSpellingLocSlowCase(SourceLocation Loc) const {
+ do {
+ std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
+ Loc = getSLocEntry(LocInfo.first).getInstantiation().getSpellingLoc();
+ Loc = Loc.getFileLocWithOffset(LocInfo.second);
+ } while (!Loc.isFileID());
+ return Loc;
+}
+
+
std::pair<FileID, unsigned>
SourceManager::getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E,
unsigned Offset) const {
More information about the cfe-commits
mailing list