https://github.com/zeyi2 updated https://github.com/llvm/llvm-project/pull/173762
>From f3b4e516546fc0d43600c8a7409dae9d9857d798 Mon Sep 17 00:00:00 2001 From: mtx <[email protected]> Date: Sun, 28 Dec 2025 15:51:55 +0800 Subject: [PATCH 1/2] [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; } >From c3b8a75a7fc1d031e974b866a1b12a6dba617557 Mon Sep 17 00:00:00 2001 From: mtx <[email protected]> Date: Sun, 28 Dec 2025 23:08:14 +0800 Subject: [PATCH 2/2] Dirty fix --- clang/lib/Tooling/Tooling.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index f19f2d36bb60e..4edbfa699151f 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -102,10 +102,23 @@ static bool ignoreExtraCC1Commands(const driver::Compilation *Compilation) { if (isa<driver::BindArchAction>(A)) A = *A->input_begin(); if (isa<driver::OffloadAction>(A)) { - // 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. + // 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. + if (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()))); + } + // FIXME: CUDA/HIP can produce a single top-level OffloadAction (e.g. + // -fsyntax-only, -E, -M), which contradicts the expectation of at least + // two top-level actions. OffloadCompilation = true; break; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
