emit a specific error when the input file is empty. This fixes
authorChris Lattner <sabre@nondot.org>
Wed, 9 Feb 2011 16:46:02 +0000 (16:46 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 9 Feb 2011 16:46:02 +0000 (16:46 +0000)
an annoyance of mine when working on tests: if the input .ll file
is broken, opt outputs an error and generates an empty file.  FileCheck
then emits its "ooh I couldn't find the first CHECK line, scanning
from ..." which obfuscates the actual problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125193 91177308-0d34-0410-b5e6-96231b3b80d8

utils/FileCheck/FileCheck.cpp

index a4aa693448ba6ad489250c4ad4ec4a7c2e50dc74..5d4cb0c0c5f074511b16b096a87e833f89f5aec1 100644 (file)
@@ -659,6 +659,11 @@ int main(int argc, char **argv) {
   }
   MemoryBuffer *F = File.take();
 
+  if (F->getBufferSize() == 0) {
+    errs() << "FileCheck error: '" << InputFilename << "' is empty.\n";
+    return 1;
+  }
+  
   // Remove duplicate spaces in the input file if requested.
   if (!NoCanonicalizeWhiteSpace)
     F = CanonicalizeInputFile(F);