[llvm-bugs] [Bug 51663] New: llvm-cov does not handle path separator correctly on Windows

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 29 00:19:11 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51663

            Bug ID: 51663
           Summary: llvm-cov does not handle path separator correctly on
                    Windows
           Product: Runtime Libraries
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: libprofile library
          Assignee: unassignedbugs at nondot.org
          Reporter: efanzh at gmail.com
                CC: llvm-bugs at lists.llvm.org

Specifically, the `SOURCE` argument for `llvm-cov show` does not work well on
Windows.

If I specify a directory in `SOURCES`, llvm-cov will find all files in that
directory, and use them to filter coverage data. The problem is that llvm-cov
compares the paths as if they were strings. On Windows, both “/” and “\” can be
used as path separator, and `C:\xyz` and `C:/xyz` should be treated as the same
path on Windows. Failing to do this may lead to incorrect report.

To reproduce, run this PowerShell script in an empty directory on Windows:

--------------------------------------------------------------------------------
echo "int main() {}" > main.cpp

$cwd = $(pwd).ToString()
$cwd = $cwd.Replace("\", "/") # Comment this line to see the exprectd result.

clang++ -fprofile-instr-generate -fcoverage-mapping "$cwd/main.cpp" -o main.exe

$env:LLVM_PROFILE_FILE="main.profraw"
.\main.exe

llvm-profdata merge -o main.profdata main.profraw
llvm-cov show --format html --instr-profile main.profdata main.exe . >
main.html
--------------------------------------------------------------------------------

I got an empty HTML report on my PC from running this script. You can also try
to comment `$cwd = $cwd.Replace("\", "/")` to get a correct report.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210829/37c95e75/attachment.html>


More information about the llvm-bugs mailing list