-
Notifications
You must be signed in to change notification settings - Fork 78
Use the same version of clang-tidy and clang-format as clang #6006
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
+83
−66
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6e43ee6
Install clang-tidy-19
wujingyue 7866a83
WIP
wujingyue 6b72c78
WIP
wujingyue fb3fe7c
Add a TODO for CUDA include path
wujingyue 026f895
Fix clang-format
wujingyue 090a2a0
Remove windows support -- YAGNI
wujingyue 5625a5d
Proper setup for lintrunner
wujingyue f51af80
Install llvm-19 earlier
wujingyue 2676598
Fix clang-format
wujingyue e1f4919
Review
wujingyue 637b9c6
shell=False
wujingyue 759f66b
Merge branch 'main' into wjy/tidy
wujingyue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,6 @@ | |
| from typing import Any, List, NamedTuple, Optional | ||
|
|
||
|
|
||
| IS_WINDOWS: bool = os.name == "nt" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. YAGNI |
||
|
|
||
|
|
||
| def eprint(*args: Any, **kwargs: Any) -> None: | ||
| print(*args, file=sys.stderr, flush=True, **kwargs) | ||
|
|
||
|
|
@@ -37,10 +34,6 @@ class LintMessage(NamedTuple): | |
| description: Optional[str] | ||
|
|
||
|
|
||
| def as_posix(name: str) -> str: | ||
| return name.replace("\\", "/") if IS_WINDOWS else name | ||
|
|
||
|
|
||
| def _run_command( | ||
| args: List[str], | ||
| *, | ||
|
|
@@ -51,9 +44,7 @@ def _run_command( | |
| try: | ||
| return subprocess.run( | ||
| args, | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.PIPE, | ||
| shell=IS_WINDOWS, # So batch scripts are found. | ||
| capture_output=True, | ||
| timeout=timeout, | ||
| check=True, | ||
| ) | ||
|
|
@@ -138,7 +129,7 @@ def check_file( | |
| "STDOUT\n{stdout}" | ||
| ).format( | ||
| returncode=err.returncode, | ||
| command=" ".join(as_posix(x) for x in err.cmd), | ||
| command=" ".join(err.cmd), | ||
| stderr=err.stderr.decode("utf-8").strip() or "(empty)", | ||
| stdout=err.stdout.decode("utf-8").strip() or "(empty)", | ||
| ) | ||
|
|
@@ -170,11 +161,6 @@ def main() -> None: | |
| description="Format files with clang-format.", | ||
| fromfile_prefix_chars="@", | ||
| ) | ||
| parser.add_argument( | ||
| "--binary", | ||
| required=True, | ||
| help="clang-format binary path", | ||
| ) | ||
| parser.add_argument( | ||
| "--retries", | ||
| default=3, | ||
|
|
@@ -201,16 +187,36 @@ def main() -> None: | |
|
|
||
| logging.basicConfig( | ||
| format="<%(threadName)s:%(levelname)s> %(message)s", | ||
| level=logging.NOTSET | ||
| if args.verbose | ||
| else logging.DEBUG | ||
| if len(args.filenames) < 1000 | ||
| else logging.INFO, | ||
| level=( | ||
| logging.NOTSET | ||
| if args.verbose | ||
| else logging.DEBUG | ||
| if len(args.filenames) < 1000 | ||
| else logging.INFO | ||
| ), | ||
| stream=sys.stderr, | ||
| ) | ||
|
|
||
| binary = os.path.normpath(args.binary) if IS_WINDOWS else args.binary | ||
| binary = os.path.expanduser(binary) | ||
| try: | ||
| llvm_bindir = subprocess.check_output( | ||
| ["llvm-config", "--bindir"], text=True | ||
| ).strip() | ||
| except FileNotFoundError: | ||
| lint_message = LintMessage( | ||
| path=None, | ||
| line=None, | ||
| char=None, | ||
| code="CLANGFORMAT", | ||
| severity=LintSeverity.ERROR, | ||
| name="init-error", | ||
| original=None, | ||
| replacement=None, | ||
| description="llvm-config doesn't exist (is LLVM installed?).", | ||
| ) | ||
| print(json.dumps(lint_message._asdict()), flush=True) | ||
| sys.exit(0) | ||
|
|
||
| binary = os.path.join(llvm_bindir, "clang-format") | ||
| if not Path(binary).exists(): | ||
| lint_message = LintMessage( | ||
| path=None, | ||
|
|
@@ -222,8 +228,7 @@ def main() -> None: | |
| original=None, | ||
| replacement=None, | ||
| description=( | ||
| f"Could not find clang-format binary at {binary}, " | ||
| "did you forget to run `lintrunner init`?" | ||
| f"Could not find clang-format binary at {binary} (is LLVM installed?)", | ||
| ), | ||
| ) | ||
| print(json.dumps(lint_message._asdict()), flush=True) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.