[PATCH] D125209: [clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 02:23:37 PDT 2022
steakhal marked an inline comment as done.
steakhal added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp:90
+ // to the `ASTContext`.
+ Finder->addMatcher(ast_matchers::translationUnitDecl().bind("TU"), this);
+}
----------------
LegalizeAdulthood wrote:
> In modernize-macro-to-enum I had to similarly discard macros defined inside a top-level decl. I did `decl(hasParent(translationUnitDecl()))` to match the top-level decls. Would that simplify your check as well?
The problem is that `extern "C" {...}` blocks might be within some namespace declarations.
https://godbolt.org/z/vr5jYx5az
================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp:123
-IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck &Check,
- LangOptions LangOpts)
+detail::IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(
+ DeprecatedHeadersCheck &Check, LangOptions LangOpts)
----------------
LegalizeAdulthood wrote:
> IMO it's poor style to define entities that are declared within a namespace outside the namespace within which they were declared.
>
> Is there some reason this isn't defined with the rest of the methods on the callback class?
I eradicated the use of `detail` namespace.
It indeed looks better.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125209/new/
https://reviews.llvm.org/D125209
More information about the cfe-commits
mailing list