Make sure the functions' range is empty before going through it in the LLVM C API test

llvm-svn: 260947
This commit is contained in:
Amaury Sechet 2016-02-16 08:37:01 +00:00
parent 1c3ea77731
commit a0396b8473
2 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,3 @@
; RUN: llvm-as < %s | llvm-dis > %t.orig
; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
; RUN: diff -w %t.orig %t.echo

View File

@ -610,6 +610,11 @@ static void declare_function(LLVMValueRef Src, LLVMModuleRef M) {
static void clone_functions(LLVMModuleRef Src, LLVMModuleRef Dst) {
LLVMValueRef Begin = LLVMGetFirstFunction(Src);
LLVMValueRef End = LLVMGetLastFunction(Src);
if (!Begin) {
if (End != nullptr)
report_fatal_error("Range has an end but no start");
return;
}
// First pass, we declare all function
LLVMValueRef Cur = Begin;