[llvm] r260947 - Make sure the functions' range is empty before going through it in the LLVM C API test

Amaury Sechet via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 00:37:16 PST 2016


Author: deadalnix
Date: Tue Feb 16 02:37:01 2016
New Revision: 260947

URL: http://llvm.org/viewvc/llvm-project?rev=260947&view=rev
Log:
Make sure the functions' range is empty before going through it in the LLVM C API test

Added:
    llvm/trunk/test/Bindings/llvm-c/empty.ll
Modified:
    llvm/trunk/tools/llvm-c-test/echo.cpp

Added: llvm/trunk/test/Bindings/llvm-c/empty.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/llvm-c/empty.ll?rev=260947&view=auto
==============================================================================
--- llvm/trunk/test/Bindings/llvm-c/empty.ll (added)
+++ llvm/trunk/test/Bindings/llvm-c/empty.ll Tue Feb 16 02:37:01 2016
@@ -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

Modified: llvm/trunk/tools/llvm-c-test/echo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-c-test/echo.cpp?rev=260947&r1=260946&r2=260947&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-c-test/echo.cpp (original)
+++ llvm/trunk/tools/llvm-c-test/echo.cpp Tue Feb 16 02:37:01 2016
@@ -610,6 +610,11 @@ static void declare_function(LLVMValueRe
 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;




More information about the llvm-commits mailing list