[clang] [clang-repl] fix segfault in CleanUpPTU() (PR #75629)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 09:12:13 PST 2023


================
@@ -373,7 +373,15 @@ std::unique_ptr<llvm::Module> IncrementalParser::GenModule() {
 
 void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
   TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+  if (!MostRecentTU) {
+    return;
+  }
+
   TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
+  if (!FirstTU) {
+    return;
+  }
----------------
vgvassilev wrote:

```suggestion
  if (!FirstTU)
    return;
```

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


More information about the cfe-commits mailing list