summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp4
-rw-r--r--clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m14
2 files changed, 13 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
index 7507eae8b6e..928d33486d2 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@ void GlobalVariableDeclarationCheck::registerMatchers(MatchFinder *Finder) {
this);
Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
.bind("global_const"),
this);
}
@@ -88,7 +88,7 @@ void GlobalVariableDeclarationCheck::check(
if (const auto *Decl = Result.Nodes.getNodeAs<VarDecl>("global_const")) {
diag(Decl->getLocation(),
"const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix")
<< Decl->getName() << generateFixItHint(Decl, true);
}
}
diff --git a/clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m b/clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
index e2316fab4f9..346ddeca7db 100644
--- a/clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
+++ b/clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
@class NSString;
static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
// CHECK-FIXES: static NSString* const kMyConstString = @"hello";
static NSString* MyString = @"hi";
@@ -22,16 +22,24 @@ static NSString* noDef;
// CHECK-FIXES: static NSString* gNoDef;
static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
// CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
// CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
static NSString* gMyIntGood = 0;
+extern NSString* const GTLServiceErrorDomain;
+
+enum GTLServiceError {
+ GTLServiceErrorQueryResultMissing = -3000,
+ GTLServiceErrorWaitTimedOut = -3001,
+};
+
@implementation Foo
- (void)f {
int x = 0;
OpenPOWER on IntegriCloud