From: Chris Lattner Date: Mon, 26 Jan 2009 19:41:58 +0000 (+0000) Subject: fix a negated conditional in getDecomposedInstantiationLocSlowCase, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bcd1a1b5af0b2d57b20fc393a8c3b0badc58c450;p=clang 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 42e6040b74..031bf4dcbc 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -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 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); }