pch support for protocol qualified id's.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69781 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h
index 118ef02..5ef7362 100644
--- a/include/clang/AST/ExprObjC.h
+++ b/include/clang/AST/ExprObjC.h
@@ -264,10 +264,7 @@
 /// Key Value Encoding, a generic concept for accessing or setting a 'Key'
 /// value for an object.
 ///
-
 class ObjCKVCRefExpr : public Expr {
-private:
-  
   ObjCMethodDecl *Setter;
   ObjCMethodDecl *Getter;
   SourceLocation Loc;
@@ -466,7 +463,6 @@
 /// which refers to the object on which the current method is executing.
 class ObjCSuperExpr : public Expr {
   SourceLocation Loc;
-
 public:
   ObjCSuperExpr(SourceLocation L, QualType Type) 
     : Expr(ObjCSuperExprClass, Type), Loc(L) { }
diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h
index df3db3b..d40e970 100644
--- a/include/clang/Frontend/PCHBitCodes.h
+++ b/include/clang/Frontend/PCHBitCodes.h
@@ -533,6 +533,8 @@
       /// \brief A ObjCProtocolExpr record.
       EXPR_OBJC_PROTOCOL_EXPR
 
+      // FIXME: From ExprObjC.h: ObjCIvarRefExpr, ObjCPropertyRefExpr,
+      // ObjCKVCRefExpr, ObjCMessageExpr, ObjCSuperExpr
     };
 
     /// \brief The kinds of designators that can occur in a
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index beb8ce8..f29a0ba 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -2090,10 +2090,14 @@
     assert(false && "Cannot de-serialize ObjC qualified interface types yet");
     return QualType();
 
-  case pch::TYPE_OBJC_QUALIFIED_ID:
-    // FIXME: Deserialize ObjCQualifiedIdType
-    assert(false && "Cannot de-serialize ObjC qualified id types yet");
-    return QualType();
+  case pch::TYPE_OBJC_QUALIFIED_ID: {
+    unsigned Idx = 0;
+    unsigned NumProtos = Record[Idx++];
+    llvm::SmallVector<ObjCProtocolDecl*, 4> Protos;
+    for (unsigned I = 0; I != NumProtos; ++I)
+      Protos.push_back(cast<ObjCProtocolDecl>(GetDecl(Record[Idx++])));
+    return Context.getObjCQualifiedIdType(&Protos[0], NumProtos);
+  }
 
   case pch::TYPE_OBJC_QUALIFIED_CLASS:
     // FIXME: Deserialize ObjCQualifiedClassType
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 0d7f588..7605781 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -1174,6 +1174,7 @@
 
 void PCHStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
   VisitExpr(E);
+  assert(0 && "Can't write a selector yet!");
   // FIXME!  Write selectors.
   //Writer.WriteSubStmt(E->getSelector());
   Writer.AddSourceLocation(E->getAtLoc(), Record);
diff --git a/test/PCH/objc_exprs.h b/test/PCH/objc_exprs.h
index 5c0c2ae..ea6f275 100644
--- a/test/PCH/objc_exprs.h
+++ b/test/PCH/objc_exprs.h
@@ -1,11 +1,12 @@
 
 @protocol foo;
 
+// Expressions
 typedef typeof(@"foo" "bar") objc_string;
-
 typedef typeof(@encode(int)) objc_encode;
-
-
 typedef typeof(@protocol(foo)) objc_protocol;
 
-//const char *X;
+
+// Types.
+typedef typeof(id<foo>) objc_id_protocol_ty;
+
diff --git a/test/PCH/objc_exprs.m b/test/PCH/objc_exprs.m
index b11a7e5..0b20af8 100644
--- a/test/PCH/objc_exprs.m
+++ b/test/PCH/objc_exprs.m
@@ -5,14 +5,18 @@
 // RUN: clang-cc -x objective-c-header -emit-pch -fblocks -o %t %S/objc_exprs.h &&
 // RUN: clang-cc -fblocks -include-pch %t -fsyntax-only -verify %s 
 
-
-
+// Expressions
 int *A1 = (objc_string)0;   // expected-warning {{'struct objc_object *'}}
 
-char A2 = (objc_encode){};  // expected-error {{initializer element is not a compile-time constant}} \
+char A2 = (objc_encode){};  // expected-error {{not a compile-time constant}} \
                                expected-warning {{char [2]}}
 
 int *A3 = (objc_protocol)0; // expected-warning {{aka 'Protocol *'}}
 
 
+// Types.
+int *T0 = (objc_id_protocol_ty)0; // expected-error {{not a compile-time constant}} \
+                                     expected-warning {{aka 'id<foo>'}}
+
+