[clang] [Clang][AST] Fix crash in APValue::LValueBase::getType when we have invalid decl (PR #75130)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 3 08:13:08 PST 2024


================
@@ -70,11 +70,13 @@ 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<ValueDecl>(D->getMostRecentDecl()); Redecl;
+    for (auto *Redecl = cast<ValueDecl>(D->getMostRecentDecl());
+         Redecl && !Redecl->isInvalidDecl();
----------------
erichkeane wrote:

The problem is that if the 'invalid' decl is the last one, we end up giving up on this loop entirely.  If the purpose here is to just skip an invalid decl, we probably need to skip JUST it, not all previous ones too.

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


More information about the cfe-commits mailing list