Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion cpp/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Checks: 'clang-diagnostic-*,clang-analyzer-*,-modernize-*,-clang-diagnostic-#pragma-messages,-readability-identifier-naming,-clang-diagnostic-switch'
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
Expand Down
6 changes: 5 additions & 1 deletion cpp/scripts/run-clang-tidy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
#

Expand All @@ -19,6 +19,7 @@
GPU_ARCH_REGEX = re.compile(r"sm_(\d+)")
SPACES = re.compile(r"\s+")
SEPARATOR = "-" * 16
UNSUPPORTED_CLANG_FLAGS = ("-fno-merge-constants",)


def _read_config_file(config_file):
Expand Down Expand Up @@ -180,6 +181,9 @@ def get_tidy_args(cmd, exe):
# remove compilation and output targets from the original command
remove_item_plus_one(command, "-c")
remove_item_plus_one(command, "-o")
for flag in UNSUPPORTED_CLANG_FLAGS:
while remove_item(command, flag) >= 0:
pass
Comment on lines +184 to +186

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Flag filtering can leave malformed compiler args.

At Line 185, removing only -fno-merge-constants by exact token can leave wrapper args like -Xcompiler orphaned (or miss inline forms like -Xcompiler=-fno-merge-constants), which can still break clang-tidy invocation.

Proposed fix
-    for flag in UNSUPPORTED_CLANG_FLAGS:
-        while remove_item(command, flag) >= 0:
-            pass
+    i = 0
+    while i < len(command):
+        token = command[i]
+        removed = False
+        for flag in UNSUPPORTED_CLANG_FLAGS:
+            # direct token: ... -fno-merge-constants ...
+            if token == flag:
+                del command[i]
+                removed = True
+                break
+            # wrapped single token: ... -Xcompiler=-fno-merge-constants ...
+            if token == f"-Xcompiler={flag}":
+                del command[i]
+                removed = True
+                break
+            # wrapped pair: ... -Xcompiler -fno-merge-constants ...
+            if (
+                token == "-Xcompiler"
+                and i + 1 < len(command)
+                and command[i + 1] == flag
+            ):
+                del command[i : i + 2]
+                removed = True
+                break
+        if not removed:
+            i += 1
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/scripts/run-clang-tidy.py` around lines 184 - 186, The current loop using
UNSUPPORTED_CLANG_FLAGS and remove_item(command, flag) only removes exact tokens
and can leave wrapper tokens (e.g., "-Xcompiler") or inline forms
("-Xcompiler=-fno-merge-constants") orphaned; update the filtering to remove (a)
exact matches of each unsupported flag, (b) tokens of the form
"<wrapper>=<flag>" (check startswith for wrappers like "-Xcompiler="), and (c)
wrapper tokens that are separate arguments followed by the flag (e.g., remove
the "-Xcompiler" token when the next token equals the unsupported flag).
Implement this logic around the existing UNSUPPORTED_CLANG_FLAGS and remove_item
usage so command ends up free of both standalone and wrapped forms of
unsupported flags.

if is_cuda:
# replace nvcc's "-gencode ..." with clang's "--cuda-gpu-arch ..."
archs = get_gpu_archs(command)
Expand Down
Loading