[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 02:02:19 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271991: [clang-tidy] Ignore the deleted function in misc-definitions-in-headers. (authored by hokein).
Changed prior to commit:
http://reviews.llvm.org/D21059?vs=59843&id=59845#toc
Repository:
rL LLVM
http://reviews.llvm.org/D21059
Files:
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
Index: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
@@ -103,6 +103,8 @@
// 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;
Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/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.59845.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160607/29cef0e4/attachment-0001.bin>
More information about the cfe-commits
mailing list