]> granicus.if.org Git - clang/commitdiff
Cleanup objc's gc attributes code no longer needed.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 18 Feb 2009 17:52:36 +0000 (17:52 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 18 Feb 2009 17:52:36 +0000 (17:52 +0000)
This make warn-weak-field.m to fail (subject of
a followup patch).
attr-objc-gc.m no passes.

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

include/clang/AST/Attr.h
include/clang/AST/Type.h
lib/CodeGen/CGExpr.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaType.cpp

index 8d4e1090cff653c6be1cca25c4024cc6e401b9f8..b2c5c23a4f6c1c3cb6eab6d9fb57a4f1574bc09b 100644 (file)
@@ -41,7 +41,6 @@ public:
     NonNull,
     NoReturn,
     NoThrow,
-    ObjCGC,
     ObjCNSObject,
     ObjCException,
     Overloadable, // Clang-specific
@@ -429,25 +428,6 @@ public:
   static bool classof(const TransparentUnionAttr *A) { return true; }
 };
 
-class ObjCGCAttr : public Attr {
-public:
-  enum GCAttrTypes {
-    Weak = 0,
-    Strong
-  };
-private:
-  GCAttrTypes GCAttrType;
-public:
-  ObjCGCAttr(GCAttrTypes t) : Attr(ObjCGC), GCAttrType(t) {}
-
-  GCAttrTypes getType() const { return GCAttrType; }
-
-  // Implement isa/cast/dyncast/etc.
-
-  static bool classof(const Attr *A) { return A->getKind() == ObjCGC; }
-  static bool classof(const ObjCGCAttr *A) { return true; }
-};
-
 class ObjCNSObjectAttr : public Attr {
 // Implement isa/cast/dyncast/etc.
 public:
index 909f395791066ae80e968c4fd5806a9c19e060b4..fdf79dbd37583d2e5e85befabf904922066ab19a 100644 (file)
@@ -29,7 +29,6 @@ using llvm::dyn_cast_or_null;
 namespace clang {
   class ASTContext;
   class Type;
-  class ObjCGCAttr;
   class TypedefDecl;
   class TemplateDecl;
   class TemplateTypeParmDecl;
index eed9ed7729be897df0122a2131d540db66fdc788..4e60cc518b3c3908866d60e733a17faaa7e66281 100644 (file)
@@ -609,12 +609,16 @@ 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 if (Ctx.getLangOptions().ObjC1 &&
+  else 
+#endif
+  if (Ctx.getLangOptions().ObjC1 &&
            Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {
     // Default behavious under objective-c's gc is for objective-c pointers
     // be treated as though they were declared as __strong.
@@ -925,12 +929,16 @@ 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 if (CGM.getLangOptions().ObjC1 &&
+  else 
+#endif
+  if (CGM.getLangOptions().ObjC1 &&
            CGM.getLangOptions().getGCMode() != LangOptions::NonGC) {
     QualType ExprTy = Field->getType();
     if (getContext().isObjCObjectPointerType(ExprTy))
index c4caec4d425a5f0fab760e3a66be2354c4a3a98c..a385d97f6809d068eab0061d08bd31fa7a841e87 100644 (file)
@@ -568,35 +568,6 @@ static void HandleVisibilityAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   d->addAttr(new VisibilityAttr(type));
 }
 
-static void HandleObjCGCAttr(Decl *D, const AttributeList &Attr, Sema &S) {
-  if (!Attr.getParameterName()) {    
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
-      << "objc_gc" << 1;
-    return;
-  }
-  
-  if (Attr.getNumArgs() != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
-    return;
-  }
-
-  ObjCGCAttr::GCAttrTypes type;
-  if (Attr.getParameterName()->isStr("weak")) {
-    if (isa<FieldDecl>(D) && !isa<ObjCIvarDecl>(D))
-      S.Diag(Attr.getLoc(), diag::warn_attribute_weak_on_field);
-    type = ObjCGCAttr::Weak;
-  }
-  else if (Attr.getParameterName()->isStr("strong"))
-    type = ObjCGCAttr::Strong;
-  else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
-      << "objc_gc" << Attr.getParameterName();
-    return;
-  }
-  
-  D->addAttr(new ObjCGCAttr(type));
-}
-
 static void HandleObjCExceptionAttr(Decl *D, const AttributeList &Attr,
                                     Sema &S) {
   if (Attr.getNumArgs() != 0) {
@@ -1391,7 +1362,8 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) {
   switch (Attr.getKind()) {
   case AttributeList::AT_IBOutlet:    HandleIBOutletAttr  (D, Attr, S); break;
   case AttributeList::AT_address_space:
-    // Ignore this, this is a type attribute, handled by ProcessTypeAttributes.
+  case AttributeList::AT_objc_gc:
+    // Ignore these, these are type attributes, handled by ProcessTypeAttributes.
     break;
   case AttributeList::AT_alias:       HandleAliasAttr     (D, Attr, S); break;
   case AttributeList::AT_aligned:     HandleAlignedAttr   (D, Attr, S); break;
@@ -1426,7 +1398,6 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) {
   case AttributeList::AT_transparent_union:
     HandleTransparentUnionAttr(D, Attr, S);
     break;
-  case AttributeList::AT_objc_gc:     HandleObjCGCAttr    (D, Attr, S); break;
   case AttributeList::AT_objc_exception:
     HandleObjCExceptionAttr(D, Attr, S);
     break;
index 677f994cac009e146a4d5c0cb91e7ad00ac11e2f..96800dd4d1db1fad8a2f544ab9ff26b62700b781 100644 (file)
@@ -779,15 +779,20 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type,
 /// specified type.  The attribute contains 1 argument, weak or strong.
 static void HandleObjCGCTypeAttribute(QualType &Type, 
                                       const AttributeList &Attr, Sema &S){
-  // FIXME. Needs more work for this to make sense.
+  // FIXME. change error code.
   if (Type.getObjCGCAttr() != QualType::GCNone) {
     S.Diag(Attr.getLoc(), diag::err_attribute_address_multiple_qualifiers);
     return;
   }
   
   // Check the attribute arguments.
+  if (!Attr.getParameterName()) {    
+    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
+      << "objc_gc" << 1;
+    return;
+  }
   QualType::GCAttrTypes attr;
-  if (!Attr.getParameterName() || Attr.getNumArgs() != 0) {
+  if (Attr.getNumArgs() != 0) {
     S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
     return;
   }