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

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 14 13:32:39 PDT 2024


================
@@ -13435,8 +13435,7 @@ void Sema::checkNonTrivialCUnion(QualType QT, SourceLocation Loc,
 void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
   // If there is no declaration, there was an error parsing it.  Just ignore
   // the initializer.
-  if (!RealDecl || RealDecl->isInvalidDecl()) {
-    CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
+  if (!RealDecl) {
     return;
   }
----------------
mizvekov wrote:

There is an odd change in behavior here, is that intentional?
If there is no declaration, or the declaration is not a VarDecl, then we don't try to correct typos in `Init` anymore.

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


More information about the cfe-commits mailing list