steakhal marked 6 inline comments as done. steakhal 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())); +} ---------------- whisperity wrote: > 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. Okay, I've checked this. The lifetimes checks out. Thanks! ``` $ ./build/debug/bin/clang-tidy a.cpp b.cpp -checks="-*,modernize-deprecated-headers" DeprecatedHeadersCheck::registerPPCallbacks() acquires SM 0x27eb9e0 ctor IncludeModernizePPCallbacks acquires SM 0x27eb9e0 IncludeModernizePPCallbacks::InclusionDirective inserts to IncludesToBeProcessed using SM 0x27eb9e0 IncludeModernizePPCallbacks::InclusionDirective inserts to IncludesToBeProcessed using SM 0x27eb9e0 DeprecatedHeadersCheck::check() emits IncludesToBeProcessed using SM 0x27eb9e0 onEndOfTranslationUnit cleares IncludesToBeProcessed 1 warning generated. dtor IncludeModernizePPCallbacks releases SM 0x27eb9e0 DeprecatedHeadersCheck::registerPPCallbacks() acquires SM 0x27eb9e0 ctor IncludeModernizePPCallbacks acquires SM 0x27eb9e0 IncludeModernizePPCallbacks::InclusionDirective inserts to IncludesToBeProcessed using SM 0x27eb9e0 IncludeModernizePPCallbacks::InclusionDirective inserts to IncludesToBeProcessed using SM 0x27eb9e0 DeprecatedHeadersCheck::check() emits IncludesToBeProcessed using SM 0x27eb9e0 onEndOfTranslationUnit cleares IncludesToBeProcessed 2 warnings generated. dtor IncludeModernizePPCallbacks releases SM 0x27eb9e0 a.cpp:2:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers] #include <assert.h> ^~~~~~~~~~ <cassert> b.cpp:2:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers] #include <assert.h> ^~~~~~~~~~ <cassert> ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125209/new/ https://reviews.llvm.org/D125209 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits