[PATCH] D143524: Make the -Wunused-template default.
Vassil Vassilev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 13:17:22 PST 2023
v.g.vassilev created this revision.
v.g.vassilev added reviewers: aaron.ballman, ldionne.
Herald added a project: All.
v.g.vassilev requested review of this revision.
https://reviews.llvm.org/D29877 implements a useful -Wunused-template diagnostic detects unused internal linkage templates. This helps finding potential ODR issues in headers.
Many years ago we made the diagnostic optional because libcxx was not ready. I am hoping @ldionne to help with that if we have not cleaned up libcxx already.
Repository:
rC Clang
https://reviews.llvm.org/D143524
Files:
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/Misc/warning-wall.c
clang/test/SemaCXX/warn-func-not-needed.cpp
clang/test/SemaCXX/warn-variable-not-needed.cpp
Index: clang/test/SemaCXX/warn-variable-not-needed.cpp
===================================================================
--- clang/test/SemaCXX/warn-variable-not-needed.cpp
+++ clang/test/SemaCXX/warn-variable-not-needed.cpp
@@ -4,7 +4,7 @@
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>
Index: clang/test/SemaCXX/warn-func-not-needed.cpp
===================================================================
--- clang/test/SemaCXX/warn-func-not-needed.cpp
+++ clang/test/SemaCXX/warn-func-not-needed.cpp
@@ -10,7 +10,7 @@
}
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() {
Index: clang/test/Misc/warning-wall.c
===================================================================
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -66,6 +66,8 @@
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
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -929,7 +929,7 @@
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143524.495628.patch
Type: text/x-patch
Size: 2545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230207/41a1e397/attachment-0001.bin>
More information about the cfe-commits
mailing list