Skip to content
Snippets Groups Projects
Commit ab8bd20b authored by Frederik Hennig's avatar Frederik Hennig
Browse files

add some apps to clang-tidy analysis

parent e87c5520
No related merge requests found
Pipeline #72515 canceled with stages
in 10 minutes and 55 seconds
......@@ -38,6 +38,17 @@ def get_directory_filter(include_dirs: list[pathlib.Path]):
return filter
def remove_duplicate_commands(db: list):
seen_files: set[str] = set()
db_filtered = []
for x in db:
if x["file"] not in seen_files:
seen_files.add(x["file"])
db_filtered.append(x)
return db_filtered
WARNING_PATTERN = re.compile(r"\[[a-z-]+,-warnings-as-errors\]\n")
TRAILING = len(",-warnings-as-errors]\n")
......@@ -119,7 +130,7 @@ def main():
def run_clang_tidy(
database: list,
include_dirs: list[pathlib.Path],
header_filter: str,
header_filter: str | None,
output: pathlib.Path,
info: str,
):
......@@ -135,12 +146,16 @@ def main():
for x in cc_filtered:
x["command"] = removePrecompiler(x["command"])
cc_filtered = remove_duplicate_commands(cc_filtered)
print(f" -- Retained {len(cc_filtered)} compile commands")
with database_fp.open("w") as db_out:
json.dump(cc_filtered, db_out)
args = clang_tidy_args + ["-header-filter", header_filter]
args = clang_tidy_args
if header_filter:
args += ["-header-filter", header_filter]
output.parent.mkdir(exist_ok=True, parents=True)
errfile = output.with_name(output.name + ".err")
......@@ -179,6 +194,30 @@ def main():
output_dir / "modules" / f"{module_name}.out",
f"module {module_name}",
)
for app_spec in params.get("apps", []):
include_paths: list[pathlib.Path]
app_name: str
match app_spec:
case str():
app_name = app_spec
include_paths = [apps_dir / app_name]
case dict():
app_name, settings = next(iter(app_spec.items()))
if (only := settings.get("only", None)) is not None:
include_paths = [apps_dir / app_name / o for o in only]
else:
include_paths = [apps_dir / app_name]
run_clang_tidy(
orig_db,
include_paths,
None,
output_dir / "apps" / f"{app_name}.out",
f"application {app_name}"
)
finally:
# Restore the backup
shutil.move(str(database_backup), str(database_fp))
......
......@@ -18,3 +18,10 @@ modules:
- timeloop
- vtk:
exclude-tests: true
apps:
- "benchmarks/CouetteFlow"
- "benchmarks/PoiseuilleFlow"
- "benchmarks/UniformGridCPU"
- "benchmarks/NonUniformGridCPU"
# to be extended
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment