From: David Chisnall Date: Fri, 20 Nov 2009 14:50:59 +0000 (+0000) Subject: Fixed crash when using undefined protocols (GNU runtime). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff80fabfa42d4aadbbaab4d61fa518d80b5a981a;p=clang Fixed crash when using undefined protocols (GNU runtime). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89457 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index b431daa958..0eb624c418 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/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);