[cfe-commits] r64935 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/CodeGen/CGExpr.cpp lib/Sema/SemaType.cpp

Fariborz Jahanian fjahanian at apple.com
Wed Feb 18 10:52:42 PST 2009


Author: fjahanian
Date: Wed Feb 18 12:52:41 2009
New Revision: 64935

URL: http://llvm.org/viewvc/llvm-project?rev=64935&view=rev
Log:
Start generating gc'able code using the new
objc gc type attributes.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def?rev=64935&r1=64934&r2=64935&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def Wed Feb 18 12:52:41 2009
@@ -903,6 +903,8 @@
      "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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=64935&r1=64934&r2=64935&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Feb 18 12:52:41 2009
@@ -609,22 +609,17 @@
 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 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;
 }
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=64935&r1=64934&r2=64935&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Feb 18 12:52:41 2009
@@ -781,7 +781,7 @@
                                       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;
   }
   





More information about the cfe-commits mailing list