[clang-tools-extra] r260108 - [clang-tidy] Some improvements in 'misc-definitions-in-headers' check.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 8 08:05:39 PST 2016
Author: hokein
Date: Mon Feb 8 10:05:39 2016
New Revision: 260108
URL: http://llvm.org/viewvc/llvm-project?rev=260108&view=rev
Log:
[clang-tidy] Some improvements in 'misc-definitions-in-headers' check.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D16979
Modified:
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=260108&r1=260107&r2=260108&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp Mon Feb 8 10:05:39 2016
@@ -51,6 +51,8 @@ void DefinitionsInHeadersCheck::storeOpt
}
void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
+ if (!getLangOpts().CPlusPlus)
+ return;
if (UseHeaderFileExtension) {
Finder->addMatcher(
namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())),
@@ -78,6 +80,8 @@ void DefinitionsInHeadersCheck::check(co
// satisfy the following requirements.
const auto *ND = Result.Nodes.getNodeAs<NamedDecl>("name-decl");
assert(ND);
+ if (ND->isInvalidDecl())
+ return;
// Internal linkage variable definitions are ignored for now:
// const int a = 1;
More information about the cfe-commits
mailing list