[clang] ff48353 - [clang-repl] Use RegisterPTU for tracking generated TranslationUnitDecl through parse (#164778)

via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 26 03:38:03 PDT 2025


Author: Anutosh Bhat
Date: 2025-10-26T10:37:59Z
New Revision: ff48353aaeb51a5c3ccf6720de9e756c1270ad2f

URL: https://github.com/llvm/llvm-project/commit/ff48353aaeb51a5c3ccf6720de9e756c1270ad2f
DIFF: https://github.com/llvm/llvm-project/commit/ff48353aaeb51a5c3ccf6720de9e756c1270ad2f.diff

LOG: [clang-repl] Use RegisterPTU for tracking generated TranslationUnitDecl through parse (#164778)

Instead of manually creating and adding a PTU, we should be able to use
`RegisterPTU` which does the same job here.

Added: 
    

Modified: 
    clang/lib/Interpreter/Interpreter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index b05cb5a0f1dbe..cde354c9cd8d1 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -581,12 +581,7 @@ Interpreter::Parse(llvm::StringRef Code) {
   if (!TuOrErr)
     return TuOrErr.takeError();
 
-  PTUs.emplace_back(PartialTranslationUnit());
-  PartialTranslationUnit &LastPTU = PTUs.back();
-  LastPTU.TUPart = *TuOrErr;
-
-  if (std::unique_ptr<llvm::Module> M = Act->GenModule())
-    LastPTU.TheModule = std::move(M);
+  PartialTranslationUnit &LastPTU = IncrParser->RegisterPTU(*TuOrErr);
 
   return LastPTU;
 }


        


More information about the cfe-commits mailing list