https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/242968
Fix the InterpreterTest.BadLLVMArgs LeakSanitizer failure. >From e0762153d1ec96b3cf3ab2900d8ad15b07933ce3 Mon Sep 17 00:00:00 2001 From: Fangrui Song <[email protected]> Date: Sun, 15 Nov 2026 21:16:05 -0800 Subject: [PATCH] [clang-repl] Fix leak when -mllvm parsing fails after #242861 Fix the InterpreterTest.BadLLVMArgs LeakSanitizer failure. --- clang/lib/Interpreter/Interpreter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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
