fix a negated conditional in getDecomposedInstantiationLocSlowCase,
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
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 42e6040..031bf4d 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -341,7 +341,7 @@
     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 @@
 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);
 }