[clang] [clang] Fix logic in APValue::LValueBase::getType() (PR #75131)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 11 18:44:20 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Chenyang Gao (cygao90)
<details>
<summary>Changes</summary>
See #<!-- -->69468.
---
Full diff: https://github.com/llvm/llvm-project/pull/75131.diff
1 Files Affected:
- (modified) clang/lib/AST/APValue.cpp (+3-1)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/75131
More information about the cfe-commits
mailing list