[cfe-commits] r151229 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaInit.cpp test/CodeGenObjC/arc-blocks.m

Eli Friedman eli.friedman at gmail.com
Wed Feb 22 18:25:10 PST 2012


Author: efriedma
Date: Wed Feb 22 20:25:10 2012
New Revision: 151229

URL: http://llvm.org/viewvc/llvm-project?rev=151229&view=rev
Log:
Try to handle qualifiers more consistently for array InitListExprs.  Fixes <rdar://problem/10907510>, and makes the ASTs a bit more self-consistent.

(I've chosen to keep the qualifiers, but it isn't a strong preference; if anyone prefers removing them, please yell.)


Modified:
    cfe/trunk/lib/CodeGen/CGExprAgg.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/CodeGenObjC/arc-blocks.m

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=151229&r1=151228&r2=151229&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Wed Feb 22 20:25:10 2012
@@ -905,10 +905,8 @@
       }
     }
 
-    QualType elementType = E->getType().getCanonicalType();
-    elementType = CGF.getContext().getQualifiedType(
-                    cast<ArrayType>(elementType)->getElementType(),
-                    elementType.getQualifiers() + Dest.getQualifiers());
+    QualType elementType =
+        CGF.getContext().getAsArrayType(E->getType())->getElementType();
 
     llvm::PointerType *APType =
       cast<llvm::PointerType>(DestPtr->getType());

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=151229&r1=151228&r2=151229&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 22 20:25:10 2012
@@ -6226,10 +6226,8 @@
   // completed by the initializer. For example:
   //   int ary[] = { 1, 3, 5 };
   // "ary" transitions from an IncompleteArrayType to a ConstantArrayType.
-  if (!VDecl->isInvalidDecl() && (DclT != SavT)) {
+  if (!VDecl->isInvalidDecl() && (DclT != SavT))
     VDecl->setType(DclT);
-    Init->setType(DclT.getNonReferenceType());
-  }
 
   // Check any implicit conversions within the expression.
   CheckImplicitConversions(Init, VDecl->getLocation());

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=151229&r1=151228&r2=151229&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Feb 22 20:25:10 2012
@@ -604,7 +604,9 @@
   CheckListElementTypes(Entity, IList, T, /*SubobjectIsDesignatorContext=*/true,
                         Index, StructuredList, StructuredIndex, TopLevelObject);
   if (!VerifyOnly) {
-    QualType ExprTy = T.getNonLValueExprType(SemaRef.Context);
+    QualType ExprTy = T;
+    if (!ExprTy->isArrayType())
+      ExprTy = ExprTy.getNonLValueExprType(SemaRef.Context);
     IList->setType(ExprTy);
     StructuredList->setType(ExprTy);
   }
@@ -2077,7 +2079,10 @@
                                          InitRange.getBegin(), 0, 0,
                                          InitRange.getEnd());
 
-  Result->setType(CurrentObjectType.getNonLValueExprType(SemaRef.Context));
+  QualType ResultType = CurrentObjectType;
+  if (!ResultType->isArrayType())
+    ResultType = ResultType.getNonLValueExprType(SemaRef.Context);
+  Result->setType(ResultType);
 
   // Pre-allocate storage for the structured initializer list.
   unsigned NumElements = 0;

Modified: cfe/trunk/test/CodeGenObjC/arc-blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-blocks.m?rev=151229&r1=151228&r2=151229&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc-blocks.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-blocks.m Wed Feb 22 20:25:10 2012
@@ -510,3 +510,7 @@
   // CHECK-NEXT: ret void
 }
 
+// <rdar://problem/10907510>
+void test14() {
+  void (^const x[1])(void) = { ^{} };
+}





More information about the cfe-commits mailing list