// tools' manual page (docs/CommandGuide/html/llvmc.html) or run the tool with
// the --help option.
//
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
#include "CompilerDriver.h"
#include "Configuration.h"
using namespace llvm;
namespace {
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== PHASE OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
cl::opt<CompilerDriver::Phases> FinalPhase(cl::Optional,
cl::desc("Choose final phase of compilation:"),
cl::init(CompilerDriver::LINKING),
)
);
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== OPTIMIZATION OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
cl::opt<CompilerDriver::OptimizationLevels> OptLevel(cl::ZeroOrMore,
cl::desc("Choose level of optimization to apply:"),
cl::init(CompilerDriver::OPT_FAST_COMPILE),
)
);
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== TOOL OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
cl::list<std::string> PreprocessorToolOpts("Tpre", cl::ZeroOrMore,
cl::desc("Pass specific options to the pre-processor"),
cl::desc("Specify path to find llvmc sub-tools"),
cl::value_desc("dir"));
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== INPUT OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
cl::list<std::string> LibPaths("L", cl::Prefix,
cl::desc("Specify a library search path"), cl::value_desc("dir"));
cl::desc("Specify a pre-processor symbol to define"),
cl::value_desc("symbol"));
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== OUTPUT OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
cl::opt<std::string> OutputFilename("o",
cl::desc("Override output filename"), cl::value_desc("file"));
cl::value_desc("file"),
cl::desc("Print the full path for the option's value"));
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== INFORMATION OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
cl::opt<bool> DryRun("dry-run", cl::Optional, cl::init(false),
cl::desc("Do everything but perform the compilation actions"));
cl::opt<bool> ShowStats("stats", cl::Optional, cl::init(false),
cl::desc("Print statistics accumulated during optimization"));
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== ADVANCED OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
static cl::opt<std::string> ConfigDir("config-dir", cl::Optional,
cl::desc("Specify configuration directory to override defaults"),
static cl::opt<bool> KeepTemps("keep-temps", cl::Optional,
cl::desc("Don't delete temporary files created by llvmc"));
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== POSITIONAL OPTIONS
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
static cl::list<std::string> Files(cl::Positional, cl::ZeroOrMore,
cl::desc("[Sources/objects/libraries]"));
cl::desc("Specify the source language for subsequent files"),
cl::value_desc("language"));
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
//=== GetFileType - determine type of a file
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
const std::string GetFileType(const std::string& fname, unsigned pos) {
static std::vector<std::string>::iterator langIt = Languages.begin();
static std::string CurrLang = "";
if (KeepTemps) flags |= CompilerDriver::KEEP_TEMPS_FLAG;
if (ShowStats) flags |= CompilerDriver::SHOW_STATS_FLAG;
if (TimeActions) flags |= CompilerDriver::TIME_ACTIONS_FLAG;
- if (TimePassesIsEnabled) flags |= CompilerDriver::TIME_PASSES_FLAG;
if (StripOutput) flags |= CompilerDriver::STRIP_OUTPUT_FLAG;
CD->setDriverFlags(flags);
if (filePos != 0 && (libPos == 0 || filePos < libPos)) {
// Add a source file
- InpList.push_back(std::make_pair(*fileIt,
+ InpList.push_back(std::make_pair(*fileIt,
GetFileType(*fileIt, filePos)));
++fileIt;
} else if ( libPos != 0 && (filePos == 0 || libPos < filePos) ) {
}
// Tell the driver to do its thing
- int result = CD->execute(InpList, sys::Path(OutputFilename));
+ std::string ErrMsg;
+ int result = CD->execute(InpList, sys::Path(OutputFilename), ErrMsg);
if (result != 0) {
- throw std::string("Error executing actions. Terminated.");
+ std::cerr << argv[0] << ": " << ErrMsg << '\n';
return result;
}