Patch to generate meta-data for prtocol used
in @protocol expression.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68806 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index a06959f..ae70dc5 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -4327,7 +4327,10 @@
 llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CGBuilderTy &Builder,
                                             const ObjCProtocolDecl *PD) {
   
-  llvm::Constant *Init =  llvm::ConstantExpr::getBitCast(GetProtocolRef(PD),
+  // This routine is called for @protocol only. So, we must build definition
+  // of protocol's meta-data (not a reference to it!)
+  //
+  llvm::Constant *Init =  llvm::ConstantExpr::getBitCast(GetOrEmitProtocol(PD),
                                         ObjCTypes.ExternalProtocolPtrTy);
   
   std::string ProtocolName("\01l_OBJC_PROTOCOL_REFERENCE_$_");