diff options
author | Chris Lattner <sabre@nondot.org> | 2007-07-21 06:41:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-07-21 06:41:57 +0000 |
commit | d1623a81992a24abbfcd5520b32a0dd90857b8a8 (patch) | |
tree | 3dabec55fc6c426e45e47c3fd388fcf149c8f879 /Basic/SourceManager.cpp | |
parent | aa4166c6c86e174362c0dc4e2cb63345f72cc5a0 (diff) |
Add support for reusing macroid's with negative physical loc deltas. This
keeps the MacroInfo table more compact.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Basic/SourceManager.cpp')
-rw-r--r-- | Basic/SourceManager.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Basic/SourceManager.cpp b/Basic/SourceManager.cpp index d05da5d971..be8eeee408 100644 --- a/Basic/SourceManager.cpp +++ b/Basic/SourceManager.cpp @@ -180,20 +180,19 @@ SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc, // reuse it. This implements a single-entry cache. if (!MacroIDs.empty()) { MacroIDInfo &LastOne = MacroIDs.back(); + if (LastOne.getInstantiationLoc() == InstantLoc && LastOne.getPhysicalLoc().getFileID() == PhysLoc.getFileID()) { int PhysDelta = PhysLoc.getRawFilePos() - LastOne.getPhysicalLoc().getRawFilePos(); - if (unsigned(PhysDelta) < (1 << SourceLocation::MacroPhysOffsBits)) - return SourceLocation::getMacroLoc(MacroIDs.size()-1, - (unsigned)PhysDelta, 0); + if (SourceLocation::isValidMacroPhysOffs(PhysDelta)) + return SourceLocation::getMacroLoc(MacroIDs.size()-1, PhysDelta, 0); } } MacroIDs.push_back(MacroIDInfo::get(InstantLoc, PhysLoc)); - return SourceLocation::getMacroLoc(MacroIDs.size()-1, 0, 0); } |