Wizard created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D59283 Files: clang-tidy/google/GlobalVariableDeclarationCheck.cpp test/clang-tidy/google-objc-global-variable-declaration.m test/clang-tidy/google-objc-global-variable-declaration.mm Index: test/clang-tidy/google-objc-global-variable-declaration.mm =================================================================== --- test/clang-tidy/google-objc-global-variable-declaration.mm +++ test/clang-tidy/google-objc-global-variable-declaration.mm @@ -35,6 +35,10 @@ extern NSString* const GTLServiceErrorDomain; +class MyTest { + static int not_objc_style; +}; + enum GTLServiceError { GTLServiceErrorQueryResultMissing = -3000, GTLServiceErrorWaitTimedOut = -3001, Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp =================================================================== --- clang-tidy/google/GlobalVariableDeclarationCheck.cpp +++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp @@ -79,12 +79,18 @@ void GlobalVariableDeclarationCheck::check( const MatchFinder::MatchResult &Result) { if (const auto *Decl = Result.Nodes.getNodeAs<VarDecl>("global_var")) { + if (Decl->isStaticDataMember()) { + return; + } diag(Decl->getLocation(), "non-const global variable '%0' must have a name which starts with " "'g[A-Z]'") << Decl->getName() << generateFixItHint(Decl, false); } if (const auto *Decl = Result.Nodes.getNodeAs<VarDecl>("global_const")) { + if (Decl->isStaticDataMember()) { + return; + } diag(Decl->getLocation(), "const global variable '%0' must have a name which starts with " "an appropriate prefix")
Index: test/clang-tidy/google-objc-global-variable-declaration.mm =================================================================== --- test/clang-tidy/google-objc-global-variable-declaration.mm +++ test/clang-tidy/google-objc-global-variable-declaration.mm @@ -35,6 +35,10 @@ extern NSString* const GTLServiceErrorDomain; +class MyTest { + static int not_objc_style; +}; + enum GTLServiceError { GTLServiceErrorQueryResultMissing = -3000, GTLServiceErrorWaitTimedOut = -3001, Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp =================================================================== --- clang-tidy/google/GlobalVariableDeclarationCheck.cpp +++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp @@ -79,12 +79,18 @@ void GlobalVariableDeclarationCheck::check( const MatchFinder::MatchResult &Result) { if (const auto *Decl = Result.Nodes.getNodeAs<VarDecl>("global_var")) { + if (Decl->isStaticDataMember()) { + return; + } diag(Decl->getLocation(), "non-const global variable '%0' must have a name which starts with " "'g[A-Z]'") << Decl->getName() << generateFixItHint(Decl, false); } if (const auto *Decl = Result.Nodes.getNodeAs<VarDecl>("global_const")) { + if (Decl->isStaticDataMember()) { + return; + } diag(Decl->getLocation(), "const global variable '%0' must have a name which starts with " "an appropriate prefix")
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits