]> granicus.if.org Git - clang/commitdiff
fix a negated conditional in getDecomposedInstantiationLocSlowCase,
authorChris Lattner <sabre@nondot.org>
Mon, 26 Jan 2009 19:41:58 +0000 (19:41 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 26 Jan 2009 19:41:58 +0000 (19:41 +0000)
which I think is rdar://6527005, and make getDecomposedSpellingLocSlowCase
handle nested spelling locations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63030 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 42e6040b7464d84ca57556bc10dfd42f93dcedb8..031bf4dcbcc5914bf52300a2dfdd0988309a7449 100644 (file)
@@ -341,7 +341,7 @@ SourceManager::getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E,
     FID = getFileID(Loc);
     E = &getSLocEntry(FID);
     Offset += Loc.getOffset()-E->getOffset();
-  } while (Loc.isFileID());
+  } while (!Loc.isFileID());
   
   return std::make_pair(FID, Offset);
 }
@@ -349,12 +349,18 @@ SourceManager::getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E,
 std::pair<FileID, unsigned>
 SourceManager::getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
                                                 unsigned Offset) const {
-  // If this is an instantiation record, get and return the spelling.
-  SourceLocation Loc = E->getInstantiation().getSpellingLoc();
-  FileID FID = getFileID(Loc);
-  E = &getSLocEntry(FID);
-  Offset += Loc.getOffset()-E->getOffset();
-  assert(Loc.isFileID() && "Should only have one spelling link");
+  // If this is an instantiation record, walk through all the instantiation
+  // points.
+  FileID FID;
+  SourceLocation Loc;
+  do {
+    Loc = E->getInstantiation().getSpellingLoc();
+    
+    FID = getFileID(Loc);
+    E = &getSLocEntry(FID);
+    Offset += Loc.getOffset()-E->getOffset();
+  } while (!Loc.isFileID());
+  
   return std::make_pair(FID, Offset);
 }