[cfe-commits] r111298 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.cpp test/SemaCXX/warn-unused-filescoped.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Aug 17 14:43:11 PDT 2010
Author: akirtzidis
Date: Tue Aug 17 16:43:11 2010
New Revision: 111298
URL: http://llvm.org/viewvc/llvm-project?rev=111298&view=rev
Log:
Introduce -Wunused-method option for warning on unused class methods in anonymous namespace.
This option is not part of the Unused diagnostic group until the warnings on llvm codebase are fixed
and we are ready to turn it on. Suggestion by Daniel.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=111298&r1=111297&r2=111298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Aug 17 16:43:11 2010
@@ -133,6 +133,7 @@
def UnusedArgument : DiagGroup<"unused-argument">;
def UnusedExceptionParameter : DiagGroup<"unused-exception-parameter">;
def UnusedFunction : DiagGroup<"unused-function">;
+def UnusedMethod : DiagGroup<"unused-method">;
def UnusedLabel : DiagGroup<"unused-label">;
def UnusedParameter : DiagGroup<"unused-parameter">;
def UnusedValue : DiagGroup<"unused-value">;
@@ -167,6 +168,7 @@
def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
// UnusedParameter, (matches GCC's behavior)
+ // UnusedMethod, (clean-up llvm before enabling)
UnusedValue, UnusedVariable]>,
DiagCategory<"Unused Entity Issue">;
@@ -185,6 +187,7 @@
InitializerOverrides,
SemiBeforeMethodBody,
SignCompare,
+ UnusedMethod,
UnusedParameter
]>;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=111298&r1=111297&r2=111298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 17 16:43:11 2010
@@ -104,6 +104,8 @@
"declaration of %0 will not be visible outside of this function">;
def warn_unused_function : Warning<"unused function %0">,
InGroup<UnusedFunction>, DefaultIgnore;
+def warn_unused_method : Warning<"unused method %0">,
+ InGroup<UnusedMethod>, DefaultIgnore;
def warn_implicit_function_decl : Warning<
"implicit declaration of function %0">,
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=111298&r1=111297&r2=111298&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Aug 17 16:43:11 2010
@@ -376,7 +376,9 @@
const FunctionDecl *DiagD;
if (!FD->hasBody(DiagD))
DiagD = FD;
- Diag(DiagD->getLocation(), diag::warn_unused_function)
+ Diag(DiagD->getLocation(),
+ isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_method
+ : diag::warn_unused_function)
<< DiagD->getDeclName();
} else {
const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition();
Modified: cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp?rev=111298&r1=111297&r2=111298&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp Tue Aug 17 16:43:11 2010
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-method %s
static void f1(); // expected-warning{{unused}}
More information about the cfe-commits
mailing list