[clang-tidy] Ignore namespaced and C++ member functions in google-objc-function-naming check 🙈
Summary: The google-objc-function-naming check applies to functions that are not namespaced and should not be applied to C++ member functions. Such function declarations should be ignored by the check to avoid false positives in Objective-C++ sources. Reviewers: benhamilton, aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D55101 llvm-svn: 348317
This commit is contained in:
parent
d6bab09b4b
commit
f6d96e0f98
|
@ -98,8 +98,9 @@ void FunctionNamingCheck::registerMatchers(MatchFinder *Finder) {
|
|||
// main.
|
||||
Finder->addMatcher(
|
||||
functionDecl(
|
||||
unless(isExpansionInSystemHeader()),
|
||||
unless(anyOf(isMain(), matchesName(validFunctionNameRegex(true)),
|
||||
unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
|
||||
hasAncestor(namespaceDecl()), isMain(),
|
||||
matchesName(validFunctionNameRegex(true)),
|
||||
allOf(isStaticStorageClass(),
|
||||
matchesName(validFunctionNameRegex(false))))))
|
||||
.bind("function"),
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// RUN: %check_clang_tidy %s google-objc-function-naming %t
|
||||
|
||||
void printSomething() {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function name 'printSomething' not
|
||||
// using function naming conventions described by Google Objective-C style guide
|
||||
|
||||
void PrintSomething() {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function name 'PrintSomething' not
|
||||
// using function naming conventions described by Google Objective-C style guide
|
||||
|
||||
void ABCBad_Name() {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function name 'ABCBad_Name' not
|
||||
// using function naming conventions described by Google Objective-C style guide
|
||||
|
||||
namespace {
|
||||
|
||||
int foo() { return 0; }
|
||||
|
||||
}
|
||||
|
||||
namespace bar {
|
||||
|
||||
int convert() { return 0; }
|
||||
|
||||
}
|
||||
|
||||
class Baz {
|
||||
public:
|
||||
int value() { return 0; }
|
||||
};
|
Loading…
Reference in New Issue