Skip to content

Conversation

@vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Jan 23, 2025

ClangTool change to fix memory leak.
FixedCompilationDatabase changed just to makes it simpler.

Created using spr 1.3.4
@vitalybuka vitalybuka changed the title [modularize] Create objects on the stack [NFC][modularize] Create objects on the stack Jan 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 23, 2025

@llvm/pr-subscribers-clang-tools-extra

Author: Vitaly Buka (vitalybuka)

Changes

ClangTool was leaking.
FixedCompilationDatabase just makes it simpler.


Full diff: https://github.com/llvm/llvm-project/pull/124034.diff

1 Files Affected:

  • (modified) clang-tools-extra/modularize/CoverageChecker.cpp (+4-4)
diff --git a/clang-tools-extra/modularize/CoverageChecker.cpp b/clang-tools-extra/modularize/CoverageChecker.cpp
index b536ee00497c03..fe6711398ab7dc 100644
--- a/clang-tools-extra/modularize/CoverageChecker.cpp
+++ b/clang-tools-extra/modularize/CoverageChecker.cpp
@@ -278,15 +278,15 @@ CoverageChecker::collectUmbrellaHeaderHeaders(StringRef UmbrellaHeaderName) {
     sys::fs::current_path(PathBuf);
 
   // Create the compilation database.
-  std::unique_ptr<CompilationDatabase> Compilations;
-  Compilations.reset(new FixedCompilationDatabase(Twine(PathBuf), CommandLine));
+  FixedCompilationDatabase Compilations(Twine(PathBuf), CommandLine);
 
   std::vector<std::string> HeaderPath;
   HeaderPath.push_back(std::string(UmbrellaHeaderName));
 
   // Create the tool and run the compilation.
-  ClangTool Tool(*Compilations, HeaderPath);
-  int HadErrors = Tool.run(new CoverageCheckerFrontendActionFactory(*this));
+  ClangTool Tool(Compilations, HeaderPath);
+  CoverageCheckerFrontendActionFactory ActionFactory(*this);
+  int HadErrors = Tool.run(&ActionFactory);
 
   // If we had errors, exit early.
   return !HadErrors;

@vitalybuka vitalybuka changed the title [NFC][modularize] Create objects on the stack [NFC][modules] Create objects on the stack Jan 23, 2025
@vitalybuka vitalybuka requested a review from kstoimenov January 23, 2025 00:31
Created using spr 1.3.4
@vitalybuka vitalybuka merged commit 6a97897 into main Jan 23, 2025
8 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/modularize-create-objects-on-the-stack branch January 23, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants