move ObjCQualifiedIdTypesAreCompatible out of ASTContext into Sema.
While it is similar to the other compatibility predicates in ASTContext,
it is not used by them and is different.

In addition, greatly simplify ObjCQualifiedIdTypesAreCompatible and
fix some canonical type bugs.  Also, simplify my Type::getAsObjC* methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49313 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index a661d01..a528519 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1185,9 +1185,8 @@
     return Incompatible;
   }
   
-  if (lhsType->isObjCQualifiedIdType() 
-           || rhsType->isObjCQualifiedIdType()) {
-    if (Context.ObjCQualifiedIdTypesAreCompatible(lhsType, rhsType))
+  if (lhsType->isObjCQualifiedIdType() || rhsType->isObjCQualifiedIdType()) {
+    if (ObjCQualifiedIdTypesAreCompatible(lhsType, rhsType, false))
       return Compatible;
     return Incompatible;
   }
@@ -1368,9 +1367,9 @@
   return InvalidOperands(loc, lex, rex);
 }
 
-inline QualType Sema::CheckSubtractionOperands( // C99 6.5.6
-  Expr *&lex, Expr *&rex, SourceLocation loc, bool isCompAssign) 
-{
+// C99 6.5.6
+QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
+                                        SourceLocation loc, bool isCompAssign) {
   if (lex->getType()->isVectorType() || rex->getType()->isVectorType())
     return CheckVectorOperands(loc, lex, rex);
     
@@ -1437,8 +1436,9 @@
   return InvalidOperands(loc, lex, rex);
 }
 
-inline QualType Sema::CheckShiftOperands( // C99 6.5.7
-  Expr *&lex, Expr *&rex, SourceLocation loc, bool isCompAssign) {
+// C99 6.5.7
+QualType Sema::CheckShiftOperands(Expr *&lex, Expr *&rex, SourceLocation loc,
+                                  bool isCompAssign) {
   // C99 6.5.7p2: Each of the operands shall have integer type.
   if (!lex->getType()->isIntegerType() || !rex->getType()->isIntegerType())
     return InvalidOperands(loc, lex, rex);
@@ -1453,9 +1453,9 @@
   return lex->getType();
 }
 
-inline QualType Sema::CheckCompareOperands( // C99 6.5.8
-  Expr *&lex, Expr *&rex, SourceLocation loc, bool isRelational)
-{
+// C99 6.5.8
+QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation loc,
+                                    bool isRelational) {
   // C99 6.5.8p3 / C99 6.5.9p4
   if (lex->getType()->isArithmeticType() && rex->getType()->isArithmeticType())
     UsualArithmeticConversions(lex, rex);
@@ -1514,7 +1514,7 @@
     return Context.IntTy;
   }
   if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())
-      && Context.ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) {
+      && ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) {
     ImpCastExprToType(rex, lType); 
     return Context.IntTy;
   }