[clang] clang: Fix warnings with multiple offload arch args (PR #189329)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 30 00:32:26 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
Fix regression after ab885fdf5f67726ef564c34087e813f2ca861f5c.
Apparently driver tests do not enforce there are no warnings.
Oddly, I need to use -Werror for the specific error. If I use
just -Werror, I get an error that the -Werror is unused.
---
Full diff: https://github.com/llvm/llvm-project/pull/189329.diff
2 Files Affected:
- (modified) clang/lib/Driver/Driver.cpp (+4-1)
- (modified) clang/test/Driver/hip-binding.hip (+1-1)
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index aff34603b8b86..55c9c7766d021 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1015,7 +1015,10 @@ static TripleSet inferOffloadToolchains(Compilation &C,
A->claim();
C.getArgs().append(A);
C.getArgs().AddSynthesizedArg(A);
- Triples.insert(Triple);
+
+ auto It = Triples.lower_bound(Triple);
+ if (It == Triples.end() || *It != Triple)
+ Triples.insert(It, Triple);
}
// Infer the default target triple if no specific architectures are given.
diff --git a/clang/test/Driver/hip-binding.hip b/clang/test/Driver/hip-binding.hip
index 1c02cfaadfad2..cf44692259257 100644
--- a/clang/test/Driver/hip-binding.hip
+++ b/clang/test/Driver/hip-binding.hip
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-print-bindings --target=x86_64-linux-gnu \
+// RUN: %clang -Werror=openmp-target -ccc-print-bindings --target=x86_64-linux-gnu \
// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s \
// RUN: --no-offload-new-driver -c 2>&1 | FileCheck -check-prefix=NRDCS %s
// RUN: %clang -ccc-print-bindings --target=x86_64-linux-gnu --offload-new-driver \
``````````
</details>
https://github.com/llvm/llvm-project/pull/189329
More information about the cfe-commits
mailing list