[clang] [clang] Fix logic in APValue::LValueBase::getType() (PR #75131)
Chenyang Gao via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 11 18:43:52 PST 2023
https://github.com/cygao90 created https://github.com/llvm/llvm-project/pull/75131
See #69468.
>From ffc9b634427a117cacfd06d9247fdb98cb6bbb30 Mon Sep 17 00:00:00 2001
From: Chenyang Gao <cygao09 at gmail.com>
Date: Tue, 12 Dec 2023 03:22:31 +0800
Subject: [PATCH] [clang] Fix logic in APValue::LValueBase::getType()
---
clang/lib/AST/APValue.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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<ValueDecl>(D->getMostRecentDecl()); Redecl;
+ for (auto *Redecl = cast<ValueDecl>(D->getMostRecentDecl());
+ Redecl && !Redecl->isInvalidDecl();
Redecl = cast_or_null<ValueDecl>(Redecl->getPreviousDecl())) {
+ D = Redecl;
QualType T = Redecl->getType();
if (!T->isIncompleteArrayType())
return T;
More information about the cfe-commits
mailing list