[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 26 14:57:57 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8afabff6b11c: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream (authored by dexonsmith).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93249/new/
https://reviews.llvm.org/D93249
Files:
clang/lib/Frontend/CompilerInstance.cpp
clang/unittests/Frontend/OutputStreamTest.cpp
Index: clang/unittests/Frontend/OutputStreamTest.cpp
===================================================================
--- clang/unittests/Frontend/OutputStreamTest.cpp
+++ clang/unittests/Frontend/OutputStreamTest.cpp
@@ -101,4 +101,12 @@
EXPECT_TRUE(StringRef(VerboseBuffer.data()).contains("errors generated"));
}
+TEST(FrontendOutputTests, TestVerboseOutputStreamOwnedNotLeaked) {
+ CompilerInstance Compiler;
+ Compiler.setVerboseOutputStream(std::make_unique<raw_null_ostream>());
+
+ // Trust leak sanitizer bots to catch a leak here.
+ Compiler.setVerboseOutputStream(llvm::nulls());
+}
+
} // anonymous namespace
Index: clang/lib/Frontend/CompilerInstance.cpp
===================================================================
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -85,7 +85,7 @@
}
void CompilerInstance::setVerboseOutputStream(raw_ostream &Value) {
- OwnedVerboseOutputStream.release();
+ OwnedVerboseOutputStream.reset();
VerboseOutputStream = &Value;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93249.319415.patch
Type: text/x-patch
Size: 1044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210126/d4ebf9bd/attachment.bin>
More information about the cfe-commits
mailing list