[clang-tidy] Ignore forward declarations without definitions in the same translation unit in readability-identifier-naming

Summary: This change ensures that forward declarations of classes are not considered for identifier naming checks within a translation unit.

Reviewers: alexfh, aaron.ballman

Subscribers: mgehre

Differential Revision: https://reviews.llvm.org/D22571

llvm-svn: 285907
This commit is contained in:
Jonathan Coe 2016-11-03 13:52:09 +00:00
parent dd6abaad75
commit 89f12c0c50
2 changed files with 8 additions and 0 deletions

View File

@ -395,6 +395,9 @@ static StyleKind findStyleKind(
if (Decl->isAnonymousStructOrUnion())
return SK_Invalid;
if (!Decl->getCanonicalDecl()->isThisDeclarationADefinition())
return SK_Invalid;
if (Decl->hasDefinition() && Decl->isAbstract() &&
NamingStyles[SK_AbstractClass].isSet())
return SK_AbstractClass;

View File

@ -190,6 +190,11 @@ public:
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for class member 'ClassMember_2'
// CHECK-FIXES: {{^}} static int ClassMember2;{{$}}
};
class my_class;
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'my_class'
// CHECK-FIXES: {{^}}class CMyClass;{{$}}
class my_forward_declared_class; // No warning should be triggered.
const int my_class::classConstant = 4;
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for class constant 'classConstant'