From bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hana=20Dus=C3=ADkov=C3=A1?= Date: Thu, 1 Feb 2024 23:31:32 +0100 Subject: [coverage] fix crash in code coverage and `if constexpr` with `ExprWithCleanups` (#80292) Fixes https://github.com/llvm/llvm-project/issues/80285 --- clang/lib/CodeGen/CoverageMappingGen.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp') 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(S->getCond()); - const bool isTrue = E->getResultAsAPSInt().getExtValue(); + const bool isTrue = + S->getCond() + ->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext()) + .getBoolValue(); extendRegion(S); -- cgit v1.1