<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116902>116902</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[coverage] functions with `std::string`, `std::vector` etc as parameter introduce bogus branches
</td>
</tr>
<tr>
<th>Labels</th>
<td>
tools:llvm-cov
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
whentojump
</td>
</tr>
</table>
<pre>
## Triggering conditions
- Decision contains at least two conditions
- One condition is a function call
- This function takes one of `std::vector`, `std::string` etc as parameter
## Effects
```text
28| 1| if (f1(s)
------------------
| Branch (28:9): [True: 1, False: 0]
| Branch (28:9): [True: 0, False: 1]
------------------
29| 1| &&
30| 1| false_condition)
------------------
| Branch (30:9): [True: 0, False: 1]
------------------
31| 0| return 1;
```
```text
33| 1| if (true_condition
------------------
| Branch (33:9): [True: 1, False: 0]
| Branch (33:9): [True: 0, False: 1]
------------------
34| 1| &&
35| 1| f0(v))
------------------
| Branch (35:9): [True: 0, False: 1]
------------------
36| 0| return 1;
```
## How to reproduce
(Compiler explorer [link](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGe1wAyeAyYAHI%2BAEaYxCAArGakAA6oCoRODB7evnrJqY4CQSHhLFEx8baY9vkMQgRMxASZPn5cFVXptfUEhWGR0XoKdQ1N2a2DXT3FpRIAlLaoXsTI7BzmAMzByN5YANQma26DxMHA%2B9gmGgCC65vbmHsHAG6YDiRnF9dXwQQ7VBoQg3QIBAz1exH2bm%2BZx2jxmewA7FYrjsUTtiJgCIsGDsNPskdd4QARD4fb6/LgAghAkBHE47BRwkyIj6otEYrE7Lh4klEklfQS/MwQRnM5Go9GY4jY3FrfFM4lXUkCqhrCBkvAi/Gs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AkmAUCxMEYS4WtQXaoaBEqj%2BYU/l%2BIJ/eOklhj7QWo%2BAf7aSpMEDOgJgg9xCLQfuNdgEyW/LQAAkkCWgtBHgsB%2BgjNyHkgy31XlnLavVEiJQ4lxdSWVDZoIwVgomJYnJGB%2BgIDKcJJ4Wytgw22YF7YLxLGfV2Zh46kB2B4Sy9BiB7EEVwRent5KkBvEwLAMRyYByDiNasaxcaxC4H7Lg1Zqwm3iBoWI8ITZ6w0obbSWdZHe19v7TgawKEGwzjYshHAzBOPThwD2i05hjVSM4SQQA)):
```shell
cat > test.cpp << EOF
#include <string>
#include <vector>
int f0(std::vector<int> v) {
return 0;
}
int f1(std::string s) {
return 1;
}
int f2() {
return 0;
}
int f3(int i) {
return 1;
}
int main() {
std::string s;
std::vector<int> v;
int true_condition = 1;
int false_condition = 0;
int i = 0;
if (f1(s)
&&
false_condition)
return 1;
if (true_condition
&&
f0(v))
return 1;
// For comparison these function signatures look fine
if (true_condition
&&
f2())
return 1;
if (f3(i)
&&
false_condition)
return 1;
return 0;
}
EOF
clang++ -fprofile-instr-generate -fcoverage-mapping test.cpp -o test
./test
llvm-profdata merge default.profraw -o default.profdata
llvm-cov show -show-branches=count -instr-profile default.profdata test
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysWFuTqjqw_jXMCzWrICDowzwk3ERBBxUVX05FCCFycwAF_fWn0LmtNTN777PPpiwml-7O190h019wXTNaEPLEDRA30B_wqUnK6qlNSNGUh1N-fNiX0eWJAxIHJH5VMUpJxQrKh2URsYaVRc0JOifA-_uR10nIalYWvUCDWVHzuOEzguuGb9ryi9ojPy_IxyjPah7z8akIb70QZ9mb3Cph9cdMg1NS82VB-DLmOUWom4iTICfBMwmbsuIUgQPabxN10-PmFIEnTcjjmj_iCuekIdVnB14dNeKYhM1vrvUmb7-GdM19iOd5MORUjb894muLxTwHhrHIgWHNgdGr6OOX583GTQ1VuAiTXhEMOQmOekUJ8twAraoT6Zti75CJs_rWE7iB_n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