-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird Clang's branch coverage with macros from system headers #78920
Comments
Coverage mappings should not be generated for system headers, as introduced in 93205af. Adding That does not explain the |
@ManuelvOK Thank you to explain the background. Seems your change doesn't affect the testcase above.
I think it'd be ideal, in this case, to handle At the moment, |
The crash can be reproducible w/o (https://godbolt.org/z/3qfva7rWa)
In this case, it dies in |
The assumption made in @chapuni Thank for the reproducible example. static const _Key&
_S_key(_Const_Link_type __x)
{
...
// | Assumed to be castable to `ConstantExpr` but is of type
// | `CXXUnresolvedConstructExpr`, which is not.
// v
if constexpr (__is_invocable<_Compare&, const _Key&, const _Key&>{})
static_assert(
is_invocable_v<const _Compare&, const _Key&, const _Key&>,
"comparison object must be invocable as const");
...
} As can be seen from the corresponding part of the AST (dumped with {
"id": "0x59f1f4f79b40",
"kind": "IfStmt",
"range": {
"begin": {
"line": 770,
"includedFrom": {
"file": "/usr/include/c++/13.2.0/set"
}
},
"end": {
"line": 773,
"col": 55,
"tokLen": 1,
"includedFrom": {
"file": "/usr/include/c++/13.2.0/set"
}
}
},
"isConstexpr": true,
"inner": [
{
"id": "0x59f1f4f79930",
"kind": "CXXUnresolvedConstructExpr",
"range": {
"begin": {
"offset": 20556,
"line": 770,
"col": 16,
"tokLen": 14,
"includedFrom": {
"file": "/usr/include/c++/13.2.0/set"
}
},
"end": {
"offset": 20608,
"col": 68,
"tokLen": 1,
"includedFrom": {
"file": "/usr/include/c++/13.2.0/set"
}
}
},
"type": {
"qualType": "__is_invocable<_Compare &, const _Key &, const _Key &>"
},
"valueCategory": "prvalue",
"list": true,
"inner": [
{
"id": "0x59f1f4f798f0",
"kind": "InitListExpr",
"range": {
"begin": {
"offset": 20607,
"col": 67,
"tokLen": 1,
"includedFrom": {
"file": "/usr/include/c++/13.2.0/set"
}
},
"end": {
"offset": 20608,
"col": 68,
"tokLen": 1,
"includedFrom": {
"file": "/usr/include/c++/13.2.0/set"
}
}
},
"type": {
"qualType": "void"
},
"valueCategory": "prvalue"
}
]
},
{
"id": "0x59f1f4f79b28",
"kind": "DeclStmt",
"...": "..."
}
]
} Unfortunately I don't have enough insight in Clang to provide a fix / correct implementation of |
|
It's no longer crashing, what changed? I see my patch is still there. I'm confused. |
A recent change #76950 fixed the The crash was uncovered as a result. I did my tests with 5585ddd, the commit immediately before the revert. |
`emitSourceRegions()` has bugs to emit malformed MC/DC coverage mappings. They were detected in `llvm-cov` as the crash. Detect inconsistencies earlier in `clang` with assertions. * mcdc-system-headers.cpp covers llvm#78920. * mcdc-scratch-space.c covers llvm#87000.
I've added assertions in #89572. This detects the issue in clang side. |
- Introduce `LeafExprSet`, - Suppress traversing LAnd and LOr expr under system headers. - Handle LAnd and LOr as instrumented leaves to override `!isInstrumentedCondition(C)`. - Replace Loc with FileLoc if it is expanded with system headers. Fixes llvm#78920
I've created #91446 . @ManuelvOK Could you take a look? |
- Introduce `LeafExprSet`, - Suppress traversing LAnd and LOr expr under system headers. - Handle LAnd and LOr as instrumented leaves to override `!isInstrumentedCondition(C)`. - Replace Loc with FileLoc if it is expanded with system headers. Fixes #78920
@chapuni There are no more 18.1.x releases planned. |
@chapuni Sure, you can tag it. |
- Introduce `LeafExprSet`, - Suppress traversing LAnd and LOr expr under system headers. - Handle LAnd and LOr as instrumented leaves to override `!isInstrumentedCondition(C)`. - Replace Loc with FileLoc if it is expanded with system headers. Fixes llvm#78920 llvmorg-19-init-11775-g702a2b627ff4
Patches for release/18.x are available. |
Clang eliminates whole MACRO expr in branch coverage.
(https://godbolt.org/z/3o9MTf4eW)
The emission of the record is as below;
ISN(c)
cannot be seen nor evaluated.Could I see the condition of
ISN(c)
?WIth
-fcoverage-mcdc
,llvm-cov
crashes. (cc: @evodius96)A workaround is adding
-mllvm -system-headers-coverage
toclang
.The text was updated successfully, but these errors were encountered: