diff options
author | Balazs Benics <benicsbalazs@gmail.com> | 2025-02-24 11:34:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-24 11:34:36 +0100 |
commit | 3dc159431be7a8c5f1a26a8bd57794f1c7008969 (patch) | |
tree | 03d0629054964bafb4412a5c8fa01caa89bf9c00 /clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | |
parent | e7ad07ffb846a9812d9567b8d4b680045dce5b28 (diff) | |
download | llvm-3dc159431be7a8c5f1a26a8bd57794f1c7008969.zip llvm-3dc159431be7a8c5f1a26a8bd57794f1c7008969.tar.gz llvm-3dc159431be7a8c5f1a26a8bd57794f1c7008969.tar.bz2 |
[analyzer] Clean up slightly the messed up ownership model of the analyzer (#128368)
Well, yes. It's not pretty.
At least after this we would have a bit more unique pointers than
before.
This is for fixing the memory leak diagnosed by:
https://lab.llvm.org/buildbot/#/builders/24/builds/5580
And that caused the revert of #127409.
After these uptrs that patch can re-land finally.
Diffstat (limited to 'clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 189d7d6..8a4bb35 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -90,7 +90,7 @@ public: const std::string OutDir; AnalyzerOptions &Opts; ArrayRef<std::string> Plugins; - CodeInjector *Injector; + std::unique_ptr<CodeInjector> Injector; cross_tu::CrossTranslationUnitContext CTU; /// Stores the declarations from the local translation unit. @@ -123,10 +123,10 @@ public: AnalysisConsumer(CompilerInstance &CI, const std::string &outdir, AnalyzerOptions &opts, ArrayRef<std::string> plugins, - CodeInjector *injector) + std::unique_ptr<CodeInjector> injector) : RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr), - PP(CI.getPreprocessor()), OutDir(outdir), Opts(opts), - Plugins(plugins), Injector(injector), CTU(CI), + PP(CI.getPreprocessor()), OutDir(outdir), Opts(opts), Plugins(plugins), + Injector(std::move(injector)), CTU(CI), MacroExpansions(CI.getLangOpts()) { DigestAnalyzerOptions(); if (Opts.AnalyzerDisplayProgress || Opts.PrintStats || @@ -229,9 +229,9 @@ public: checkerMgr = std::make_unique<CheckerManager>(*Ctx, Opts, PP, Plugins, CheckerRegistrationFns); - Mgr = std::make_unique<AnalysisManager>(*Ctx, PP, PathConsumers, - CreateStoreMgr, CreateConstraintMgr, - checkerMgr.get(), Opts, Injector); + Mgr = std::make_unique<AnalysisManager>( + *Ctx, PP, std::move(PathConsumers), CreateStoreMgr, CreateConstraintMgr, + checkerMgr.get(), Opts, std::move(Injector)); } /// Store the top level decls in the set to be processed later on. @@ -342,8 +342,9 @@ public: return true; } - void AddDiagnosticConsumer(PathDiagnosticConsumer *Consumer) override { - PathConsumers.push_back(Consumer); + void AddDiagnosticConsumer( + std::unique_ptr<PathDiagnosticConsumer> Consumer) override { + PathConsumers.push_back(std::move(Consumer)); } void AddCheckerRegistrationFn(std::function<void(CheckerRegistry&)> Fn) override { @@ -794,5 +795,5 @@ ento::CreateAnalysisConsumer(CompilerInstance &CI) { return std::make_unique<AnalysisConsumer>( CI, CI.getFrontendOpts().OutputFile, analyzerOpts, CI.getFrontendOpts().Plugins, - hasModelPath ? new ModelInjector(CI) : nullptr); + hasModelPath ? std::make_unique<ModelInjector>(CI) : nullptr); } |