forked from OSchip/llvm-project
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
This commit is contained in:
parent
81857f0bcb
commit
a89c1e3145
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue