[PATCH] D125209: [clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 12 01:19:48 PDT 2022


whisperity added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp:87-88
     const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
-    PP->addPPCallbacks(
-        ::std::make_unique<IncludeModernizePPCallbacks>(*this, getLangOpts()));
+  PP->addPPCallbacks(::std::make_unique<detail::IncludeModernizePPCallbacks>(
+      *this, getLangOpts(), PP->getSourceManager()));
+}
----------------
steakhal wrote:
> whisperity wrote:
> > (🔮: Same here. Is this state that might keep a dangling reference if multiple TUs are consumed in sequence?)
> How can I acquire the right `SourceManager` if not like this?
> I haven't found any alternative.
> What do you suggest?
Is the `PP` a different variable when a new translation unit is consumed by the same check instance? If so, then there is no problem. A simple debug print `llvm::errs() << PP << '\n';`, recompile, re-run with `clang-tidy a.cpp b.cpp` should show how the infrastructure behaves. I do not know the exact behaviour of the preprocessor layer.


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