Index: clang-tidy/misc/DefinitionsInHeadersCheck.cpp =================================================================== --- clang-tidy/misc/DefinitionsInHeadersCheck.cpp +++ clang-tidy/misc/DefinitionsInHeadersCheck.cpp @@ -51,6 +51,8 @@ } void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) { + if (!getLangOpts().CPlusPlus) + return; if (UseHeaderFileExtension) { Finder->addMatcher( namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), @@ -78,6 +80,8 @@ // satisfy the following requirements. const auto *ND = Result.Nodes.getNodeAs("name-decl"); assert(ND); + if (ND->isInvalidDecl()) + return; // Internal linkage variable definitions are ignored for now: // const int a = 1;