clang-tidy

This commit is contained in:
Markus F.X.J. Oberhumer
2023-07-31 14:49:48 +02:00
parent 41e9f7985f
commit 70287d3c49
20 changed files with 176 additions and 51 deletions
@@ -0,0 +1,21 @@
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
---
Checks: >
-*,
bugprone-*,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-reserved-identifier,
clang-analyzer-*,
-clang-analyzer-core.UndefinedBinaryOperatorResult,
-clang-analyzer-core.uninitialized.Assign,
-clang-analyzer-security.insecureAPI.strcpy,
clang-diagnostics-*',
performance-*,
FormatStyle: file
HeaderFilterRegex: '.*'
InheritParentConfig: false
...
@@ -0,0 +1,20 @@
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
---
Checks: >
-*,
bugprone-*,
-bugprone-assignment-in-if-condition,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses,
-bugprone-reserved-identifier,
-bugprone-sizeof-expression,
-bugprone-suspicious-include,
clang-analyzer-*,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
clang-diagnostics-*',
performance-*,
FormatStyle: file
HeaderFilterRegex: '.*'
InheritParentConfig: false
...
@@ -0,0 +1,20 @@
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
---
Checks: >
-*,
bugprone-*,
-bugprone-assignment-in-if-condition,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-reserved-identifier,
clang-analyzer-*,
-clang-analyzer-optin.performance.Padding,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
clang-diagnostics-*',
performance-*,
FormatStyle: file
HeaderFilterRegex: '.*'
InheritParentConfig: false
...
@@ -0,0 +1,24 @@
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
---
Checks: >
-*,
bugprone-*,
-bugprone-assignment-in-if-condition,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses,
-bugprone-misplaced-widening-cast,
-bugprone-narrowing-conversions,
-bugprone-reserved-identifier,
clang-analyzer-*,
-clang-analyzer-core.UndefinedBinaryOperatorResult,
-clang-analyzer-deadcode.DeadStores,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
clang-diagnostics-*',
performance-*,
-performance-no-int-to-ptr,
FormatStyle: file
HeaderFilterRegex: '.*'
InheritParentConfig: false
...
@@ -391,6 +391,27 @@ def main():
)
tmpdir = tempfile.mkdtemp()
# Load the database and extract all files.
database = json.load(open(os.path.join(build_path, db_path)))
files = set(
[make_absolute(entry["file"], entry["directory"]) for entry in database]
)
# Build up a big regexy filter from all command line arguments.
file_name_re = re.compile("|".join(args.files))
# filter files with mo.group(0), and sort files
matched_files = []
for name in files:
mo = file_name_re.search(name)
if mo and mo.group(0):
matched_files.append(name)
files = sorted(matched_files)
if not files:
if tmpdir:
shutil.rmtree(tmpdir)
sys.exit(0)
try:
invocation = get_tidy_invocation(
"",
@@ -422,20 +443,10 @@ def main():
print("Unable to run clang-tidy.", file=sys.stderr)
sys.exit(1)
# Load the database and extract all files.
database = json.load(open(os.path.join(build_path, db_path)))
files = set(
[make_absolute(entry["file"], entry["directory"]) for entry in database]
)
files = sorted(list(files))
max_task = args.j
if max_task == 0:
max_task = multiprocessing.cpu_count()
# Build up a big regexy filter from all command line arguments.
file_name_re = re.compile("|".join(args.files))
return_code = 0
try:
# Spin up a bunch of tidy-launching threads.