https://github.com/zeyi2 created https://github.com/llvm/llvm-project/pull/173762
Running clang-tidy on CUDA files without specifying `--cuda-host-only` or `--cuda-device-only` would trigger an assertion failure in `Actions.size() > 1`, a related discussion: https://github.com/llvm/llvm-project/pull/173699#discussion_r2649279975. This occurred because the Clang Driver generates a single top-level `OffloadAction` in `-fsyntax-only` mode which clang-tidy uses. This commit removes the overly strict assertions. >From f3b4e516546fc0d43600c8a7409dae9d9857d798 Mon Sep 17 00:00:00 2001 From: mtx <[email protected]> Date: Sun, 28 Dec 2025 15:51:55 +0800 Subject: [PATCH] [clang-tidy] Fix assertion failure when processing CUDA files --- clang/lib/Tooling/Tooling.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index f10aa524674da..f19f2d36bb60e 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -102,19 +102,10 @@ static bool ignoreExtraCC1Commands(const driver::Compilation *Compilation) { if (isa<driver::BindArchAction>(A)) A = *A->input_begin(); if (isa<driver::OffloadAction>(A)) { - // Offload compilation has 2 top-level actions, one (at the front) is - // the original host compilation and the other is offload action - // composed of at least one device compilation. For such case, general - // tooling will consider host-compilation only. For tooling on device - // compilation, device compilation only option, such as - // `--cuda-device-only`, needs specifying. - assert(Actions.size() > 1); - assert( - isa<driver::CompileJobAction>(Actions.front()) || - // On MacOSX real actions may end up being wrapped in - // BindArchAction. - (isa<driver::BindArchAction>(Actions.front()) && - isa<driver::CompileJobAction>(*Actions.front()->input_begin()))); + // For offload compilation, general tooling will consider host + // compilation only. For tooling on device compilation, device + // compilation only option, such as `--cuda-device-only`, needs + // specifying. OffloadCompilation = true; break; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
