aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvmc2
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2008-05-30 06:29:17 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2008-05-30 06:29:17 +0000
commit7329610dfa494864f38e9d99b4eb97898a5c9480 (patch)
tree54d9e2cca2afd7cc71eafc2c338be5aae27f52a0 /tools/llvmc2
parenta7d0ae34fbcc587e4b357f33849c50127a166cf2 (diff)
downloadexternal_llvm-7329610dfa494864f38e9d99b4eb97898a5c9480.zip
external_llvm-7329610dfa494864f38e9d99b4eb97898a5c9480.tar.gz
external_llvm-7329610dfa494864f38e9d99b4eb97898a5c9480.tar.bz2
Add a --save-temps option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc2')
-rw-r--r--tools/llvmc2/CompilationGraph.cpp13
-rw-r--r--tools/llvmc2/CompilationGraph.h2
-rw-r--r--tools/llvmc2/doc/LLVMC-Reference.rst6
-rw-r--r--tools/llvmc2/llvmc.cpp11
4 files changed, 25 insertions, 7 deletions
diff --git a/tools/llvmc2/CompilationGraph.cpp b/tools/llvmc2/CompilationGraph.cpp
index df1f239..9cdcac3 100644
--- a/tools/llvmc2/CompilationGraph.cpp
+++ b/tools/llvmc2/CompilationGraph.cpp
@@ -139,8 +139,17 @@ void CompilationGraph::insertEdge(const std::string& A, Edge* Edg) {
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;
diff --git a/tools/llvmc2/CompilationGraph.h b/tools/llvmc2/CompilationGraph.h
index 7dfe78f..4324c38 100644
--- a/tools/llvmc2/CompilationGraph.h
+++ b/tools/llvmc2/CompilationGraph.h
@@ -79,8 +79,6 @@ namespace llvmc {
{ 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; }
diff --git a/tools/llvmc2/doc/LLVMC-Reference.rst b/tools/llvmc2/doc/LLVMC-Reference.rst
index f2c5a34..9cee46c 100644
--- a/tools/llvmc2/doc/LLVMC-Reference.rst
+++ b/tools/llvmc2/doc/LLVMC-Reference.rst
@@ -76,6 +76,12 @@ configuration files:
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
========================================
diff --git a/tools/llvmc2/llvmc.cpp b/tools/llvmc2/llvmc.cpp
index ba2d70a..e093439 100644
--- a/tools/llvmc2/llvmc.cpp
+++ b/tools/llvmc2/llvmc.cpp
@@ -32,7 +32,6 @@ using namespace llvmc;
// 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>"),
@@ -50,12 +49,17 @@ cl::opt<bool> WriteGraph("write-graph",
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);
@@ -65,7 +69,8 @@ namespace {
throw;
}
- tempDir.eraseFromDisk(true);
+ if (!SaveTemps)
+ tempDir.eraseFromDisk(true);
return ret;
}
}