[PATCH] D99695: [llvm-cov] Use -path-equivalence to support relative path.

Zequan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 1 11:51:50 PDT 2021


zequanwu added a comment.

In D99695#2664545 <https://reviews.llvm.org/D99695#2664545>, @vsk wrote:

>> For example, if we have /tmp/src/a.cpp embedded in the binary, llvm-cov show -path-equivalence=/tmp/src/,/cov ... will generate output direcotry like this: coverage/cov/a.cpp.
>
> What happens if the binary has a relative path '../../a.cpp' embedded and the user passes `-path-equivalence=/tmp/src/,/cov` to llvm-cov? Is a.cpp written to `<coverage-dir>/cov/../../a.cpp`?

In this case, `../../` is not matching `/tmp/src`. So, it's like -path-equivalence is not given. llvm-cov will lookup a.cpp in ../../ relative to current working directory.

>> But if -path-equivalence is not given and ../../a.cpp is embedded in the binary, llvm-cov may still generate report files outside report directory when source files are found. Maybe we should give a warning/error to let user use -path-equivalence when relative path is present?
>
> Until recently, relative paths weren't allowed in the coverage mapping. I don't believe it was ever the intention to allow llvm-cov to write files outside of the coverage dir. That sounds dangerous to me, fwiw I think that should be a hard error and the tool should refuse to do it.

I agree.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99695/new/

https://reviews.llvm.org/D99695



More information about the llvm-commits mailing list