Fixed crash when using undefined protocols (GNU runtime).

llvm-svn: 89457
This commit is contained in:
David Chisnall 2009-11-20 14:50:59 +00:00
parent 9e26aac773
commit bc8bdea183
1 changed files with 7 additions and 2 deletions

View File

@ -747,9 +747,14 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList(
std::vector<llvm::Constant*> 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<llvm::Constant*>::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);