mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-27 03:48:33 +00:00
[clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈
Summary: Implicit functions are outside the control of source authors and should be exempt from style restrictions. Tested via running clang tools tests. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D57207 llvm-svn: 352968
This commit is contained in:
parent
cf07b097c6
commit
b08a2d4851
@ -93,12 +93,16 @@ void FunctionNamingCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (!getLangOpts().ObjC)
|
||||
return;
|
||||
|
||||
// Match function declarations that are not in system headers and are not
|
||||
// main.
|
||||
// Enforce Objective-C function naming conventions on all functions except:
|
||||
// • Functions defined in system headers.
|
||||
// • C++ member functions.
|
||||
// • Namespaced functions.
|
||||
// • Implicitly defined functions.
|
||||
// • The main function.
|
||||
Finder->addMatcher(
|
||||
functionDecl(
|
||||
unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
|
||||
hasAncestor(namespaceDecl()), isMain(),
|
||||
hasAncestor(namespaceDecl()), isMain(), isImplicit(),
|
||||
matchesName(validFunctionNameRegex(true)),
|
||||
allOf(isStaticStorageClass(),
|
||||
matchesName(validFunctionNameRegex(false))))))
|
||||
|
@ -1,5 +1,13 @@
|
||||
// RUN: %check_clang_tidy %s google-objc-function-naming %t
|
||||
|
||||
#import <stdio.h>
|
||||
|
||||
static void TestImplicitFunctionDeclaration(int a) {
|
||||
// Call a builtin function so that the compiler generates an implicit
|
||||
// function declaration.
|
||||
printf("%d", a);
|
||||
}
|
||||
|
||||
typedef _Bool bool;
|
||||
|
||||
static bool ispositive(int a) { return a > 0; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user