[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream
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()); + + // 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 ) { - OwnedVerboseOutputStream.release(); + OwnedVerboseOutputStream.reset(); VerboseOutputStream = } 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()); + + // 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 ) { - OwnedVerboseOutputStream.release(); + OwnedVerboseOutputStream.reset(); VerboseOutputStream = } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream
erik.pilkington accepted this revision. erik.pilkington added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93249/new/ https://reviews.llvm.org/D93249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream
dexonsmith added a comment. Ping! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93249/new/ https://reviews.llvm.org/D93249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D93249: Frontend: Fix memory leak in CompilerInstance::setVerboseOutputStream
dexonsmith created this revision. dexonsmith added a reviewer: erik.pilkington. Herald added a subscriber: ributzka. dexonsmith requested review of this revision. Herald added a project: clang. Repository: rG LLVM Github Monorepo 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()); + + // 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 ) { - OwnedVerboseOutputStream.release(); + OwnedVerboseOutputStream.reset(); VerboseOutputStream = } 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()); + + // 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 ) { - OwnedVerboseOutputStream.release(); + OwnedVerboseOutputStream.reset(); VerboseOutputStream = } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits