[clang-tools-extra] r260108 - [clang-tidy] Some improvements in 'misc-definitions-in-headers' check.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 8 08:15:21 PST 2016
On Mon, Feb 8, 2016 at 11:05 AM, Haojian Wu via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> 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;
C has the same concept, under different wording. Are there plans to
make this check work in C mode as well?
6.2.7p2:
All declarations that refer to the same object or function shall have
compatible type; otherwise, the behavior is undefined.
It seems like this check may be useful for C too with some pretty
simple modifications.
~Aaron
> 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;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list