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

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 28 15:41:55 PST 2023


================
@@ -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();
----------------
shafik wrote:

We are dealing with ill-formed code here. So there is not "right answer", right? Are you saying that we might misdiagnose an error?

Or are you saying the original code is incorrect and you think there is well-formed code we will not do the correct thing on?

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


More information about the cfe-commits mailing list