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"), Index: test/clang-tidy/misc-definitions-in-headers.hpp =================================================================== --- test/clang-tidy/misc-definitions-in-headers.hpp +++ 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;