]> granicus.if.org Git - clang/commitdiff
Start generating gc'able code using the new
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 18 Feb 2009 18:52:41 +0000 (18:52 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 18 Feb 2009 18:52:41 +0000 (18:52 +0000)
objc gc type attributes.

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

include/clang/Basic/DiagnosticSemaKinds.def
lib/CodeGen/CGExpr.cpp
lib/Sema/SemaType.cpp

index fc4bfc9ad2f90177c423a8da921173e9f431df4d..a283b73ab7844c3a8830bb10aa76b81e13a4a89d 100644 (file)
@@ -903,6 +903,8 @@ DIAG(error_objc_throw_expects_object, ERROR,
      "invalid %0 argument (expected an ObjC object type)")
 DIAG(error_rethrow_used_outside_catch, ERROR,
      "@throw (rethrow) used outside of a @catch block")
+DIAG(err_attribute_multiple_objc_gc, ERROR,
+     "multiple garbage collection attributes specified for type")
 
 
 // C++ casts
index 4e60cc518b3c3908866d60e733a17faaa7e66281..ae8d4b433a256e4ab412ee8cd0237449a41c0119 100644 (file)
@@ -609,22 +609,17 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
 static void SetVarDeclObjCAttribute(ASTContext &Ctx, const Decl *VD, 
                                     const QualType &Ty, LValue &LV)
 {
-#if 0
-// FIXME. ObjCGCAttr no more.
-  if (const ObjCGCAttr *A = VD->getAttr<ObjCGCAttr>()) {
-    ObjCGCAttr::GCAttrTypes attrType = A->getType();
-    LValue::SetObjCType(attrType == ObjCGCAttr::Weak, 
-                        attrType == ObjCGCAttr::Strong, LV);
-  }
-  else 
-#endif
   if (Ctx.getLangOptions().ObjC1 &&
-           Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {
+      Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {
+    QualType::GCAttrTypes attr = Ty.getObjCGCAttr();
+    if (attr != QualType::GCNone)
+      LValue::SetObjCType(attr == QualType::Weak, 
+                          attr == QualType::Strong, LV);
     // Default behavious under objective-c's gc is for objective-c pointers
     // be treated as though they were declared as __strong.
-    if (Ctx.isObjCObjectPointerType(Ty))
+    else if (Ctx.isObjCObjectPointerType(Ty))
       LValue::SetObjCType(false, true, LV);
-  }  
+  }
 }
 
 LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
@@ -929,21 +924,17 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
   LValue LV =  
     LValue::MakeAddr(V, 
                      Field->getType().getCVRQualifiers()|CVRQualifiers);
-#if 0
-// FIXME. ObjCGCAttr is no more.
-  if (const ObjCGCAttr *A = Field->getAttr<ObjCGCAttr>()) {
-    ObjCGCAttr::GCAttrTypes attrType = A->getType();
-    // __weak attribute on a field is ignored.
-    LValue::SetObjCType(false, attrType == ObjCGCAttr::Strong, LV);
-  }
-  else 
-#endif
   if (CGM.getLangOptions().ObjC1 &&
-           CGM.getLangOptions().getGCMode() != LangOptions::NonGC) {
-    QualType ExprTy = Field->getType();
-    if (getContext().isObjCObjectPointerType(ExprTy))
+      CGM.getLangOptions().getGCMode() != LangOptions::NonGC) {
+    QualType Ty = Field->getType();
+    QualType::GCAttrTypes attr = Ty.getObjCGCAttr();
+    if (attr != QualType::GCNone)
+      // __weak attribute on a field is ignored.
+      LValue::SetObjCType(false, attr == QualType::Strong, LV);
+    else if (getContext().isObjCObjectPointerType(Ty))
       LValue::SetObjCType(false, true, LV);
-  }  
+    
+  }
   return LV;
 }
 
index 96800dd4d1db1fad8a2f544ab9ff26b62700b781..dfd024b31e666f1d80cc8506396bfe490f1d425a 100644 (file)
@@ -781,7 +781,7 @@ static void HandleObjCGCTypeAttribute(QualType &Type,
                                       const AttributeList &Attr, Sema &S){
   // FIXME. change error code.
   if (Type.getObjCGCAttr() != QualType::GCNone) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_address_multiple_qualifiers);
+    S.Diag(Attr.getLoc(), diag::err_attribute_multiple_objc_gc);
     return;
   }