llvm-project
10f94172 - [Coverage] Fix assertion failure when a -isystem header invokes a user macro (#195427)

Commit
19 days ago
[Coverage] Fix assertion failure when a -isystem header invokes a user macro (#195427) ``` // a.cc static void foo(int x) { switch (x) { #define GENERIC(n) case n: #include "types.def" // -isystem header invokes a user macro break; } } // sys/types.def #define MID(name) GENERIC(name) MID(0) MID(1) MID(2) ``` ``` $ clang -fprofile-instr-generate -fcoverage-mapping -isystem sys -c a.cc Assertion `SystemHeadersCoverage || !SM.isInSystemHeader(SM.getSpellingLoc(Loc))' failed. ``` Commit 702a2b627ff4 ("[Coverage] Rework !SystemHeadersCoverage") replaced the system-header skip in gatherFileIDs with this assertion, which trips as `SM.isInSystemHeader(SM.getSpellingLoc(Loc))` is false. This patch adds back the pre-#91446 condition but folds it with the macro-token remap `if` statement. Fixes #179316/#195422. Clang Opus 4.7 identified clang/lib/Parse/ParseExpr.cpp, created a minimal reproduce with cvise, and wrote the initial version of this CodeGen patch. (An earlier session papered over the bug by patching llvm-cov instead, which I abandoned).
Author
Parents
Loading