[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-26 Thread Krasimir Georgiev via cfe-commits

https://github.com/krasimirgg closed 
https://github.com/llvm/llvm-project/pull/82773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-26 Thread Krasimir Georgiev via cfe-commits

https://github.com/krasimirgg updated 
https://github.com/llvm/llvm-project/pull/82773

>From 43f8b15fa3e5465f1939d0359ff5dcfc83ed1717 Mon Sep 17 00:00:00 2001
From: Krasimir Georgiev 
Date: Fri, 23 Feb 2024 15:11:51 +
Subject: [PATCH 1/2] clang serialization unittests: fix some leaks

No functional changes intended.

Fixes some leaks found by running under asan with --gtest_repeat=2.
---
 .../Serialization/ModuleCacheTest.cpp  | 18 ++
 .../Serialization/VarDeclConstantInitTest.cpp  |  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index c3e347ffec660c..76aeee60f5a435 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,6 +88,16 @@ class ModuleCacheTest : public ::testing::Test {
 }
 )cpp");
   }
+ 
+  std::unique_ptr createInvocationAndEnableFree(
+  ArrayRef Args, CreateInvocationOptions Opts) {
+std::unique_ptr Invocation =
+createInvocation(Args, Opts);
+if (Invocation)
+  Invocation->getFrontendOpts().DisableFree = false;
+
+return Invocation;
+  }
 };
 
 TEST_F(ModuleCacheTest, CachedModuleNewPath) {
@@ -106,7 +116,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -129,7 +139,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
  "-Fframeworks",  MCPArg.c_str(), "-working-directory",
  TestDir.c_str(), "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
@@ -156,7 +166,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -173,7 +183,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
   TestDir.c_str(), "-Xclang",  "-fallow-pcm-with-compiler-errors",
   "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp 
b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
index 86ae929e7f17e4..7efa1c1d64a964 100644
--- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
+++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
@@ -103,6 +103,7 @@ export namespace Fibonacci
   std::shared_ptr Invocation =
   createInvocation(Args, CIOpts);
   ASSERT_TRUE(Invocation);
+  Invocation->getFrontendOpts().DisableFree = false;
 
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());

>From 4ab1858f489d9222ce114bf8a351ac1e8012ec00 Mon Sep 17 00:00:00 2001
From: Krasimir Georgiev 
Date: Fri, 23 Feb 2024 15:20:32 +
Subject: [PATCH 2/2] reformat

---
 clang/unittests/Serialization/ModuleCacheTest.cpp | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index 76aeee60f5a435..a7ca98549b4125 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,9 +88,10 @@ class ModuleCacheTest : public ::testing::Test {
 }
 )cpp");
   }
- 
-  std::unique_ptr createInvocationAndEnableFree(
-  ArrayRef Args, CreateInvocationOptions Opts) {
+
+  std::unique_ptr
+  createInvocationAndEnableFree(ArrayRef Args,
+CreateInvocationOptions Opts) {
 std::unique_ptr Invocation =
 createInvocation(Args, Opts);
 if (Invocation)

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-25 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 approved this pull request.


https://github.com/llvm/llvm-project/pull/82773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-23 Thread Benjamin Kramer via cfe-commits

https://github.com/d0k approved this pull request.


https://github.com/llvm/llvm-project/pull/82773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-23 Thread Krasimir Georgiev via cfe-commits

https://github.com/krasimirgg updated 
https://github.com/llvm/llvm-project/pull/82773

>From 43f8b15fa3e5465f1939d0359ff5dcfc83ed1717 Mon Sep 17 00:00:00 2001
From: Krasimir Georgiev 
Date: Fri, 23 Feb 2024 15:11:51 +
Subject: [PATCH 1/2] clang serialization unittests: fix some leaks

No functional changes intended.

Fixes some leaks found by running under asan with --gtest_repeat=2.
---
 .../Serialization/ModuleCacheTest.cpp  | 18 ++
 .../Serialization/VarDeclConstantInitTest.cpp  |  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index c3e347ffec660c..76aeee60f5a435 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,6 +88,16 @@ class ModuleCacheTest : public ::testing::Test {
 }
 )cpp");
   }
+ 
+  std::unique_ptr createInvocationAndEnableFree(
+  ArrayRef Args, CreateInvocationOptions Opts) {
+std::unique_ptr Invocation =
+createInvocation(Args, Opts);
+if (Invocation)
+  Invocation->getFrontendOpts().DisableFree = false;
+
+return Invocation;
+  }
 };
 
 TEST_F(ModuleCacheTest, CachedModuleNewPath) {
@@ -106,7 +116,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -129,7 +139,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
  "-Fframeworks",  MCPArg.c_str(), "-working-directory",
  TestDir.c_str(), "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
@@ -156,7 +166,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -173,7 +183,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
   TestDir.c_str(), "-Xclang",  "-fallow-pcm-with-compiler-errors",
   "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp 
b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
index 86ae929e7f17e4..7efa1c1d64a964 100644
--- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
+++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
@@ -103,6 +103,7 @@ export namespace Fibonacci
   std::shared_ptr Invocation =
   createInvocation(Args, CIOpts);
   ASSERT_TRUE(Invocation);
+  Invocation->getFrontendOpts().DisableFree = false;
 
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());

>From 4ab1858f489d9222ce114bf8a351ac1e8012ec00 Mon Sep 17 00:00:00 2001
From: Krasimir Georgiev 
Date: Fri, 23 Feb 2024 15:20:32 +
Subject: [PATCH 2/2] reformat

---
 clang/unittests/Serialization/ModuleCacheTest.cpp | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index 76aeee60f5a435..a7ca98549b4125 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,9 +88,10 @@ class ModuleCacheTest : public ::testing::Test {
 }
 )cpp");
   }
- 
-  std::unique_ptr createInvocationAndEnableFree(
-  ArrayRef Args, CreateInvocationOptions Opts) {
+
+  std::unique_ptr
+  createInvocationAndEnableFree(ArrayRef Args,
+CreateInvocationOptions Opts) {
 std::unique_ptr Invocation =
 createInvocation(Args, Opts);
 if (Invocation)

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-23 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 3b232f066d40a3e91ac27e421a3baeaca0cd59ec 
43f8b15fa3e5465f1939d0359ff5dcfc83ed1717 -- 
clang/unittests/Serialization/ModuleCacheTest.cpp 
clang/unittests/Serialization/VarDeclConstantInitTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index 76aeee60f5..a7ca98549b 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,9 +88,10 @@ public:
 }
 )cpp");
   }
- 
-  std::unique_ptr createInvocationAndEnableFree(
-  ArrayRef Args, CreateInvocationOptions Opts) {
+
+  std::unique_ptr
+  createInvocationAndEnableFree(ArrayRef Args,
+CreateInvocationOptions Opts) {
 std::unique_ptr Invocation =
 createInvocation(Args, Opts);
 if (Invocation)

``




https://github.com/llvm/llvm-project/pull/82773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krasimir Georgiev (krasimirgg)


Changes

No functional changes intended.

Fixes some leaks found by running under asan with `--gtest_repeat=2`.

---
Full diff: https://github.com/llvm/llvm-project/pull/82773.diff


2 Files Affected:

- (modified) clang/unittests/Serialization/ModuleCacheTest.cpp (+14-4) 
- (modified) clang/unittests/Serialization/VarDeclConstantInitTest.cpp (+1) 


``diff
diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index c3e347ffec660c..76aeee60f5a435 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,6 +88,16 @@ class ModuleCacheTest : public ::testing::Test {
 }
 )cpp");
   }
+ 
+  std::unique_ptr createInvocationAndEnableFree(
+  ArrayRef Args, CreateInvocationOptions Opts) {
+std::unique_ptr Invocation =
+createInvocation(Args, Opts);
+if (Invocation)
+  Invocation->getFrontendOpts().DisableFree = false;
+
+return Invocation;
+  }
 };
 
 TEST_F(ModuleCacheTest, CachedModuleNewPath) {
@@ -106,7 +116,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -129,7 +139,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
  "-Fframeworks",  MCPArg.c_str(), "-working-directory",
  TestDir.c_str(), "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
@@ -156,7 +166,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -173,7 +183,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
   TestDir.c_str(), "-Xclang",  "-fallow-pcm-with-compiler-errors",
   "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp 
b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
index 86ae929e7f17e4..7efa1c1d64a964 100644
--- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
+++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
@@ -103,6 +103,7 @@ export namespace Fibonacci
   std::shared_ptr Invocation =
   createInvocation(Args, CIOpts);
   ASSERT_TRUE(Invocation);
+  Invocation->getFrontendOpts().DisableFree = false;
 
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());

``




https://github.com/llvm/llvm-project/pull/82773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Krasimir Georgiev (krasimirgg)


Changes

No functional changes intended.

Fixes some leaks found by running under asan with `--gtest_repeat=2`.

---
Full diff: https://github.com/llvm/llvm-project/pull/82773.diff


2 Files Affected:

- (modified) clang/unittests/Serialization/ModuleCacheTest.cpp (+14-4) 
- (modified) clang/unittests/Serialization/VarDeclConstantInitTest.cpp (+1) 


``diff
diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index c3e347ffec660c..76aeee60f5a435 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,6 +88,16 @@ class ModuleCacheTest : public ::testing::Test {
 }
 )cpp");
   }
+ 
+  std::unique_ptr createInvocationAndEnableFree(
+  ArrayRef Args, CreateInvocationOptions Opts) {
+std::unique_ptr Invocation =
+createInvocation(Args, Opts);
+if (Invocation)
+  Invocation->getFrontendOpts().DisableFree = false;
+
+return Invocation;
+  }
 };
 
 TEST_F(ModuleCacheTest, CachedModuleNewPath) {
@@ -106,7 +116,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -129,7 +139,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
  "-Fframeworks",  MCPArg.c_str(), "-working-directory",
  TestDir.c_str(), "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
@@ -156,7 +166,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -173,7 +183,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
   TestDir.c_str(), "-Xclang",  "-fallow-pcm-with-compiler-errors",
   "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp 
b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
index 86ae929e7f17e4..7efa1c1d64a964 100644
--- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
+++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
@@ -103,6 +103,7 @@ export namespace Fibonacci
   std::shared_ptr Invocation =
   createInvocation(Args, CIOpts);
   ASSERT_TRUE(Invocation);
+  Invocation->getFrontendOpts().DisableFree = false;
 
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());

``




https://github.com/llvm/llvm-project/pull/82773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-23 Thread Krasimir Georgiev via cfe-commits

https://github.com/krasimirgg ready_for_review 
https://github.com/llvm/llvm-project/pull/82773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang serialization unittests: fix some leaks (PR #82773)

2024-02-23 Thread Krasimir Georgiev via cfe-commits

https://github.com/krasimirgg created 
https://github.com/llvm/llvm-project/pull/82773

No functional changes intended.

Fixes some leaks found by running under asan with `--gtest_repeat=2`.

>From 43f8b15fa3e5465f1939d0359ff5dcfc83ed1717 Mon Sep 17 00:00:00 2001
From: Krasimir Georgiev 
Date: Fri, 23 Feb 2024 15:11:51 +
Subject: [PATCH] clang serialization unittests: fix some leaks

No functional changes intended.

Fixes some leaks found by running under asan with --gtest_repeat=2.
---
 .../Serialization/ModuleCacheTest.cpp  | 18 ++
 .../Serialization/VarDeclConstantInitTest.cpp  |  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/clang/unittests/Serialization/ModuleCacheTest.cpp 
b/clang/unittests/Serialization/ModuleCacheTest.cpp
index c3e347ffec660c..76aeee60f5a435 100644
--- a/clang/unittests/Serialization/ModuleCacheTest.cpp
+++ b/clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -88,6 +88,16 @@ class ModuleCacheTest : public ::testing::Test {
 }
 )cpp");
   }
+ 
+  std::unique_ptr createInvocationAndEnableFree(
+  ArrayRef Args, CreateInvocationOptions Opts) {
+std::unique_ptr Invocation =
+createInvocation(Args, Opts);
+if (Invocation)
+  Invocation->getFrontendOpts().DisableFree = false;
+
+return Invocation;
+  }
 };
 
 TEST_F(ModuleCacheTest, CachedModuleNewPath) {
@@ -106,7 +116,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -129,7 +139,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
  "-Fframeworks",  MCPArg.c_str(), "-working-directory",
  TestDir.c_str(), "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
@@ -156,7 +166,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocation(Args, CIOpts);
+  createInvocationAndEnableFree(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -173,7 +183,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPathAllowErrors) {
   TestDir.c_str(), "-Xclang",  "-fallow-pcm-with-compiler-errors",
   "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocation(Args2, CIOpts);
+  createInvocationAndEnableFree(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  ());
diff --git a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp 
b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
index 86ae929e7f17e4..7efa1c1d64a964 100644
--- a/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
+++ b/clang/unittests/Serialization/VarDeclConstantInitTest.cpp
@@ -103,6 +103,7 @@ export namespace Fibonacci
   std::shared_ptr Invocation =
   createInvocation(Args, CIOpts);
   ASSERT_TRUE(Invocation);
+  Invocation->getFrontendOpts().DisableFree = false;
 
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits