[PATCH] D154478: [analyzer][NFC] Use unique_ptrs for PathDiagnosticConsumers

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 00:34:06 PDT 2023


steakhal created this revision.
steakhal added reviewers: xazax.hun, NoQ.
Herald added subscribers: PiotrZSL, carlosgalvezp, manas, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware.
Herald added a reviewer: Szelethus.
Herald added a reviewer: njames93.
Herald added a project: All.
steakhal requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Due to lazy initialization on AnalysisConsumer, that needs to smuggle analysis consumers from its ctor to the initialize function; hence we need the `TempPathConsumers`.
The consumers are usually populated by `DigestAnalyzerOptions` from the ctor.

At least now, we only have a single place storing pointers to the consumers - unlike in the past where you could call the virtual `addDiagnosticConsumer` on `AnalysisConsumer` and end up pushing to the "stale" vector of consumers without observing any effects - except for leaking memory.
Now, it's gone. And pushing back there would push back to the AnalysisManager (who owns the consumers) - and behave as expected.

Note that the code quality begs for refactoring how consumers passed across, but I'm not intending to fix that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154478

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
  clang/unittests/StaticAnalyzer/CheckerRegistration.h
  clang/unittests/StaticAnalyzer/Reusables.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154478.537237.patch
Type: text/x-patch
Size: 21200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230705/62d7268d/attachment-0001.bin>


More information about the cfe-commits mailing list