diff options
author | Hana Dusíková <hanicka@hanicka.net> | 2024-02-01 23:31:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 23:31:32 +0100 |
commit | bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd (patch) | |
tree | ce8e4219e5c6e1a4b56e20da0f51c587070254f2 /clang/lib/CodeGen/CoverageMappingGen.cpp | |
parent | ecdbffe59e80666c9cadf3f80bd20bb34828fb47 (diff) | |
download | llvm-bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd.zip llvm-bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd.tar.gz llvm-bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd.tar.bz2 |
[coverage] fix crash in code coverage and `if constexpr` with `ExprWithCleanups` (#80292)
Fixes https://github.com/llvm/llvm-project/issues/80285
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 8b5e6c4..f7f7354 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder assert(S->isConstexpr()); // evaluate constant condition... - const auto *E = cast<ConstantExpr>(S->getCond()); - const bool isTrue = E->getResultAsAPSInt().getExtValue(); + const bool isTrue = + S->getCond() + ->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext()) + .getBoolValue(); extendRegion(S); |