diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp index 4eae308ef5b34c..648540c42b3e75 100644 --- a/clang/lib/AST/APValue.cpp +++ b/clang/lib/AST/APValue.cpp @@ -70,8 +70,10 @@ QualType APValue::LValueBase::getType() const { // constexpr int *p = &arr[1]; // valid? // // For now, we take the most complete type we can find. - for (auto *Redecl = cast(D->getMostRecentDecl()); Redecl; + for (auto *Redecl = cast(D->getMostRecentDecl()); + Redecl && !Redecl->isInvalidDecl(); Redecl = cast_or_null(Redecl->getPreviousDecl())) { + D = Redecl; QualType T = Redecl->getType(); if (!T->isIncompleteArrayType()) return T;