[cfe-commits] r49324 - /cfe/trunk/lib/AST/ASTContext.cpp

Chris Lattner sabre at nondot.org
Sun Apr 6 23:51:05 PDT 2008


Author: lattner
Date: Mon Apr  7 01:51:04 2008
New Revision: 49324

URL: http://llvm.org/viewvc/llvm-project?rev=49324&view=rev
Log:
move some code around, no other change.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Apr  7 01:51:04 2008
@@ -1435,69 +1435,9 @@
   ObjCConstantStringType = getObjCInterfaceType(Decl);
 }
 
-
-/// areCompatObjCInterfaces - Return true if the two interface types are
-/// compatible for assignment from RHS to LHS.  This handles validation of any
-/// protocol qualifiers on the LHS or RHS.
-///
-static bool 
-areCompatObjCInterfaces(const ObjCInterfaceType *LHS, 
-                        const ObjCInterfaceType *RHS) {
-  // Verify that the base decls are compatible: the RHS must be a subclass of
-  // the LHS.
-  if (!LHS->getDecl()->isSuperClassOf(RHS->getDecl()))
-    return false;
-
-  // RHS must have a superset of the protocols in the LHS.  If the LHS is not
-  // protocol qualified at all, then we are good.
-  if (!isa<ObjCQualifiedInterfaceType>(LHS))
-    return true;
-  
-  // Okay, we know the LHS has protocol qualifiers.  If the RHS doesn't, then it
-  // isn't a superset.
-  if (!isa<ObjCQualifiedInterfaceType>(RHS))
-    return true;  // FIXME: should return false!
-
-  // Finally, we must have two protocol-qualified interfaces.
-  const ObjCQualifiedInterfaceType *LHSP =cast<ObjCQualifiedInterfaceType>(LHS);
-  const ObjCQualifiedInterfaceType *RHSP =cast<ObjCQualifiedInterfaceType>(RHS);
-  ObjCQualifiedInterfaceType::qual_iterator LHSPI = LHSP->qual_begin();
-  ObjCQualifiedInterfaceType::qual_iterator LHSPE = LHSP->qual_end();
-  ObjCQualifiedInterfaceType::qual_iterator RHSPI = RHSP->qual_begin();
-  ObjCQualifiedInterfaceType::qual_iterator RHSPE = RHSP->qual_end();
-  
-  // All protocols in LHS must have a presence in RHS.  Since the protocol lists
-  // are both sorted alphabetically and have no duplicates, we can scan RHS and
-  // LHS in a single parallel scan until we run out of elements in LHS.
-  assert(LHSPI != LHSPE && "Empty LHS protocol list?");
-  ObjCProtocolDecl *LHSProto = *LHSPI;
-  
-  while (RHSPI != RHSPE) {
-    ObjCProtocolDecl *RHSProto = *RHSPI++;
-    // If the RHS has a protocol that the LHS doesn't, ignore it.
-    if (RHSProto != LHSProto)
-      continue;
-    
-    // Otherwise, the RHS does have this element.
-    ++LHSPI;
-    if (LHSPI == LHSPE)
-      return true;  // All protocols in LHS exist in RHS.
-    
-    LHSProto = *LHSPI;
-  }
-  
-  // If we got here, we didn't find one of the LHS's protocols in the RHS list.
-  return false;
-}
-
-/// areCompatVectorTypes - Return true if the two specified vector types are 
-/// compatible.
-static bool areCompatVectorTypes(const VectorType *LHS,
-                                 const VectorType *RHS) {
-  assert(LHS->isCanonical() && RHS->isCanonical());
-  return LHS->getElementType() == RHS->getElementType() &&
-         LHS->getNumElements() == RHS->getNumElements();
-}
+//===----------------------------------------------------------------------===//
+//                        Type Compatibility Testing
+//===----------------------------------------------------------------------===//
 
 /// C99 6.2.7p1: If both are complete types, then the following additional
 /// requirements apply.
@@ -1606,6 +1546,70 @@
   return true;
 }
 
+/// areCompatVectorTypes - Return true if the two specified vector types are 
+/// compatible.
+static bool areCompatVectorTypes(const VectorType *LHS,
+                                 const VectorType *RHS) {
+  assert(LHS->isCanonical() && RHS->isCanonical());
+  return LHS->getElementType() == RHS->getElementType() &&
+  LHS->getNumElements() == RHS->getNumElements();
+}
+
+/// areCompatObjCInterfaces - Return true if the two interface types are
+/// compatible for assignment from RHS to LHS.  This handles validation of any
+/// protocol qualifiers on the LHS or RHS.
+///
+static bool 
+areCompatObjCInterfaces(const ObjCInterfaceType *LHS, 
+                        const ObjCInterfaceType *RHS) {
+  // Verify that the base decls are compatible: the RHS must be a subclass of
+  // the LHS.
+  if (!LHS->getDecl()->isSuperClassOf(RHS->getDecl()))
+    return false;
+  
+  // RHS must have a superset of the protocols in the LHS.  If the LHS is not
+  // protocol qualified at all, then we are good.
+  if (!isa<ObjCQualifiedInterfaceType>(LHS))
+    return true;
+  
+  // Okay, we know the LHS has protocol qualifiers.  If the RHS doesn't, then it
+  // isn't a superset.
+  if (!isa<ObjCQualifiedInterfaceType>(RHS))
+    return true;  // FIXME: should return false!
+  
+  // Finally, we must have two protocol-qualified interfaces.
+  const ObjCQualifiedInterfaceType *LHSP =cast<ObjCQualifiedInterfaceType>(LHS);
+  const ObjCQualifiedInterfaceType *RHSP =cast<ObjCQualifiedInterfaceType>(RHS);
+  ObjCQualifiedInterfaceType::qual_iterator LHSPI = LHSP->qual_begin();
+  ObjCQualifiedInterfaceType::qual_iterator LHSPE = LHSP->qual_end();
+  ObjCQualifiedInterfaceType::qual_iterator RHSPI = RHSP->qual_begin();
+  ObjCQualifiedInterfaceType::qual_iterator RHSPE = RHSP->qual_end();
+  
+  // All protocols in LHS must have a presence in RHS.  Since the protocol lists
+  // are both sorted alphabetically and have no duplicates, we can scan RHS and
+  // LHS in a single parallel scan until we run out of elements in LHS.
+  assert(LHSPI != LHSPE && "Empty LHS protocol list?");
+  ObjCProtocolDecl *LHSProto = *LHSPI;
+  
+  while (RHSPI != RHSPE) {
+    ObjCProtocolDecl *RHSProto = *RHSPI++;
+    // If the RHS has a protocol that the LHS doesn't, ignore it.
+    if (RHSProto != LHSProto)
+      continue;
+    
+    // Otherwise, the RHS does have this element.
+    ++LHSPI;
+    if (LHSPI == LHSPE)
+      return true;  // All protocols in LHS exist in RHS.
+    
+    LHSProto = *LHSPI;
+  }
+  
+  // If we got here, we didn't find one of the LHS's protocols in the RHS list.
+  return false;
+}
+
+
 /// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible, 
 /// both shall have the identically qualified version of a compatible type.
 /// C99 6.2.7p1: Two types have compatible types if their types are the 





More information about the cfe-commits mailing list