llvm-project
4a1bea02 - [clang] Reject ranges getExpansionRangeInFile cannot represent (#214461)

Commit
39 days ago
[clang] Reject ranges getExpansionRangeInFile cannot represent (#214461) getExpansionRangeInFile was extracted verbatim and inherited two shortcomings of the original loop, fixed here before the analyzer's SARIF and HTML consumers depend on it: - It mapped the end with getExpansionRange(SourceLocation), which always reports a token range, so a char-range input was widened by a whole token. Now using the getExpansionRange(CharSourceRange) overload, which keeps the flag. - It passed reversed ranges through. Consumers walk begin->end; now returning nullopt for those, as Lexer::makeFileCharRange already does. Separate from the extraction so that stays NFC, and out of the consumer fixes because it changes the shared helper's contract rather than one output. Both contract changes, plus the invalid- and cross-file-range guards, are covered by a GetExpansionRangeInFile unit test in clang/unittests/Frontend/TextDiagnosticTest.cpp. Assisted-By: claude
Author
Parents
Loading