Prevent output of bytecode to std::cout unless the --force flag is given.
authorReid Spencer <rspencer@reidspencer.com>
Sun, 2 Jan 2005 00:08:46 +0000 (00:08 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 2 Jan 2005 00:08:46 +0000 (00:08 +0000)
This prevents bytecode splats with usage like: cat file.ll | llvm-as -

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

tools/llvm-as/llvm-as.cpp

index eb77a33165be2644854a5bcb3884e6863ff336c4..ef1602b6a72c7ee7e84ad67fe9c736838da101bf 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/Bytecode/Writer.h"
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/SystemUtils.h"
 #include "llvm/System/Signals.h"
 #include <fstream>
 #include <iostream>
@@ -124,7 +125,9 @@ int main(int argc, char **argv) {
       return 1;
     }
    
-    WriteBytecodeToFile(M.get(), *Out, !NoCompress);
+    if (Force || !CheckBytecodeOutputToConsole(Out,true)) {
+      WriteBytecodeToFile(M.get(), *Out, !NoCompress);
+    }
   } catch (const ParseException &E) {
     std::cerr << argv[0] << ": " << E.getMessage() << "\n";
     exitCode = 1;