diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index b431daa958f0b80a16972dae44515f837573b647..0eb624c4187afc2c4b4064e911409c2cd0aeea74 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -747,9 +747,14 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList( std::vector Elements; for (const std::string *iter = Protocols.begin(), *endIter = Protocols.end(); iter != endIter ; iter++) { - llvm::Constant *protocol = ExistingProtocols[*iter]; - if (!protocol) + llvm::Constant *protocol = 0; + llvm::StringMap::iterator value = + ExistingProtocols.find(*iter); + if (value == ExistingProtocols.end()) { protocol = GenerateEmptyProtocol(*iter); + } else { + protocol = value->getValue(); + } llvm::Constant *Ptr = llvm::ConstantExpr::getBitCast(protocol, PtrToInt8Ty); Elements.push_back(Ptr);