[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 14 23:45:35 PDT 2024


================
@@ -13456,6 +13455,14 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
     return;
   }
 
+  if (VDecl->isInvalidDecl()) {
+    CorrectDelayedTyposInExpr(Init, VDecl);
+    VDecl->setInit(
+        CreateRecoveryExpr(Init->getBeginLoc(), Init->getEndLoc(), {Init})
+            .get());
----------------
HighCommander4 wrote:

Fixed, thanks.

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


More information about the cfe-commits mailing list