[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
================
@@ -98,3 +104,49 @@ int main() { // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 =
void ternary() {
true ? FOO : FOO; // CHECK-NOT: Gap,{{.*}}, [[@LINE]]:8 ->
}
+
+// FIXME: Do not generate coverage for discarded branches in if consteval
+// GH-57377
+// CHECK-LABEL: _Z16check_constevalAi:
+constexpr int check_constevalA(int i) { // CHECK-NEXT: [[@LINE]]:39 -> {{[0-9]+}}:2 = #0
+ if consteval {
+ i *= 3; // CHECK-NEXT: [[@LINE-1]]:16 -> [[@LINE+1]]:4 = #1
+ } else { // CHECK-NEXT: Gap,File 0, [[@LINE]]:4 -> [[@LINE]]:10 = #0
+ i *= 5; // CHECK-NEXT: [[@LINE-1]]:10 -> [[@LINE+1]]:4 = #0
+ }
+ return i; // CHECK-NEXT: [[@LINE]]:3 -> [[@LINE]]:11 = (#0 + #1)
+}
+
+// CHECK-LABEL: _Z16check_constevalBi:
+constexpr int check_constevalB(int i) { // CHECK-NEXT: [[@LINE]]:39 -> {{[0-9]+}}:2 = #0
----------------
ornata wrote:
Maybe `check_if_not_consteval_with_discarded_branch` would be a more descriptive name?
https://github.com/llvm/llvm-project/pull/77214
More information about the cfe-commits
mailing list