[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 23:19:19 PDT 2024
================
@@ -13435,16 +13435,18 @@ 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()) {
+ if (!RealDecl) {
CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
return;
}
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
----------------
HighCommander4 wrote:
Note, I believe in this formulation it needs to be:
```
if (auto *Method = dyn_cast<CXXMethodDecl>(RealDecl); Method && !Method->isInvalidDecl())
```
https://github.com/llvm/llvm-project/pull/88645
More information about the cfe-commits
mailing list