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: unassignedb...@nondot.org
          Reporter: efa...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to