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);
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;