Skip to content

[NFC][modules] Create objects on the stack #124034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

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.

3 participants