namespace {
sys::Path MakeTempFile(const sys::Path& TempDir, const std::string& BaseName,
const std::string& Suffix) {
- sys::Path Out = TempDir;
- Out.appendComponent(BaseName);
+ sys::Path Out;
+
+ // Make sure we don't end up with path names like '/file.o' if the
+ // TempDir is empty.
+ if (TempDir.empty()) {
+ Out.set(BaseName);
+ }
+ else {
+ Out = TempDir;
+ Out.appendComponent(BaseName);
+ }
Out.appendSuffix(Suffix);
Out.makeUnique(true, NULL);
return Out;
{ OutEdges.push_back(llvm::IntrusiveRefCntPtr<Edge>(E)); }
// Inward edge counter. Used to implement topological sort.
- // TOTHINK: Move the mutable counter back into Tool classes? Makes
- // us more const-correct.
void IncrInEdges() { ++InEdges; }
void DecrInEdges() { --InEdges; }
bool HasNoInEdges() const { return InEdges == 0; }
current directory with the compilation graph description in the
Graphviz format. Hidden option, useful for debugging.
+* ``--save-temps`` - Write temporary files to the current directory
+ and do not delete them on exit. Hidden option, useful for debugging.
+
+* ``--help``, ``--help-hidden``, ``--version`` - These options have
+ their standard meaning.
+
Customizing LLVMC: the compilation graph
========================================
// Built-in command-line options.
// External linkage here is intentional.
-// TOFIX: Add a --keep-temps option.
// TOFIX: Write a 'driver driver' (easier to do as a separate
// executable that drives llvmc2 proper).
cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input file>"),
cl::opt<bool> ViewGraph("view-graph",
cl::desc("Show compilation graph in GhostView"),
cl::Hidden);
+cl::opt<bool> SaveTemps("save-temps",
+ cl::desc("Keep temporary files"),
+ cl::Hidden);
namespace {
/// BuildTargets - A small wrapper for CompilationGraph::Build.
int BuildTargets(CompilationGraph& graph) {
int ret;
- sys::Path tempDir(sys::Path::GetTemporaryDirectory());
+ const sys::Path& tempDir = SaveTemps
+ ? sys::Path("")
+ : sys::Path(sys::Path::GetTemporaryDirectory());
try {
ret = graph.Build(tempDir);
throw;
}
- tempDir.eraseFromDisk(true);
+ if (!SaveTemps)
+ tempDir.eraseFromDisk(true);
return ret;
}
}