Skip to content

Commit cab738b

Browse files
authored
[MC/DC] Update CoverageMapping tests (#125404)
To resolve the error, rename mcdc-error-nests.cpp -> mcdc-nested-expr.cpp at first. - `func_condop` A corner case that contains close decisions. - `func_expect` Uses `__builtin_expect`. (#124565) - `func_lnot` Contains logical not(s) `!` among MC/DC binary operators. (#124563)
1 parent 83d2c68 commit cab738b

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

clang/test/CoverageMapping/mcdc-error-nests.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fcoverage-mcdc -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s 2> %t.stderr.txt | FileCheck %s
2+
// RUN: FileCheck %s --check-prefix=WARN < %t.stderr.txt
3+
4+
// "Split-nest" -- boolean expressions within boolean expressions.
5+
extern bool bar(bool);
6+
// CHECK: func_split_nest{{.*}}:
7+
bool func_split_nest(bool a, bool b, bool c, bool d, bool e, bool f, bool g) {
8+
// WARN: :[[@LINE+1]]:14: warning: unsupported MC/DC boolean expression; contains an operation with a nested boolean expression.
9+
bool res = a && b && c && bar(d && e) && f && g;
10+
return bar(res);
11+
}
12+
13+
// The inner expr begins with the same Loc as the outer expr
14+
// CHECK: func_condop{{.*}}:
15+
bool func_condop(bool a, bool b, bool c) {
16+
// WARN: :[[@LINE+1]]:10: warning: unsupported MC/DC boolean expression; contains an operation with a nested boolean expression.
17+
return (a && b ? true : false) && c;
18+
}
19+
20+
// __builtin_expect
21+
// Treated as parentheses.
22+
// CHECK: func_expect{{.*}}:
23+
bool func_expect(bool a, bool b, bool c) {
24+
// WARN: :[[@LINE+1]]:10: warning: unsupported MC/DC boolean expression; contains an operation with a nested boolean expression.
25+
return a || __builtin_expect(b && c, true);
26+
}
27+
28+
// LNot among BinOp(s)
29+
// Doesn't split exprs.
30+
// CHECK: func_lnot{{.*}}:
31+
bool func_lnot(bool a, bool b, bool c, bool d) {
32+
// WARN: :[[@LINE+1]]:10: warning: unsupported MC/DC boolean expression; contains an operation with a nested boolean expression.
33+
return !(a || b) && !(c && d);
34+
}

0 commit comments

Comments
 (0)