This is an archive of the discontinued LLVM Phabricator instance.

[clang/Lexer] Enhance `Lexer::getImmediateMacroNameForDiagnostics` to return a result from non-file buffers
ClosedPublic

Authored by akyrtzi on Dec 15 2022, 1:37 PM.

Details

Summary

Use SourceManager::isWrittenInScratchSpace() to specifically check for token paste or stringization, instead of
excluding all non-file buffers. This allows diagnostics to mention macro names that were defined from the command-line.

Diff Detail

Event Timeline

akyrtzi created this revision.Dec 15 2022, 1:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2022, 1:37 PM
akyrtzi requested review of this revision.Dec 15 2022, 1:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2022, 1:37 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steven_wu accepted this revision.Dec 15 2022, 3:12 PM

LGTM

clang/lib/Lex/Lexer.cpp
1050–1054

nit: isn't FileID or from scratch space

This revision is now accepted and ready to land.Dec 15 2022, 3:12 PM
akyrtzi updated this revision to Diff 483370.Dec 15 2022, 3:31 PM

Adjust code comment.

akyrtzi marked an inline comment as done.Dec 15 2022, 3:31 PM