[PATCH] D21059: [clang-tidy] Ignore the deleted function in misc-definitions-in-headers.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 7 01:22:23 PDT 2016
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.
http://reviews.llvm.org/D21059
Files:
clang-tidy/misc/DefinitionsInHeadersCheck.cpp
test/clang-tidy/misc-definitions-in-headers-cxx11.hpp
Index: test/clang-tidy/misc-definitions-in-headers-cxx11.hpp
===================================================================
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers-cxx11.hpp
@@ -0,0 +1,7 @@
+// RUN: clang-tidy %s -checks="-*,misc-definitions-in-headers" -- -extra-arg="-std=c++11" | FileCheck -allow-empty %s
+
+// Note: This test verifies that the checker does not emit any warning for the
+// function being marked delete.
+
+int f() = delete;
+// CHECK-NOT: [misc-definitions-in-headers]
Index: clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===================================================================
--- clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -53,15 +53,17 @@
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"),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21059.59841.patch
Type: text/x-patch
Size: 1796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160607/c95af9cb/attachment.bin>
More information about the cfe-commits
mailing list