Simplify logic to use SourceManager::getFileLoc(), per Argyrios's feedback.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170487 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2012-12-19 01:16:49 +00:00
Родитель e3ec31a6c2
Коммит 6ee225c8d4
2 изменённых файлов: 3 добавлений и 12 удалений

Просмотреть файл

@ -153,10 +153,8 @@ void DiagnosticRenderer::emitDiagnostic(SourceLocation Loc,
SourceLocation UnexpandedLoc = Loc;
// Perform the same walk as emitMacroExpansions, to find the ultimate
// expansion location for the diagnostic.
while (Loc.isMacroID())
Loc = SM->getImmediateMacroCallerLoc(Loc);
// Find the ultimate expansion location for the diagnostic.
Loc = SM->getFileLoc(Loc);
PresumedLoc PLoc = SM->getPresumedLoc(Loc, DiagOpts->ShowPresumedLoc);

Просмотреть файл

@ -294,14 +294,7 @@ void clang_getSpellingLocation(CXSourceLocation location,
const SourceManager &SM =
*static_cast<const SourceManager*>(location.ptr_data[0]);
SourceLocation SpellLoc = Loc;
// Unravel the macro instantiation stack. This logic mirrors that
// in DiagnosticRenderer.
while (SpellLoc.isMacroID()) {
SpellLoc = SM.getImmediateMacroCallerLoc(SpellLoc);
}
SourceLocation SpellLoc = SM.getFileLoc(Loc);
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(SpellLoc);
FileID FID = LocInfo.first;
unsigned FileOffset = LocInfo.second;