summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAnders Waldenborg <anders@0x63.nu>2013-10-17 10:25:24 +0000
committerAnders Waldenborg <anders@0x63.nu>2013-10-17 10:25:24 +0000
commita89c1e314545d7a2c079551cee81ca09cfac3160 (patch)
tree65f8b1c181c520ec7c35d351b4d53dedb29e0c14 /llvm/lib
parent81857f0bcb70500cc96281954305730e16a1c046 (diff)
downloadbcm5719-llvm-a89c1e314545d7a2c079551cee81ca09cfac3160.tar.gz
bcm5719-llvm-a89c1e314545d7a2c079551cee81ca09cfac3160.zip
llvm-c: Return NULL from LLVMGetFirstTarget instead of asserting
If no targets are registered, LLVMGetFirstTarget currently fails with an assertion. This patch makes it return NULL instead, similarly to how LLVMGetNextTarget would. Patch by Peter Zotov Differential Revision: http://llvm-reviews.chandlerc.com/D1908 llvm-svn: 192878
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/TargetMachineC.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp
index 741912200da..9fccfcd9e22 100644
--- a/llvm/lib/Target/TargetMachineC.cpp
+++ b/llvm/lib/Target/TargetMachineC.cpp
@@ -60,8 +60,12 @@ inline LLVMTargetRef wrap(const Target * P) {
}
LLVMTargetRef LLVMGetFirstTarget() {
- const Target* target = &*TargetRegistry::begin();
- return wrap(target);
+ if(TargetRegistry::begin() == TargetRegistry::end()) {
+ return NULL;
+ }
+
+ const Target* target = &*TargetRegistry::begin();
+ return wrap(target);
}
LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T) {
return wrap(unwrap(T)->getNext());
OpenPOWER on IntegriCloud