Skip to content

Commit

Permalink
[clang-tidy] Ignore the deleted function in misc-definitions-in-headers.
Browse files Browse the repository at this point in the history
Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D21059

llvm-svn: 271991
  • Loading branch information
hokein committed Jun 7, 2016
1 parent 91e3ac8 commit ba992cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
Expand Up @@ -53,15 +53,17 @@ void DefinitionsInHeadersCheck::storeOptions(
void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
auto DefinitionMatcher =
anyOf(functionDecl(isDefinition(), unless(isDeleted())),
varDecl(isDefinition()));
if (UseHeaderFileExtension) {
Finder->addMatcher(
namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())),
usesHeaderFileExtension(HeaderFileExtensions))
.bind("name-decl"),
this);
Finder->addMatcher(namedDecl(DefinitionMatcher,
usesHeaderFileExtension(HeaderFileExtensions))
.bind("name-decl"),
this);
} else {
Finder->addMatcher(
namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())),
namedDecl(DefinitionMatcher,
anyOf(usesHeaderFileExtension(HeaderFileExtensions),
unless(isExpansionInMainFile())))
.bind("name-decl"),
Expand Down
Expand Up @@ -103,6 +103,8 @@ namespace {
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f7' defined in a header file;
}

int f8() = delete; // OK: the function being marked delete is not callable.

int a = 1;
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'a' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
CA a1;
Expand Down

0 comments on commit ba992cf

Please sign in to comment.