Implement a more sensible strategy for ObjC built-in types (addressing a long standing FIXME in Sema::GetObjcIdType()).

This removes several gross hacks to work around the previous "lazy" behavior.

Two notes:
- MinimalActions still needs to be taught about the built-in types (This breaks one of the -noop test cases). I started this, then added a FIXME.
- I didn't convert Sema::GetObjcProtoType() yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43567 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index aac6ca3..1eacd48 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1959,17 +1959,6 @@
                                                  SourceLocation RParenLoc) {
   QualType EncodedType = QualType::getFromOpaquePtr(Ty);
 
-  // We cannot build type 'id' lazily. It is needed when checking if a 
-  // type is an 'id' (via call to isObjcIdType) even if there is no
-  // need for the default 'id' type.
-  // FIXME: Depending on the need to compare to 'id', this may have to go
-  // somewhere else. At this time, this is a good enough place to do type
-  // encoding of methods and ivars for the rewrite client.
-  // The same is true for the 'Class' and 'SEL' types.
-  GetObjcIdType(EncodeLoc);
-  GetObjcClassType(EncodeLoc);
-  GetObjcSelType(EncodeLoc);
-  
   QualType t = Context.getPointerType(Context.CharTy);
   return new ObjCEncodeExpr(t, EncodedType, AtLoc, RParenLoc);
 }
@@ -1979,7 +1968,7 @@
                                                    SourceLocation SelLoc,
                                                    SourceLocation LParenLoc,
                                                    SourceLocation RParenLoc) {
-  QualType t = GetObjcSelType(AtLoc);
+  QualType t = Context.getObjcSelType();
   return new ObjCSelectorExpr(t, Sel, AtLoc, RParenLoc);
 }
 
@@ -2076,7 +2065,7 @@
   if (!Method) {
     Diag(lbrac, diag::warn_method_not_found, std::string("+"), Sel.getName(),
          SourceRange(lbrac, rbrac));
-    returnType = GetObjcIdType();
+    returnType = Context.getObjcIdType();
   } else {
     returnType = Method->getResultType();
     if (Sel.getNumArgs()) {
@@ -2084,7 +2073,6 @@
         return true;
     }
   }
-  GetObjcSelType(lbrac); // FIXME: a hack to install the sel type.
   return new ObjCMessageExpr(receiverName, Sel, returnType, lbrac, rbrac,
                              ArgExprs);
 }
@@ -2103,12 +2091,12 @@
   QualType receiverType = RExpr->getType();
   QualType returnType;
   
-  if (receiverType == GetObjcIdType()) {
+  if (receiverType == Context.getObjcIdType()) {
     ObjcMethodDecl *Method = InstanceMethodPool[Sel].Method;
     if (!Method) {
       Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
            SourceRange(lbrac, rbrac));
-      returnType = GetObjcIdType();
+      returnType = Context.getObjcIdType();
     } else {
       returnType = Method->getResultType();
       if (Sel.getNumArgs())
@@ -2134,7 +2122,7 @@
     if (!Method) {
       Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
            SourceRange(lbrac, rbrac));
-      returnType = GetObjcIdType();
+      returnType = Context.getObjcIdType();
     } else {
       returnType = Method->getResultType();
       if (Sel.getNumArgs())
@@ -2142,6 +2130,5 @@
           return true;
     }
   }
-  GetObjcSelType(lbrac); // FIXME: a hack to install the sel type.
   return new ObjCMessageExpr(RExpr, Sel, returnType, lbrac, rbrac, ArgExprs);
 }