[clang] [OpenCL] Fix an infinite loop in builidng AddrSpaceQualType (PR #92612)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Sat May 18 11:58:56 PDT 2024
================
@@ -3054,6 +3054,13 @@ QualType ASTContext::removeAddrSpaceQualType(QualType T) const {
if (!T.hasAddressSpace())
return T;
+ // For arrays, strip the qualifier off the element type, then reconstruct the
+ // array type
+ if (T.getTypePtr()->isArrayType()) {
+ Qualifiers Qualfs;
+ return getUnqualifiedArrayType(T, Qualfs);
----------------
efriedma-quic wrote:
You need to preserve the non-address-space qualifiers, the same way the code after the loop does. Actually, I'd just recommend restructuring to use the existing code, something like:
```
if (T.getTypePtr()->isArrayType()) {
getUnqualifiedArrayType()
} else {
while (T.hasAddressSpace()) {
[...]
}
}
```
https://github.com/llvm/llvm-project/pull/92612
More information about the cfe-commits
mailing list