diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-26 20:04:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-26 20:04:19 +0000 |
commit | addb797ca2b5afc1a1e82fd8d5d6eb2a592e75a9 (patch) | |
tree | 21e8163c516d0e79395f85f494744ed47c940f71 /include/clang/Basic/SourceManager.h | |
parent | 9e5e4aaf8b8835b552819d68d29b6d94115d8a0b (diff) |
make getInstantiationLoc and getSpellingLoc handle multiply instantiated
locations, and move the slow case out of line. No perf change on cocoa.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63033 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r-- | include/clang/Basic/SourceManager.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 41c2defacd..84aabe1f31 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -415,24 +415,20 @@ public: /// 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 @@ private: 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; |