[clang] [clang][coverage] fixing "if constexpr" and "if consteval" coverage report (PR #77214)

Jessica Paquette via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 20:02:12 PST 2024


================
@@ -23,19 +23,29 @@ void foo() {                    // CHECK-NEXT: Gap,File 0, [[@LINE+1]]:21 -> [[@
 }                               // CHECK-NEXT: [[@LINE-2]]:9 -> [[@LINE-1]]:5 = #1
                                 // CHECK-NEXT: [[@LINE-2]]:5 -> [[@LINE-2]]:8 = #1
 
-// FIXME: Do not generate coverage for discarded branches in if consteval and if constexpr statements
-constexpr int check_consteval(int i) {
-    if consteval {
-      i++;
-    }
-    if !consteval {
-      i++;
-    }
-    if consteval {
-        return 42;
-    } else {
-        return i;
-    }
+// FIXME: Do not generate coverage for discarded branches in if constexpr
+// CHECK-LABEL: _Z16check_constexprAi:
+int check_constexprA(int i) {   // CHECK-NEXT: [[@LINE]]:29 -> {{[0-9]+}}:2 = #0
----------------
ornata wrote:

I think this test should be named `check_if_constexpr_true` or something similar

https://github.com/llvm/llvm-project/pull/77214


More information about the cfe-commits mailing list