diff options
author | Krasimir Georgiev <krasimir@google.com> | 2024-02-26 16:58:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 16:58:39 +0100 |
commit | b2ebd8b89777a1c5ba6acc4ad9f195ea2ad5f0de (patch) | |
tree | fed529e9edfa62e3ab1eaf688f47408e10f2fe3a | |
parent | 2730a5c68c6986bc8f01d047f8f31bcfd9316333 (diff) | |
download | llvm-b2ebd8b89777a1c5ba6acc4ad9f195ea2ad5f0de.zip llvm-b2ebd8b89777a1c5ba6acc4ad9f195ea2ad5f0de.tar.gz llvm-b2ebd8b89777a1c5ba6acc4ad9f195ea2ad5f0de.tar.bz2 |
clang serialization unittests: fix some leaks (#82773)
No functional changes intended.
Fixes some leaks found by running under asan with `--gtest_repeat=2`.
-rw-r--r-- | clang/unittests/Serialization/ModuleCacheTest.cpp | 19 | ||||
-rw-r--r-- | clang/unittests/Serialization/VarDeclConstantInitTest.cpp | 1 |
2 files changed, 16 insertions, 4 deletions
diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp b/clang/unittests/Serialization/ModuleCacheTest.cpp index c3e347f..a7ca985 100644 --- a/clang/unittests/Serialization/ModuleCacheTest.cpp +++ b/clang/unittests/Serialization/ModuleCacheTest.cpp @@ -88,6 +88,17 @@ public: } )cpp"); } + + std::unique_ptr<CompilerInvocation> + createInvocationAndEnableFree(ArrayRef<const char *> Args, + CreateInvocationOptions Opts) { + std::unique_ptr<CompilerInvocation> Invocation = + createInvocation(Args, Opts); + if (Invocation) + Invocation->getFrontendOpts().DisableFree = false; + + return Invocation; + } }; TEST_F(ModuleCacheTest, CachedModuleNewPath) { @@ -106,7 +117,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) { MCPArg.c_str(), "-working-directory", TestDir.c_str(), "test.m"}; std::shared_ptr<CompilerInvocation> Invocation = - createInvocation(Args, CIOpts); + createInvocationAndEnableFree(Args, CIOpts); ASSERT_TRUE(Invocation); CompilerInstance Instance; Instance.setDiagnostics(Diags.get()); @@ -129,7 +140,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) { "-Fframeworks", MCPArg.c_str(), "-working-directory", TestDir.c_str(), "test.m"}; std::shared_ptr<CompilerInvocation> Invocation2 = - createInvocation(Args2, CIOpts); + createInvocationAndEnableFree(Args2, CIOpts); ASSERT_TRUE(Invocation2); CompilerInstance Instance2(Instance.getPCHContainerOperations(), &Instance.getModuleCache()); @@ -156,7 +167,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) { MCPArg.c_str(), "-working-directory", TestDir.c_str(), "test.m"}; std::shared_ptr<CompilerInvocation> Invocation = - createInvocation(Args, CIOpts); + createInvocationAndEnableFree(Args, CIOpts); ASSERT_TRUE(Invocation); CompilerInstance Instance; Instance.setDiagnostics(Diags.get()); @@ -173,7 +184,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) { TestDir.c_str(), "-Xclang", "-fallow-pcm-with-compiler-errors", "test.m"}; std::shared_ptr<CompilerInvocation> Invocation2 = - createInvocation(Args2, CIOpts); + createInvocationAndEnableFree(Args2, CIOpts); ASSERT_TRUE(Invocation2); CompilerInstance Instance2(Instance.getPCHContainerOperations(), &Instance.getModuleCache()); diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp index 86ae929..7efa1c1 100644 --- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp +++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp @@ -103,6 +103,7 @@ export namespace Fibonacci std::shared_ptr<CompilerInvocation> Invocation = createInvocation(Args, CIOpts); ASSERT_TRUE(Invocation); + Invocation->getFrontendOpts().DisableFree = false; CompilerInstance Instance; Instance.setDiagnostics(Diags.get()); |