Bug filed here: https://bugs.llvm.org/show_bug.cgi?id=45849
This is caused by gap area not emitted if either AfterLoc or BeforeLoc is a macro location.
Details
- Reviewers
vsk bogner - Commits
- rGa31c89c1b7a0: [Coverage] Enable emitting gap area between macros
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks, looks good to me! Please check for any issues in a stage2 coverage build before landing this.
Here is a repro of crash caused by this change.
int k, l;
#define m(e) e##e
void p() {
int kk,ll;
if (k)
m(k);
else
l = m(l);
}SM.getExpansLoc(AfterLoc) for m(k) gives location pointing to m(l), which caused the crash.
We started seeing assertion failure after rolling a toolchain that contains this change and git bisect identified this change. I have filed a bug with a reproducer as PR47324.
Could you check in the reproducer program (void p) as a regression test?
| clang/lib/CodeGen/CoverageMappingGen.cpp | ||
|---|---|---|
| 995 | It could aid debugging to assert that the result of getIncludeOrExpansionLoc(AfterLoc) is valid. | |
| clang/test/CoverageMapping/if.cpp | ||
| 10 | Just to double-check: this is now starting the gap after the '?', instead of including the '?' - if so, that looks right. | |
- Added regression test.
- Assert getIncludeOrExpansionLoc(AfterLoc) is valid.
| clang/test/CoverageMapping/if.cpp | ||
|---|---|---|
| 10 | Yes. | |
Landed at https://github.com/llvm/llvm-project/commit/d83511dd26ca8d0dd5be6302ad7b55de05cedab2 (forgot to add the differential revision line).
This commit introduced an unused variable warning when built without asserts. (CoverageMappingGen.cpp:984) I have fixed it with rG4544a63b7705.
It could aid debugging to assert that the result of getIncludeOrExpansionLoc(AfterLoc) is valid.