Repository navigation
Reland "[Clang] Enable -Wunused-template under -Wall" - #208001
Conversation
Uncomment UnusedTemplate in the Unused diagnostic group so -Wunused-template is part of -Wall. It diagnoses unused function and variable templates with internal linkage; in a header, such a template gives every translation unit its own internal-linkage copy, which is a latent ODR violation. Also update the affected tests (Misc/warning-wall.c and the warn-func-not-needed.cpp / warn-variable-not-needed.cpp -verify tests) and add a release note. Closes llvm#202945.
b1e32ab to
168204d
Compare
|
@llvm/pr-subscribers-clang Author: Aditya Medhane (flash1729) ChangesReland of #206123, which was reverted in #207848. What has changed since:
Marked as draft until #207979 and #207983 land. Closes #202945 5 Files Affected:
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 5de8e546b7812..b49a9db3d5fca 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -570,6 +570,11 @@ latest release, please see the [Clang Web Site](https://clang.llvm.org) or the
allowing it to be disabled independently with `-Wno-unused-but-set-global`.
(#GH148361)
+- `-Wunused-template` is now part of `-Wunused` (which is enabled by `-Wall`).
+ It diagnoses unused function and variable templates with internal linkage,
+ which in a header is a latent ODR hazard. It can be disabled with
+ `-Wno-unused-template`. (#GH202945)
+
- Added `-Wlifetime-safety` to enable lifetime safety analysis,
a CFG-based intra-procedural analysis that detects use-after-free and related
temporal safety bugs. See the
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 16ee72c80dbc8..d353a86f228ba 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1368,7 +1368,7 @@ def Conversion
def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
// UnusedParameter, (matches GCC's behavior)
- // UnusedTemplate, (clean-up libc++ before enabling)
+ UnusedTemplate,
// UnusedMemberFunction, (clean-up llvm before enabling)
UnusedPrivateField, UnusedLambdaCapture,
UnusedLocalTypedef, UnusedValue, UnusedVariable,
diff --git a/clang/test/Misc/warning-wall.c b/clang/test/Misc/warning-wall.c
index 6d6c4e562400f..ade9cbaace77e 100644
--- a/clang/test/Misc/warning-wall.c
+++ b/clang/test/Misc/warning-wall.c
@@ -73,6 +73,8 @@ CHECK-NEXT: -Wunused-argument
CHECK-NEXT: -Wunused-function
CHECK-NEXT: -Wunneeded-internal-declaration
CHECK-NEXT: -Wunused-label
+CHECK-NEXT: -Wunused-template
+CHECK-NEXT: -Wunneeded-internal-declaration
CHECK-NEXT: -Wunused-private-field
CHECK-NEXT: -Wunused-lambda-capture
CHECK-NEXT: -Wunused-local-typedef
diff --git a/clang/test/SemaCXX/warn-func-not-needed.cpp b/clang/test/SemaCXX/warn-func-not-needed.cpp
index cb3cae4cd6c76..74438543c43b7 100644
--- a/clang/test/SemaCXX/warn-func-not-needed.cpp
+++ b/clang/test/SemaCXX/warn-func-not-needed.cpp
@@ -10,7 +10,7 @@ void foo() {
}
namespace test1_template {
-template <typename T> static void f() {}
+template <typename T> static void f() {} // expected-warning {{unused function template}}
template <> void f<int>() {} // expected-warning {{function 'f<int>' is not needed and will not be emitted}}
template <typename T>
void foo() {
diff --git a/clang/test/SemaCXX/warn-variable-not-needed.cpp b/clang/test/SemaCXX/warn-variable-not-needed.cpp
index 272c8998d15c0..d234e9140e3fd 100644
--- a/clang/test/SemaCXX/warn-variable-not-needed.cpp
+++ b/clang/test/SemaCXX/warn-variable-not-needed.cpp
@@ -4,7 +4,7 @@ namespace test1 {
static int abc = 42; // expected-warning {{variable 'abc' is not needed and will not be emitted}}
namespace {
- template <typename T> int abc_template = 0;
+ template <typename T> int abc_template = 0; // expected-warning {{unused variable template}}
template <> int abc_template<int> = 0; // expected-warning {{variable 'abc_template<int>' is not needed and will not be emitted}}
} // namespace
template <typename T>
|
|
ping for review @AaronBallman @erichkeane @vgvassilev |
Reland of #206123, which was reverted in #207848. What has changed since: - flang-rt occurrences are fixed in #207979 - openmp had one more occurrence which is fixed in #207983 - The remaining -Wunused-template hits anywhere in CI logs are the tsan Go runtime warnings, which are warnings only (buildgo.sh does not use -Werror on Linux) Marked as draft until #207979 and #207983 land. Closes #202945
|
This change breaks building Harfbuzz. Harfbuzz internally enables a bunch of diagnostics as errors, see https://github.com/harfbuzz/harfbuzz/blob/14.2.1/src/hb.hh#L93. Previously there were no warnings at all, but now this triggers a bunch of errors: To reproduce, clone https://github.com/harfbuzz/harfbuzz, and configure and build it like this: |
|
I’d think the diagnostic is valid here. If that’s unused we can either delete that code of mark it with the maybe_unused attribute. |
|
I filed harfbuzz/harfbuzz#6059 upstream so they can figure out what they want to do about it - I just happened to run into this while building harfbuzz as part of VLC. |
|
If I saw correctly, it looks like
Errors include e.g.: |
|
thanks for flagging @Thyre, this breakage is similar to past occurrences, I am working on a fix and will ship the patch soon |
|
I'll go ahead and ignore this in HarfBuzz. I find this warning / error unwarranted. Our types and function objects can expose methods that are currently unused by the codebase... |
In that case you can annotate those with |
Right. But that can really be anything. The case reported in the HB issue is of a function-object called This just makes writing encapsulated types harder. |
I'd still claim that writing 6 times the maybe_unused attribute is a good investment ;) |
|
I put up #208642 to add |
…s overload afab8d4 fuzz, refactor: Remove `Serialize` overload (Hennadii Stepanov) efa7f8c fuzz: Remove unused `DeserializeFromFuzzingInput` params overload (Hennadii Stepanov) Pull request description: Clang recently enabled `-Wunused-template` under `-Wall` (see llvm/llvm-project#206123, llvm/llvm-project#207848, llvm/llvm-project#208001). Our codebase [triggers](https://my.cdash.org/builds/3714664/build) some of these warnings. This PR handles the simplest case, where the unused template function can simply be removed. Other cases need different approaches, as their usage depends on the actual TU they are compiled in. Those are left for follow-ups. While cleaning up `src/test/fuzz/deserialize.cpp`, another [suggestion](#35679 (comment)) has been addressed. ACKs for top commit: maflcko: lgtm ACK afab8d4 brunoerg: reACK afab8d4 frankomosh: Review ACK afab8d4 Tree-SHA512: 60e98034aa642a8bc0e43dd6c02e60927b5b51be21bbef5812569c797f5d80a04011bced43a34e237e454008382c792a8f7adbde960268f6ae2c0fe3bb2749b7
…ingInput` params overload 9828a26 fuzz, refactor: Remove `Serialize` overload (Hennadii Stepanov) 0804346 fuzz: Remove unused `DeserializeFromFuzzingInput` params overload (Hennadii Stepanov) Pull request description: Clang recently enabled `-Wunused-template` under `-Wall` (see llvm/llvm-project#206123, llvm/llvm-project#207848, llvm/llvm-project#208001). Our codebase [triggers](https://my.cdash.org/builds/3714664/build) some of these warnings. This PR handles the simplest case, where the unused template function can simply be removed. Other cases need different approaches, as their usage depends on the actual TU they are compiled in. Those are left for follow-ups. While cleaning up `src/test/fuzz/deserialize.cpp`, another [suggestion](bitcoin/bitcoin#35679 (comment)) has been addressed. ACKs for top commit: maflcko: lgtm ACK 9828a26 brunoerg: reACK 9828a26 frankomosh: Review ACK 9828a26 Tree-SHA512: 60e98034aa642a8bc0e43dd6c02e60927b5b51be21bbef5812569c797f5d80a04011bced43a34e237e454008382c792a8f7adbde960268f6ae2c0fe3bb2749b7
…-Wall" (#208001)"
```
/Users/alatsis/Desktop/rebranch/swift-2/lib/Demangling/Remangler.cpp:236:15: error: unused function template 'mangleIdentifier' [-Werror,-Wunused-template]
236 | friend void mangleIdentifier(Mangler &M, StringRef ident);
| ^~~~~~~~~~~~~~~~
```
The referenced commit moves `-Wunused-template` into the `-Wunused`
group, so `-Wall` (and thus `-Werror=unused`) now flags unused
internal-linkage function/variable templates. Fixes, matching the
warning's intent (internal-linkage templates are a latent ODR hazard):
drop the redundant unqualified `mangleIdentifier` friend template (the
real one is already befriended as `Mangle::mangleIdentifier`); give the
genuinely header/file-scope helpers `TypeLookupErrorImpl`,
`assignUnlessEqual`, `tuple_allocateBuffer` and `pointer_function_cast`
external linkage via `inline`; and mark the unused variadic
`getExtraAllocationSize` cache-entry members `[[maybe_unused]]`.
See llvm/llvm-project@1529d35 (llvm/llvm-project#208001).
Assisted-by: Claude Code
…-Wall" (#208001)"
```
/Users/alatsis/Desktop/rebranch/swift-2/lib/Demangling/Remangler.cpp:236:15: error: unused function template 'mangleIdentifier' [-Werror,-Wunused-template]
236 | friend void mangleIdentifier(Mangler &M, StringRef ident);
| ^~~~~~~~~~~~~~~~
```
The referenced commit moves `-Wunused-template` into the `-Wunused`
group, so `-Wall` (and thus `-Werror=unused`) now flags unused
internal-linkage function/variable templates. Fixes, matching the
warning's intent (internal-linkage templates are a latent ODR hazard):
drop the redundant unqualified `mangleIdentifier` friend template (the
real one is already befriended as `Mangle::mangleIdentifier`); give the
genuinely header/file-scope helpers `TypeLookupErrorImpl`,
`assignUnlessEqual`, `tuple_allocateBuffer` and `pointer_function_cast`
external linkage via `inline`; and mark the unused variadic
`getExtraAllocationSize` cache-entry members `[[maybe_unused]]`.
See llvm/llvm-project@1529d35 (llvm/llvm-project#208001).
Assisted-by: Claude Code
…-Wall" (#208001)"
```
/Users/alatsis/Desktop/rebranch/swift-2/lib/Demangling/Remangler.cpp:236:15: error: unused function template 'mangleIdentifier' [-Werror,-Wunused-template]
236 | friend void mangleIdentifier(Mangler &M, StringRef ident);
| ^~~~~~~~~~~~~~~~
```
The referenced commit moves `-Wunused-template` into the `-Wunused`
group, so `-Wall` (and thus `-Werror=unused`) now flags unused
internal-linkage function/variable templates. Fixes, matching the
warning's intent (internal-linkage templates are a latent ODR hazard):
drop the redundant unqualified `mangleIdentifier` friend template (the
real one is already befriended as `Mangle::mangleIdentifier`); give the
genuinely header/file-scope helpers `TypeLookupErrorImpl`,
`assignUnlessEqual`, `tuple_allocateBuffer` and `pointer_function_cast`
external linkage via `inline`; and mark the unused variadic
`getExtraAllocationSize` cache-entry members `[[maybe_unused]]`.
See llvm/llvm-project@1529d35 (llvm/llvm-project#208001).
Assisted-by: Claude Code
…-Wall" (#208001)"
```
/Users/alatsis/Desktop/rebranch/swift-2/lib/Demangling/Remangler.cpp:236:15: error: unused function template 'mangleIdentifier' [-Werror,-Wunused-template]
236 | friend void mangleIdentifier(Mangler &M, StringRef ident);
| ^~~~~~~~~~~~~~~~
```
The referenced commit moves `-Wunused-template` into the `-Wunused`
group, so `-Wall` (and thus `-Werror=unused`) now flags unused
internal-linkage function/variable templates. Fixes, matching the
warning's intent (internal-linkage templates are a latent ODR hazard):
drop the redundant unqualified `mangleIdentifier` friend template (the
real one is already befriended as `Mangle::mangleIdentifier`); give the
genuinely header/file-scope helpers `TypeLookupErrorImpl`,
`assignUnlessEqual`, `tuple_allocateBuffer` and `pointer_function_cast`
external linkage via `inline`; and mark the unused variadic
`getExtraAllocationSize` cache-entry members `[[maybe_unused]]`.
See llvm/llvm-project@1529d35 (llvm/llvm-project#208001).
Assisted-by: Claude Code
…-Wall" (#208001)"
```
/Users/alatsis/Desktop/rebranch/swift-2/lib/Demangling/Remangler.cpp:236:15: error: unused function template 'mangleIdentifier' [-Werror,-Wunused-template]
236 | friend void mangleIdentifier(Mangler &M, StringRef ident);
| ^~~~~~~~~~~~~~~~
```
The referenced commit moves `-Wunused-template` into the `-Wunused`
group, so `-Wall` (and thus `-Werror=unused`) now flags unused
internal-linkage function/variable templates. Fixes, matching the
warning's intent (internal-linkage templates are a latent ODR hazard):
drop the redundant unqualified `mangleIdentifier` friend template (the
real one is already befriended as `Mangle::mangleIdentifier`); give the
genuinely header/file-scope helpers `TypeLookupErrorImpl`,
`assignUnlessEqual`, `tuple_allocateBuffer` and `pointer_function_cast`
external linkage via `inline`; and mark the unused variadic
`getExtraAllocationSize` cache-entry members `[[maybe_unused]]`.
See llvm/llvm-project@1529d35 (llvm/llvm-project#208001).
Assisted-by: Claude Code
…with `[[maybe_unused]]` 9e059b2 refactor: Annotate `MakeAndPushFeature` with `[[maybe_unused]]` (Hennadii Stepanov) Pull request description: This is a follow-up to bitcoin/bitcoin#35221. The `MakeAndPushFeature` member function template has no callers yet, which [triggers](https://my.cdash.org/builds/3851810/build) `-Wunused-template` now that Clang 23 [enables](llvm/llvm-project#208001) it as part of `-Wall`. Related PRs: - bitcoin/bitcoin#35679 - bitcoin/bitcoin#35737 - bitcoin-core/minisketch#102 ACKs for top commit: maflcko: lgtm ACK 9e059b2 sedited: ACK 9e059b2 Tree-SHA512: c8b639055d34ea431d5d5f4c85815b4c19b31d6ea7e4a0c05c8420a328503028eca465fb0803eff3d4bab2c782cb8038844d3f89680928791832488494bd95d4
…into cluster_linearize namespace 0982505 test: Move cluster_linearize.h contents into cluster_linearize namespace (Hennadii Stepanov) Pull request description: Clang recently enabled `-Wunused-template` under `-Wall` (see llvm/llvm-project#206123, llvm/llvm-project#207848, llvm/llvm-project#208001). Our codebase [triggers](https://my.cdash.org/builds/3714664/build) some of these warnings. This PR: 1. Avoids Clang's `-Wunused-template` warnings in `src/test/util/cluster_linearize.h` when building the `bench_bitcoin` and `fuzz` targets. 2. Follows the C++ Core Guidelines: "[SF.21: Don't use an unnamed (anonymous) namespace in a header](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf21-dont-use-an-unnamed-anonymous-namespace-in-a-header)". 3. Drops `[[maybe_unused]]` annotations, which are no longer needed after changing the linkage from internal to external. Along with bitcoin/bitcoin#35679, this resolves all instances of this warning in the test/bench/fuzz code. Another related change: bitcoin-core/minisketch#102. --- Steps to reproduce on the master branch @ c7bd54a: ```console $ CXXFLAGS="-Wunused-template" cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_BENCH=ON $ cmake --build build -t test_bitcoin $ cmake --build build -t bench_bitcoin [19/62] Building CXX object src/bench/CMakeFiles/bench_bitcoin.dir/cluster_linearize.cpp.o In file included from /home/hebasto/dev/bitcoin/src/bench/cluster_linearize.cpp:9: /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:122:17: warning: unused function template 'Ser' [-Wunused-template] 122 | static void Ser(Stream& s, const DepGraph<SetType>& depgraph) | ^~~ /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:286:6: warning: unused function template 'SanityCheck' [-Wunused-template] 286 | void SanityCheck(const DepGraph<SetType>& depgraph) | ^~~~~~~~~~~ /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:383:6: warning: unused function template 'SanityCheck' [-Wunused-template] 383 | void SanityCheck(const DepGraph<SetType>& depgraph, std::span<const DepGraphIndex> linearization) | ^~~~~~~~~~~ 3 warnings generated. [62/62] Linking CXX executable bin/bench_bitcoin ``` ACKs for top commit: maflcko: lgtm ACK 0982505 sedited: ACK 0982505 Tree-SHA512: 893082c2dc3295b68738c438094656b3568f85b95e0e2f9b0b9dd178d0613e4cb50cd2300a9595e390b9d0a4c650ca78d2772dd1010c178756cefbeef6e2ed94
…214759) Another case of the cleanup done for #208001, which enabled -Wunused-template under -Wall. Both helpers are `static` in ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and MemRef.h, so clang warns wherever they are not instantiated. Dropping `static` gives them vague linkage.
…es (#214756) These are more of the cases fixed alongside #208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
…214759) Another case of the cleanup done for #208001, which enabled -Wunused-template under -Wall. Both helpers are `static` in ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and MemRef.h, so clang warns wherever they are not instantiated. Dropping `static` gives them vague linkage.
…es (#214756) These are more of the cases fixed alongside #208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
…selections d14cd49 Avoid Clang's `-Wunused-template` under restricted field selections (Hennadii Stepanov) Pull request description: Clang recently enabled `-Wunused-template` under `-Wall` (see llvm/llvm-project#206123, llvm/llvm-project#207848, llvm/llvm-project#208001), which [breaks](https://my.cdash.org/builds/3714664/build) `-Wall -Werror` builds of downstream projects that compile minisketch with a restricted field set, including Bitcoin Core. On the master branch @ d1bd01e: ```console $ CXXFLAGS="-Wunused-template" cmake -B build -DCMAKE_CXX_COMPILER=clang++ -DMINISKETCH_FIELDS=2 $ cmake --build build [35/40] Building CXX object src/CMakeFiles/minisketch.dir/fields/clmul_1byte.cpp.o In file included from /home/hebasto/dev/minisketch/src/fields/clmul_1byte.cpp:12: /home/hebasto/dev/minisketch/src/fields/clmul_common_impl.h:31:60: warning: unused function template 'MulWithClMulReduce' [-Wunused-template] 31 | template<typename I, int BITS, I MOD> NO_SANITIZE_MEMORY I MulWithClMulReduce(I a, I b) | ^~~~~~~~~~~~~~~~~~ 1 warning generated. [37/40] Building CXX object src/CMakeFiles/minisketch_verify.dir/fields/clmul_1byte.cpp.o In file included from /home/hebasto/dev/minisketch/src/fields/clmul_1byte.cpp:12: /home/hebasto/dev/minisketch/src/fields/clmul_common_impl.h:31:60: warning: unused function template 'MulWithClMulReduce' [-Wunused-template] 31 | template<typename I, int BITS, I MOD> NO_SANITIZE_MEMORY I MulWithClMulReduce(I a, I b) | ^~~~~~~~~~~~~~~~~~ 1 warning generated. [40/40] Linking CXX executable bin/test-verify ``` Bitcoin Core's case: ```console $ CXXFLAGS="-Wunused-template" cmake -B build -DCMAKE_CXX_COMPILER=clang++ -DMINISKETCH_FIELDS=32 $ cmake --build build [16/40] Building CXX object src/CMakeFiles/minisketch.dir/fields/clmul_4bytes.cpp.o In file included from /home/hebasto/dev/minisketch/src/fields/clmul_4bytes.cpp:12: /home/hebasto/dev/minisketch/src/fields/clmul_common_impl.h:68:62: warning: unused function template 'MulTrinomial' [-Wunused-template] 68 | template<typename I, int BITS, int POS> NO_SANITIZE_MEMORY I MulTrinomial(I a, I b) | ^~~~~~~~~~~~ 1 warning generated. [36/40] Building CXX object src/CMakeFiles/minisketch_verify.dir/fields/clmul_4bytes.cpp.o In file included from /home/hebasto/dev/minisketch/src/fields/clmul_4bytes.cpp:12: /home/hebasto/dev/minisketch/src/fields/clmul_common_impl.h:68:62: warning: unused function template 'MulTrinomial' [-Wunused-template] 68 | template<typename I, int BITS, int POS> NO_SANITIZE_MEMORY I MulTrinomial(I a, I b) | ^~~~~~~~~~~~ 1 warning generated. [40/40] Linking CXX executable bin/test-verify ``` --- Alternatively, ~function templates can be moved out of the anonymous namespace~ the anonymous namespace can be switched to a named one (C++ Core Guidelines, [SF.21](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf21-dont-use-an-unnamed-anonymous-namespace-in-a-header)). ACKs for top commit: sipa: ACK d14cd49 Tree-SHA512: 2aec8cc492e8f434020be61f47adbc2ef53547b245667f064e2b8d59d0375cc9bb27c8a690a6450010d3164ecacdcb3c37b479f806441ada633d997a1bc7d884
…lvm#214759) Another case of the cleanup done for llvm#208001, which enabled -Wunused-template under -Wall. Both helpers are `static` in ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and MemRef.h, so clang warns wherever they are not instantiated. Dropping `static` gives them vague linkage.
…es (llvm#214756) These are more of the cases fixed alongside llvm#208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
…lvm#214759) Another case of the cleanup done for llvm#208001, which enabled -Wunused-template under -Wall. Both helpers are `static` in ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and MemRef.h, so clang warns wherever they are not instantiated. Dropping `static` gives them vague linkage.
…es (llvm#214756) These are more of the cases fixed alongside llvm#208001, which enabled -Wunused-template under -Wall. Each template is `static` in a widely included header, so clang warns in every TU that includes it without instantiating it. Dropping `static` gives them vague linkage and silences the warning.
…ingInput` params overload afab8d4225c720f8d8658d4ea134505b3d9531f9 fuzz, refactor: Remove `Serialize` overload (Hennadii Stepanov) efa7f8c1437681dfae536017da6f27c75f8f2309 fuzz: Remove unused `DeserializeFromFuzzingInput` params overload (Hennadii Stepanov) Pull request description: Clang recently enabled `-Wunused-template` under `-Wall` (see llvm/llvm-project#206123, llvm/llvm-project#207848, llvm/llvm-project#208001). Our codebase [triggers](https://my.cdash.org/builds/3714664/build) some of these warnings. This PR handles the simplest case, where the unused template function can simply be removed. Other cases need different approaches, as their usage depends on the actual TU they are compiled in. Those are left for follow-ups. While cleaning up `src/test/fuzz/deserialize.cpp`, another [suggestion](bitcoin/bitcoin#35679 (comment)) has been addressed. ACKs for top commit: maflcko: lgtm ACK afab8d4225c720f8d8658d4ea134505b3d9531f9 brunoerg: reACK afab8d4225c720f8d8658d4ea134505b3d9531f9 frankomosh: Review ACK afab8d4225c720f8d8658d4ea134505b3d9531f9 Tree-SHA512: 60e98034aa642a8bc0e43dd6c02e60927b5b51be21bbef5812569c797f5d80a04011bced43a34e237e454008382c792a8f7adbde960268f6ae2c0fe3bb2749b7
…with `[[maybe_unused]]` 0238aebf619013a761c06ad3c57a56ee50f4541c refactor: Annotate `MakeAndPushFeature` with `[[maybe_unused]]` (Hennadii Stepanov) Pull request description: This is a follow-up to bitcoin/bitcoin#35221. The `MakeAndPushFeature` member function template has no callers yet, which [triggers](https://my.cdash.org/builds/3851810/build) `-Wunused-template` now that Clang 23 [enables](llvm/llvm-project#208001) it as part of `-Wall`. Related PRs: - bitcoin/bitcoin#35679 - bitcoin/bitcoin#35737 - bitcoin-core/minisketch#102 ACKs for top commit: maflcko: lgtm ACK 0238aebf619013a761c06ad3c57a56ee50f4541c sedited: ACK 0238aebf619013a761c06ad3c57a56ee50f4541c Tree-SHA512: c8b639055d34ea431d5d5f4c85815b4c19b31d6ea7e4a0c05c8420a328503028eca465fb0803eff3d4bab2c782cb8038844d3f89680928791832488494bd95d4
…into cluster_linearize namespace 21b4b790e4884e1edef6ea8da589e71f1ceacde8 test: Move cluster_linearize.h contents into cluster_linearize namespace (Hennadii Stepanov) Pull request description: Clang recently enabled `-Wunused-template` under `-Wall` (see llvm/llvm-project#206123, llvm/llvm-project#207848, llvm/llvm-project#208001). Our codebase [triggers](https://my.cdash.org/builds/3714664/build) some of these warnings. This PR: 1. Avoids Clang's `-Wunused-template` warnings in `src/test/util/cluster_linearize.h` when building the `bench_bitcoin` and `fuzz` targets. 2. Follows the C++ Core Guidelines: "[SF.21: Don't use an unnamed (anonymous) namespace in a header](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf21-dont-use-an-unnamed-anonymous-namespace-in-a-header)". 3. Drops `[[maybe_unused]]` annotations, which are no longer needed after changing the linkage from internal to external. Along with bitcoin/bitcoin#35679, this resolves all instances of this warning in the test/bench/fuzz code. Another related change: bitcoin-core/minisketch#102. --- Steps to reproduce on the master branch @ 70d9ec7f3d452789d04dce81dc02db0b3b778bb5: ```console $ CXXFLAGS="-Wunused-template" cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_BENCH=ON $ cmake --build build -t test_bitcoin $ cmake --build build -t bench_bitcoin [19/62] Building CXX object src/bench/CMakeFiles/bench_bitcoin.dir/cluster_linearize.cpp.o In file included from /home/hebasto/dev/bitcoin/src/bench/cluster_linearize.cpp:9: /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:122:17: warning: unused function template 'Ser' [-Wunused-template] 122 | static void Ser(Stream& s, const DepGraph<SetType>& depgraph) | ^~~ /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:286:6: warning: unused function template 'SanityCheck' [-Wunused-template] 286 | void SanityCheck(const DepGraph<SetType>& depgraph) | ^~~~~~~~~~~ /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:383:6: warning: unused function template 'SanityCheck' [-Wunused-template] 383 | void SanityCheck(const DepGraph<SetType>& depgraph, std::span<const DepGraphIndex> linearization) | ^~~~~~~~~~~ 3 warnings generated. [62/62] Linking CXX executable bin/bench_bitcoin ``` ACKs for top commit: maflcko: lgtm ACK 21b4b790e4884e1edef6ea8da589e71f1ceacde8 sedited: ACK 21b4b790e4884e1edef6ea8da589e71f1ceacde8 Tree-SHA512: 893082c2dc3295b68738c438094656b3568f85b95e0e2f9b0b9dd178d0613e4cb50cd2300a9595e390b9d0a4c650ca78d2772dd1010c178756cefbeef6e2ed94
Reverts `a06d76ec59bc`, restoring upstream `1529d35adbd6` ("Reland
"[Clang] Enable -Wunused-template under -Wall" (llvm#208001)").
## Why it was reverted
`a06d76ec59bc` was a same-day downstream revert on 2026-07-08 to unblock
CI. hipDNN built with `-Werror` and hit three unused internal-linkage
function templates:
```
ShapeUtilities.hpp:348:13: error: unused function template 'iterateAlongDimensions' [-Werror,-Wunused-template]
CpuFpReferenceUtilities.hpp:141:5: error: unused function template 'callFuncUnpackArgsImpl' [-Werror,-Wunused-template]
CpuFpReferenceUtilities.hpp:147:13: error: unused function template 'callFuncUnpackArgs' [-Werror,-Wunused-template]
```
Tracked as ALMIOPEN-2293.
## Why it can go back in
[ROCm/rocm-libraries#10193](ROCm/rocm-libraries#10193)
fixed all of them — nine files, the three above plus six more
`cpu_graph_executor` headers — and merged 2026-08-04 (`1aa8a6f6afa8`).
It also added the diagnostic to hipdnn's own warning flags:
```cmake
$<$<CXX_COMPILER_ID:Clang>:-Wunused-template> # Clang: catch unused internal-linkage templates (matches llvm-project CI)
```
so hipdnn enforces it independently of whether it is in `-Wall`, and
will catch regressions on its own.
The fix is reachable from TheRock's pinned `rocm-libraries` submodule
(`416eae89dcee`, 0 commits behind `1aa8a6f6afa8`), so it is present in
the tree `amd-staging` CI builds. Verified at that pin: the
`-Wunused-template` flag is on line 261 of
`projects/hipdnn/CMakeLists.txt`, and `iterateAlongDimensions` is no
longer `static`.
## Result
The four affected files now match `upstream/main` exactly (`git diff
upstream/main` over them is empty).
Note that `clang/docs/ReleaseNotes.md` already documents
`-Wunused-template` as part of `-Wunused` — a later upstream merge
restored that paragraph, so the docs and the code have been inconsistent
since the revert. This change makes them agree again.
The stale `revert_patches.txt` entry is removed.
…08001)" (llvm#218638) This reverts commit 1529d35. There are two issues: - The change appear fairly disruptive so close to release (see comments on llvm#208001) - there are false positives (see llvm#218429)
Reland of #206123, which was reverted in #207848.
What has changed since:
Marked as draft until #207979 and #207983 land.
Closes #202945