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.

llvm-svn: 111298
This commit is contained in:
Argyrios Kyrtzidis 2010-08-17 21:43:11 +00:00
parent 798f83239c
commit cad715fb9b
4 changed files with 9 additions and 2 deletions

View File

@ -133,6 +133,7 @@ def UnknownAttributes : DiagGroup<"unknown-attributes">;
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 Conversion : DiagGroup<"conversion",
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 @@ def Extra : DiagGroup<"extra", [
InitializerOverrides,
SemiBeforeMethodBody,
SignCompare,
UnusedMethod,
UnusedParameter
]>;

View File

@ -104,6 +104,8 @@ def warn_decl_in_param_list : Warning<
"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">,

View File

@ -376,7 +376,9 @@ void Sema::ActOnEndOfTranslationUnit() {
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();

View File

@ -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}}