about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--test/regression/2016-08-12-empty-file.c10
-rw-r--r--tools/klee/main.cpp7
2 files changed, 14 insertions, 3 deletions
diff --git a/test/regression/2016-08-12-empty-file.c b/test/regression/2016-08-12-empty-file.c
new file mode 100644
index 00000000..b9650278
--- /dev/null
+++ b/test/regression/2016-08-12-empty-file.c
@@ -0,0 +1,10 @@
+// RUN: %llvmgcc %s -emit-llvm -g -O0 -c -o %t.bc
+// RUN: rm -rf %t.klee-out
+// RUN: not %klee --output-dir=%t.klee-out %t.bc >%t1.log 2>&1
+// RUN: FileCheck -input-file=%t1.log -check-prefix=CHECK-MAIN-NOT-FOUND %s
+// RUN: rm -rf %t.klee-out
+// RUN: rm -rf %t1.log
+// RUN: not %klee --output-dir=%t.klee-out --posix-runtime %t.bc >%t1.log 2>&1
+// RUN: FileCheck -input-file=%t1.log -check-prefix=CHECK-MAIN-NOT-FOUND %s
+
+// CHECK-MAIN-NOT-FOUND: 'main' function not found in module.
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 3e469a6e..2143c95b 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -669,6 +669,9 @@ static int initEnv(Module *mainModule) {
   */
 
   Function *mainFn = mainModule->getFunction(EntryPoint);
+  if (!mainFn) {
+    klee_error("'%s' function not found in module.", EntryPoint.c_str());
+  }
 
   if (mainFn->arg_size() < 2) {
     klee_error("Cannot handle ""--posix-runtime"" when main() has less than two arguments.\n");
@@ -1276,7 +1279,6 @@ int main(int argc, char **argv, char **envp) {
   }
 #endif
 
-
   if (WithPOSIXRuntime) {
     int r = initEnv(mainModule);
     if (r != 0)
@@ -1331,8 +1333,7 @@ int main(int argc, char **argv, char **envp) {
   // locale and other data and then calls main.
   Function *mainFn = mainModule->getFunction(EntryPoint);
   if (!mainFn) {
-    llvm::errs() << "'" << EntryPoint << "' function not found in module.\n";
-    return -1;
+    klee_error("'%s' function not found in module.", EntryPoint.c_str());
   }
 
   // FIXME: Change me to std types.