]> granicus.if.org Git - clang/commitdiff
Use getAsPointerType instead of using getCanonicalType directly.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 18 Apr 2009 08:54:40 +0000 (08:54 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 18 Apr 2009 08:54:40 +0000 (08:54 +0000)
 - <rdar://problem/6803995>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69435 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenObjC/attr-strong.c [new file with mode: 0644]

index f98e6748b219cd3d478d7df9dd91e558efd2f869..a073c442561248eef45a7b655f75624ae9d1fb9a 100644 (file)
@@ -825,13 +825,10 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
                                                     BaseTypeSize));
   }
   
-  QualType T = E->getBase()->getType();
-  QualType ExprTy = getContext().getCanonicalType(T);
-  T = T->getAsPointerType()->getPointeeType();
-  LValue LV = 
-           LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"),
-           ExprTy->getAsPointerType()->getPointeeType().getCVRQualifiers(),
-           getContext().getObjCGCAttrKind(T));
+  QualType T = E->getBase()->getType()->getAsPointerType()->getPointeeType();
+  LValue LV = LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"),
+                               T.getCVRQualifiers(),
+                               getContext().getObjCGCAttrKind(T));
   if (getContext().getLangOptions().ObjC1 &&
       getContext().getLangOptions().getGCMode() != LangOptions::NonGC)
     LValue::SetObjCNonGC(LV, !E->isOBJCGCCandidate());
@@ -900,7 +897,7 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
   if (E->isArrow()) {
     BaseValue = EmitScalarExpr(BaseExpr);
     const PointerType *PTy = 
-      cast<PointerType>(getContext().getCanonicalType(BaseExpr->getType()));
+      BaseExpr->getType()->getAsPointerType();
     if (PTy->getPointeeType()->isUnionType())
       isUnion = true;
     CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
@@ -1166,8 +1163,7 @@ LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) {
   QualType ObjectTy;
   if (E->isArrow()) {
     BaseValue = EmitScalarExpr(BaseExpr);
-    const PointerType *PTy = 
-      cast<PointerType>(getContext().getCanonicalType(BaseExpr->getType()));
+    const PointerType *PTy = BaseExpr->getType()->getAsPointerType();
     ObjectTy = PTy->getPointeeType();
     CVRQualifiers = ObjectTy.getCVRQualifiers();
   } else {
diff --git a/test/CodeGenObjC/attr-strong.c b/test/CodeGenObjC/attr-strong.c
new file mode 100644 (file)
index 0000000..ca83334
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: clang -emit-llvm -S -o %t %s
+
+struct s0 {
+  void *a;
+};
+struct s0 * __attribute__((objc_gc(strong))) g0;
+void f0(void) {
+  g0->a = 0;
+}