[clang] [OpenCL] Fix an infinite loop in builidng AddrSpaceQualType (PR #92612)

Changpeng Fang via cfe-commits cfe-commits at lists.llvm.org
Sat May 18 14:57:32 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);
----------------
changpeng wrote:

Thanks.  Can I do as the following?
Note that I am passing QualifierCollector to getUnqualifiedArrayType, which has Qualifiers as the second argument.
 Also,  TypeNode = T.getTypePtr(); after I is unqualified.

 QualifierCollector Quals;
  const Type *TypeNode;
  if (T.getTypePtr()->isArrayType()) {
    T = getUnqualifiedArrayType(T, Quals);
    TypeNode = T.getTypePtr();
  } else {
  while (T.hasAddressSpace()) {
  ....

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


More information about the cfe-commits mailing list