Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line filter on for clang compiler on windows #108

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions post/clang_tidy_review/clang_tidy_review/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,14 @@ def get_line_ranges(diff, files):

line_filter_json = []
for name, lines in lines_by_file.items():
# On windows, unidiff has forward slashes but clang-tidy expects backslashes
name = os.path.join(*name.split("/"))
line_filter_json.append({"name": name, "lines": lines})
# On windows, unidiff has forward slashes but cl.exe expects backslashes.
# However, clang.exe on windows expects forward slashes.
# Adding a copy of the line filters with backslashes allows for both cl.exe and clang.exe to work.
if os.path.sep == "\\":
# Converts name to backslashes for the cl.exe line filter.
name = os.path.join(*name.split("/"))
line_filter_json.append({"name": name, "lines": lines})
return json.dumps(line_filter_json, separators=(",", ":"))


Expand Down