Author: Fangrui Song Date: 2026-11-15T21:22:44-08:00 New Revision: 6b1f7ba6dd9ee47d2b2360447d1ab1aec16a3035
URL: https://github.com/llvm/llvm-project/commit/6b1f7ba6dd9ee47d2b2360447d1ab1aec16a3035 DIFF: https://github.com/llvm/llvm-project/commit/6b1f7ba6dd9ee47d2b2360447d1ab1aec16a3035.diff LOG: [clang-repl] Fix leak when -mllvm parsing fails after #242861 (#242968) Fix the InterpreterTest.BadLLVMArgs LeakSanitizer failure. Added: Modified: clang/lib/Interpreter/Interpreter.cpp Removed: ################################################################################ diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index dcb7824d270a1..429f9ee1cb345 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -232,8 +232,15 @@ static llvm::Error ExecuteIncrementalAction(CompilerInstance &CI, // LLVMContext. std::string Msg; llvm::raw_string_ostream OS(Msg); - if (!CI.parseLLVMArgs(&OS)) + if (!CI.parseLLVMArgs(&OS)) { + // Without a preprocessor, the SourceManager never adopts the buffers. + PreprocessorOptions &PPOpts = CI.getPreprocessorOpts(); + if (!PPOpts.RetainRemappedFileBuffers) + for (auto &RB : PPOpts.RemappedFileBuffers) + delete RB.second; + PPOpts.clearRemappedFiles(); return llvm::createStringError(llvm::StringRef(Msg).rtrim()); + } if (!CI.ExecuteAction(Act) || CI.getDiagnostics().hasErrorOccurred()) { return llvm::createStringError(llvm::errc::not_supported, "Failed to execute incremental action"); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
