[clang-tools-extra] [clang-tidy] Export fixes from check_clang_tidy.py (PR #88186)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 9 13:17:49 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 2950283dddab03c183c1be2d7de9d4999cc86131...596037423faeebf01759158b5a93a3e933978941 clang-tools-extra/test/clang-tidy/check_clang_tidy.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- check_clang_tidy.py 2024-04-09 20:07:52.000000 +0000
+++ check_clang_tidy.py 2024-04-09 20:17:24.042204 +0000
@@ -112,19 +112,18 @@
self.clang_extra_args = []
self.clang_tidy_extra_args = extra_args
if "--" in extra_args:
i = self.clang_tidy_extra_args.index("--")
- self.clang_extra_args = self.clang_tidy_extra_args[i + 1:]
+ self.clang_extra_args = self.clang_tidy_extra_args[i + 1 :]
self.clang_tidy_extra_args = self.clang_tidy_extra_args[:i]
# If the test does not specify a config style, force an empty one; otherwise
# auto-detection logic can discover a ".clang-tidy" file that is not related to
# the test.
if not any(
- [re.match("^-?-config(-file)?=", arg)
- for arg in self.clang_tidy_extra_args]
+ [re.match("^-?-config(-file)?=", arg) for arg in self.clang_tidy_extra_args]
):
self.clang_tidy_extra_args.append("--config={}")
if extension in [".m", ".mm"]:
self.clang_extra_args = [
@@ -139,12 +138,11 @@
# Tests should not rely on STL being available, and instead provide mock
# implementations of relevant APIs.
self.clang_extra_args.append("-nostdinc++")
if self.resource_dir is not None:
- self.clang_extra_args.append(
- "-resource-dir=%s" % self.resource_dir)
+ self.clang_extra_args.append("-resource-dir=%s" % self.resource_dir)
def read_input(self):
with open(self.input_file_name, "r", encoding="utf-8") as input_file:
self.input_text = input_file.read()
@@ -156,20 +154,17 @@
+ ' but "%s" was given' % suffix
)
file_check_suffix = ("-" + suffix) if suffix else ""
- has_check_fix = self.fixes.check(
- file_check_suffix, self.input_text)
+ has_check_fix = self.fixes.check(file_check_suffix, self.input_text)
self.has_check_fixes = self.has_check_fixes or has_check_fix
- has_check_message = self.messages.check(
- file_check_suffix, self.input_text)
+ has_check_message = self.messages.check(file_check_suffix, self.input_text)
self.has_check_messages = self.has_check_messages or has_check_message
- has_check_note = self.notes.check(
- file_check_suffix, self.input_text)
+ has_check_note = self.notes.check(file_check_suffix, self.input_text)
self.has_check_notes = self.has_check_notes or has_check_note
if has_check_note and has_check_message:
sys.exit(
"Please use either %s or %s but not both"
@@ -187,22 +182,22 @@
def prepare_test_inputs(self):
# Remove the contents of the CHECK lines to avoid CHECKs matching on
# themselves. We need to keep the comments to preserve line numbers while
# avoiding empty lines which could potentially trigger formatting-related
# checks.
- cleaned_test = re.sub(
- "// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", self.input_text)
+ cleaned_test = re.sub("// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", self.input_text)
write_file(self.temp_file_name, cleaned_test)
write_file(self.original_file_name, cleaned_test)
def run_clang_tidy(self):
args = (
[
"clang-tidy",
self.temp_file_name,
- ] + ["-fix" if self.export is None else "--export-fixes=" + self.export] +
- [
+ ]
+ + ["-fix" if self.export is None else "--export-fixes=" + self.export]
+ + [
"--checks=-*," + self.check_name,
]
+ self.clang_tidy_extra_args
+ ["--"]
+ self.clang_extra_args
@@ -328,12 +323,16 @@
default=None,
type=str,
metavar="file",
help="A file to export fixes into instead of fixing.",
)
- parser.add_argument("-std", type=csv, default=["c++11-or-later"],
- help="Passed to clang. Special -or-later values are expanded.")
+ parser.add_argument(
+ "-std",
+ type=csv,
+ default=["c++11-or-later"],
+ help="Passed to clang. Special -or-later values are expanded.",
+ )
return parser.parse_known_args()
def main():
args, extra_args = parse_arguments()
``````````
</details>
https://github.com/llvm/llvm-project/pull/88186
More information about the cfe-commits
mailing list