[cfe-commits] r72711 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaObjC/objc2-merge-gc-attribue-decl.m

Fariborz Jahanian fjahanian at apple.com
Mon Jun 1 18:40:24 PDT 2009


Author: fjahanian
Date: Mon Jun  1 20:40:22 2009
New Revision: 72711

URL: http://llvm.org/viewvc/llvm-project?rev=72711&view=rev
Log:
This patch attempts to fix the merging of __strong/__weak attributes
in merge_types. It is incomplete. We probably want to issue 
a warning if user attempts to change the attribute from __weak to
__strong or vice-vera. It also assumes that a __weak/__strong
attribute can not be specified with other (currently one) type
attriute. 

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=72711&r1=72710&r2=72711&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Jun  1 20:40:22 2009
@@ -3028,6 +3028,20 @@
   if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
   if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
 
+  QualType::GCAttrTypes RHSGCAttr = QualType::GCNone;
+  QualType::GCAttrTypes LHSGCAttr = QualType::GCNone;
+  if (RHSClass == Type::ExtQual) {
+    RHSGCAttr = RHSCan.getObjCGCAttr();    
+    if (RHSGCAttr != QualType::GCNone)
+      RHSClass = RHSCan.getUnqualifiedType()->getTypeClass();
+  }
+
+  if (LHSClass == Type::ExtQual) {
+    LHSGCAttr = LHSCan.getObjCGCAttr();    
+    if (LHSGCAttr != QualType::GCNone)
+      LHSClass = LHSCan.getUnqualifiedType()->getTypeClass();
+  }
+
   // Same as above for arrays
   if (LHSClass == Type::VariableArray || LHSClass == Type::IncompleteArray)
     LHSClass = Type::ConstantArray;
@@ -3125,10 +3139,16 @@
     QualType RHSPointee = RHS->getAsPointerType()->getPointeeType();
     QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
     if (ResultType.isNull()) return QualType();
-    if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))
+    if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType)) {
+      if (RHSGCAttr != LHSGCAttr && RHSGCAttr != QualType::GCNone)
+        LHS = getObjCGCQualType(LHS, RHSGCAttr);
       return LHS;
-    if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType))
+    }
+    if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType)) {
+      if (RHSGCAttr != LHSGCAttr && LHSGCAttr != QualType::GCNone)
+        RHS = getObjCGCQualType(RHS, LHSGCAttr);
       return RHS;
+    }
     return getPointerType(ResultType);
   }
   case Type::BlockPointer:

Modified: cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m?rev=72711&r1=72710&r2=72711&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m (original)
+++ cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m Mon Jun  1 20:40:22 2009
@@ -1,7 +1,4 @@
 // RUN: clang-cc -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
-// This is really dangerous!  Disabling for now until we work out what's
-// supposed to happen here.
-// XFAIL
 @interface INTF @end
 
 extern INTF* p2;





More information about the cfe-commits mailing list