<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62689>62689</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-path-equivalence doesn’t map path in coverage data to different path on same machine
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
FlashSheridan
</td>
</tr>
</table>
<pre>
Our use case for the `-path-equivalence` option to `llvm-cov` seems to be covered by the descriptive part of its [command documentation](https://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-report), “Map the paths in the coverage data to local source file paths,” though it differs from the subsequent motivational sentence (“This allows you to generate the coverage data on one machine, and then use llvm-cov on a different machine where you have the same files on a different path.”) Our details are quite complicated (involving Rust and Cargo dependencies with duplicated files), but the problem reproduces with the natural extension of the basic example in the [Source-based Code Coverage](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#creating-coverage-reports): The `-path-equivalence` option makes no difference to the output.
While there are tests which use the option, e.g. [llvm/test/tools/llvm-cov/showExpansions.cpp](https://github.com/llvm/llvm-project/blob/5cbe3381a65c14793f660f456f6daff674ac23bd/llvm/test/tools/llvm-cov/showExpansions.cpp#L1) and [llvm/test/tools/llvm-cov/showProjectSummary.cpp](https://github.com/llvm/llvm-project/blob/5cbe3381a65c14793f660f456f6daff674ac23bd/llvm/test/tools/llvm-cov/showProjectSummary.cpp#L15), their checks don’t seem to depend on the option making a difference.
## Steps to Reproduce
Here are the simplified steps, using the `foo.cc` from the documentation:
In directory Path_Equivalence, then repeated in the directory Other_Path_Equivalence
- `/Users/flash/Documents/Code/external_code/ToT_LLVM/llvm-project/build/bin/clang++ -fprofile-instr-generate -fcoverage-mapping --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/ foo.cc -o foo`
In directory Path_Equivalence:
- `LLVM_PROFILE_FILE="foo.profraw" ./foo`
In directory Other_Path_Equivalence:
- `LLVM_PROFILE_FILE="foo2.profraw" ./foo`
Back in directory Path_Equivalence:
- `/Users/flash/Documents/Code/external_code/ToT_LLVM/llvm-project/build/bin/llvm-profdata merge -sparse foo.profraw ../Other_Path_Equivalence/foo2.profraw -o foo+2.profdata`
- `/Users/flash/Documents/Code/external_code/ToT_LLVM/llvm-project/build/bin/llvm-cov show -object ./foo -object ../Other_Path_Equivalence/foo -instr-profile=foo+2.profdata -path-equivalence=/Users/flash/Documents/Code/Test_code/Path_Equivalence,/Users/flash/Documents/Code/Test_code/Other_Path_Equivalence`
## Actual Output
The output shows both files; it does not map the path “…/Path_Equivalence” in the coverage data to the local source file path “…/Other_Path_Equivalence”:
```
/Users/flash/Documents/Code/Test_code/Other_Path_Equivalence/foo.cc:
1| 40|#define BAR(x) ((x) || (x))
…
/Users/flash/Documents/Code/Test_code/Path_Equivalence/foo.cc:
1| 40|#define BAR(x) ((x) || (x))
```
## Expected Output
We need the coverage data for both files mapped to source file path `Other_Path_Equivalence/foo.cc`. Obviously in this simplified example it makes no difference, but in our case the majority of our test coverage is in one dependency copy of the file(s) of interest, with some test coverage is in the original location.
## Configuration
MacOS 12.6.5 21G531 on M1 Max
Clang built from source 54fd5cf926c56d255c4757af838edbe37e6ae5d9, May 12 09:31:04 2023 -0700.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWN9v47gR_mvol4EFibJk-8EPsR1fD90gi03au7eAokYWbyVRR1JO_N8XQ_1wduN0s0V7KBDYlkgO55v5Zvgxwlp1bBA3LNmyZD8TnSu12RwqYcuHEo3KRTPLdH7e3HcGOosghUUotAFXIrA0nLfClXP8s1MnUWEjkaUh6NYp3YDTNKOqTvVc6hMNWMTa0vsMQeoTGswhO3tbOVppVOvUCaEVxoEuQDkLLNlKXdeiySHXsquxcYKss2TP-Kp0rrUsvmH8wPiBtgq0OTJ-yLW0jB92_dJfOpXjMIF8CUpXV4zH4_PcYKuNY3zN-A7YLWer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