[clang] [clang-repl] Refactor locking of runtime PTU stack (NFC) (PR #84176)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 12:44:53 PST 2024


Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/84176 at github.com>


================
@@ -136,6 +136,24 @@ TEST(InterpreterTest, DeclsAndStatements) {
   EXPECT_TRUE(!!R2);
 }
 
+TEST(InterpreterTest, PTUStack) {
+  clang::IncrementalCompilerBuilder CB;
+  auto CI = cantFail(CB.CreateCpp());
+
+  llvm::Error Err = llvm::Error::success();
+  auto Interp = std::make_unique<Interpreter>(std::move(CI), Err);
+  cantFail(std::move(Err));
+
+  auto NumBuiltinPTUs = Interp->getEffectivePTUSize();
+  cantFail(Interp->Parse("void firstRuntimePTU() {}"));
+  EXPECT_EQ(NumBuiltinPTUs + 1, Interp->getEffectivePTUSize());
----------------
vgvassilev wrote:

Wouldn’t using the public interpreter::Undo indirectly achieve the same effect? If it errors out we will know the size of the builtin PTUs. 

https://github.com/llvm/llvm-project/pull/84176


More information about the cfe-commits mailing list