forked from OSchip/llvm-project
misc-unused-parameters: Only remove parameters in the main source file.
In headers, they might always be pulled in to different TUs, even if they are declared static or nested in an unnamed namespace. llvm-svn: 243414
This commit is contained in:
parent
3916c910d1
commit
542482e63d
|
@ -70,7 +70,9 @@ void UnusedParametersCheck::warnOnUnusedParameter(
|
|||
};
|
||||
|
||||
// Comment out parameter name for non-local functions.
|
||||
if (Function->isExternallyVisible() || UsedByRef()) {
|
||||
if (Function->isExternallyVisible() ||
|
||||
!Result.SourceManager->isInMainFile(Function->getLocation()) ||
|
||||
UsedByRef()) {
|
||||
SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd());
|
||||
// Note: We always add a space before the '/*' to not accidentally create a
|
||||
// '*/*' for pointer types, which doesn't start a comment. clang-format will
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-unused-parameters %t
|
||||
// RUN: echo "static void staticFunctionHeader(int i) {}" > %T/header.h
|
||||
// RUN: echo "static void staticFunctionHeader(int /*i*/) {}" > %T/header-fixed.h
|
||||
// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-unused-parameters %t -header-filter='.*' --
|
||||
// RUN: diff %T/header.h %T/header-fixed.h
|
||||
// REQUIRES: shell
|
||||
|
||||
#include "header.h"
|
||||
// CHECK-MESSAGES: header.h:1:38: warning
|
||||
|
||||
// Basic removal
|
||||
// =============
|
||||
void a(int i) {}
|
||||
|
|
Loading…
Reference in New Issue