From 0bd4dbad3d4c369394fac428d0eecd04cbc4444f Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Fri, 30 May 2008 18:48:52 +0000 Subject: Add a --dry-run option to llvmc2. Patch by Holger Schurig. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51781 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvmc2/Action.cpp | 8 ++++++-- tools/llvmc2/llvmc.cpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'tools/llvmc2') diff --git a/tools/llvmc2/Action.cpp b/tools/llvmc2/Action.cpp index 183dd81..0841626 100644 --- a/tools/llvmc2/Action.cpp +++ b/tools/llvmc2/Action.cpp @@ -22,6 +22,7 @@ using namespace llvm; using namespace llvmc; +extern cl::opt DryRun; extern cl::opt VerboseMode; namespace { @@ -65,10 +66,13 @@ namespace { } int llvmc::Action::Execute() const { - if (VerboseMode) { + if (DryRun || VerboseMode) { std::cerr << Command_ << " "; std::for_each(Args_.begin(), Args_.end(), print_string); std::cerr << '\n'; } - return ExecuteProgram(Command_, Args_); + if (DryRun) + return 0; + else + return ExecuteProgram(Command_, Args_); } diff --git a/tools/llvmc2/llvmc.cpp b/tools/llvmc2/llvmc.cpp index e093439..9a2b27f 100644 --- a/tools/llvmc2/llvmc.cpp +++ b/tools/llvmc2/llvmc.cpp @@ -41,6 +41,8 @@ cl::opt OutputFilename("o", cl::desc("Output file name"), cl::list Languages("x", cl::desc("Specify the language of the following input files"), cl::ZeroOrMore); +cl::opt DryRun("dry-run", + cl::desc("only pretend to run commands")); cl::opt VerboseMode("v", cl::desc("Enable verbose mode")); cl::opt WriteGraph("write-graph", -- cgit v1.1