[clang] [clang] Fix crash when compiling error with invalid decl (PR #77893)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 4 06:45:37 PST 2024


================
@@ -40,7 +40,11 @@ static_assert(
     "Type is insufficiently aligned");
 
 APValue::LValueBase::LValueBase(const ValueDecl *P, unsigned I, unsigned V)
-    : Ptr(P ? cast<ValueDecl>(P->getCanonicalDecl()) : nullptr), Local{I, V} {}
+    : Ptr(P ? cast<ValueDecl>(P->getCanonicalDecl()->isInvalidDecl()
+                                  ? P
+                                  : P->getCanonicalDecl())
----------------
erichkeane wrote:

This part of the change doesn't really make sense to me either, it isn't clear why the invalid decl is assumed to have a not-invalid-canonical decl, thats an incorrect assumption.

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


More information about the cfe-commits mailing list