Index: lib/Basic/SourceManager.cpp =================================================================== --- lib/Basic/SourceManager.cpp +++ lib/Basic/SourceManager.cpp @@ -1474,7 +1474,15 @@ bool *Invalid) const { if (isInvalid(Loc, Invalid)) return ""; - return getBuffer(getFileID(Loc), Invalid)->getBufferIdentifier(); + // Try to get the name without reading the buffer. + FileID FID = getFileID(Loc); + const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, Invalid); + if (!Invalid && Entry.isFile()) { + if (const FileEntry* FE = Entry.getFile().getContentCache()->ContentsEntry) + return FE->getName(); + } + + return getBuffer(FID, Invalid)->getBufferIdentifier(); }