summaryrefslogtreecommitdiffstats
path: root/clang/Basic
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
commit2e380893e32a11af321d1a6f51715b883f677af5 (patch)
treed05a26fed6671a72c2ca412446f0621b1c178514 /clang/Basic
parent43c0ed633367a19ae1868e023789fe416d55c0b4 (diff)
downloadbcm5719-llvm-2e380893e32a11af321d1a6f51715b883f677af5.tar.gz
bcm5719-llvm-2e380893e32a11af321d1a6f51715b883f677af5.zip
Add support for reusing macroid's with negative physical loc deltas. This
keeps the MacroInfo table more compact. llvm-svn: 40281
Diffstat (limited to 'clang/Basic')
-rw-r--r--clang/Basic/SourceManager.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/Basic/SourceManager.cpp b/clang/Basic/SourceManager.cpp
index d05da5d971b..be8eeee4086 100644
--- a/clang/Basic/SourceManager.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud