I'm on Windows and trying to use the -line-filter-argument to clang-tidy. This only worked on paths without folders (myfile.cpp). To ensure unique file names in the filter, I wanted to use paths with folders (instead of myfile.cpp use src/subfolder/myfile.cpp. I saw in the source that endswith is used on the file name (which I assume is a relative or absolute file path).
I got it to work by using windows path separators (that had to be escaped), i.e. src\\subfolder\\myfile.cpp instead of src/subfolder/myfile.cpp. (even when using MINGW64/Git bash that is included in Git for Windows, this solution is neccessary)
This is a problem because I want to use clang-tidy-diff.py. It does work by modifying clang-tidy-diff.py
from
lines_by_file.setdefault(filename, []).append([start_line, end_line])
to
lines_by_file.setdefault(filename.replace("/", "\\"), []).append([start_line, end_line])
but it doesn't feel right that clang-tidy can't handle this internally.
The example usage of clang-tidy-diff.py is with git diff, which outputs unix path separators /.
Hi,
I'm on Windows and trying to use the `-line-filter`-argument to clang-tidy. This only worked on paths without folders (`myfile.cpp`). To ensure unique file names in the filter, I wanted to use paths with folders (instead of `myfile.cpp` use `src/subfolder/myfile.cpp`. I saw in the source that `endswith` is used on the file name (which I assume is a relative or absolute file path).
https://github.com/llvm/llvm-project/blob/58d97034c9c149d175c66440d31f46e9dfd4b760/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp#L468
I got it to work by using windows path separators (that had to be escaped), i.e. `src\\subfolder\\myfile.cpp` instead of `src/subfolder/myfile.cpp`. (even when using MINGW64/Git bash that is included in Git for Windows, this solution is neccessary)
`-line-filter='[{"name":"subfolder\\myfile.cpp","lines":[[10,35]]}]'`
This is a problem because I want to use `clang-tidy-diff.py`. It does work by modifying `clang-tidy-diff.py`
from
`lines_by_file.setdefault(filename, []).append([start_line, end_line])`
to
`lines_by_file.setdefault(filename.replace("/", "\\"), []).append([start_line, end_line])`
but it doesn't feel right that clang-tidy can't handle this internally.
The example usage of `clang-tidy-diff.py` is with git diff, which outputs unix path separators `/`.
Hi,
I'm on Windows and trying to use the
-line-filter
-argument to clang-tidy. This only worked on paths without folders (myfile.cpp
). To ensure unique file names in the filter, I wanted to use paths with folders (instead ofmyfile.cpp
usesrc/subfolder/myfile.cpp
. I saw in the source thatendswith
is used on the file name (which I assume is a relative or absolute file path).https://github.com/llvm/llvm-project/blob/58d97034c9c149d175c66440d31f46e9dfd4b760/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp#L468
I got it to work by using windows path separators (that had to be escaped), i.e.
src\\subfolder\\myfile.cpp
instead ofsrc/subfolder/myfile.cpp
. (even when using MINGW64/Git bash that is included in Git for Windows, this solution is neccessary)-line-filter='[{"name":"subfolder\\myfile.cpp","lines":[[10,35]]}]'
This is a problem because I want to use
clang-tidy-diff.py
. It does work by modifyingclang-tidy-diff.py
from
lines_by_file.setdefault(filename, []).append([start_line, end_line])
tolines_by_file.setdefault(filename.replace("/", "\\"), []).append([start_line, end_line])
but it doesn't feel right that clang-tidy can't handle this internally.
The example usage of
clang-tidy-diff.py
is with git diff, which outputs unix path separators/
.