aboutsummaryrefslogtreecommitdiff
path: root/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-21 06:41:57 +0000
committerChris Lattner <sabre@nondot.org>2007-07-21 06:41:57 +0000
commitd1623a81992a24abbfcd5520b32a0dd90857b8a8 (patch)
tree3dabec55fc6c426e45e47c3fd388fcf149c8f879 /Basic/SourceManager.cpp
parentaa4166c6c86e174362c0dc4e2cb63345f72cc5a0 (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.cpp7
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);
}