summaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-12 19:31:35 +0000
committerChris Lattner <sabre@nondot.org>2010-02-12 19:31:35 +0000
commita5c6c5814b4c9f562247d2182eb59ccad128dbde (patch)
tree8f09ee0f92a8e62f0443e84f4cb44557765fceaf /lib/Basic/SourceManager.cpp
parent432a8893f7e30d141d7f279bd00b741a3cdac81f (diff)
downloadclang-a5c6c5814b4c9f562247d2182eb59ccad128dbde.tar.gz
fix a bug in SourceManager::getInstantiationLocSlowCase, where
we'd add an offset from the spelling location space to the instantiation location, which doesn't make sense and would lead up to the text diagnostics crashing when presented with non-sensical locations. This fixes rdar://7597492, a crash on 255.vortex. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r--lib/Basic/SourceManager.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 354bf7befb..b91671ad17 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -560,10 +560,14 @@ FileID SourceManager::getFileIDSlow(unsigned SLocOffset) const {
SourceLocation SourceManager::
getInstantiationLocSlowCase(SourceLocation Loc) const {
do {
- std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
- Loc = getSLocEntry(LocInfo.first).getInstantiation()
+ // Note: If Loc indicates an offset into a token that came from a macro
+ // expansion (e.g. the 5th character of the token) we do not want to add
+ // this offset when going to the instantiation location. The instatiation
+ // location is the macro invocation, which the offset has nothing to do
+ // with. This is unlike when we get the spelling loc, because the offset
+ // directly correspond to the token whose spelling we're inspecting.
+ Loc = getSLocEntry(getFileID(Loc)).getInstantiation()
.getInstantiationLocStart();
- Loc = Loc.getFileLocWithOffset(LocInfo.second);
} while (!Loc.isFileID());
return Loc;