aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/TargetMachineC.cpp
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
commit2fee43f9b210859f46fdb279baabb96a61a774af (patch)
tree3447b808cafd24998e91fd85fc1e1ea21091f405 /lib/Target/TargetMachineC.cpp
parent4ef1999d61f955917f86320f3b1c6e3352fd0b49 (diff)
downloadexternal_llvm-2fee43f9b210859f46fdb279baabb96a61a774af.zip
external_llvm-2fee43f9b210859f46fdb279baabb96a61a774af.tar.gz
external_llvm-2fee43f9b210859f46fdb279baabb96a61a774af.tar.bz2
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192878 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetMachineC.cpp')
-rw-r--r--lib/Target/TargetMachineC.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp
index 7419122..9fccfcd 100644
--- a/lib/Target/TargetMachineC.cpp
+++ b/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());