aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Chisnall <csdavec@swan.ac.uk>2009-11-20 14:50:59 +0000
committerDavid Chisnall <csdavec@swan.ac.uk>2009-11-20 14:50:59 +0000
commitff80fabfa42d4aadbbaab4d61fa518d80b5a981a (patch)
treecfac6b14cb5a302b6604d080b420ae3a431b297b
parentd5dc9f34ef2288ace0003e1fee011cc9e7d2d040 (diff)
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
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp9
1 files changed, 7 insertions, 2 deletions
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<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);