diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2010-07-27 11:19:36 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2010-07-27 11:19:36 +0000 |
commit | 67d985ffb2d02941dd4e34ecea3f3b8c0fcfaf4f (patch) | |
tree | c7414f5ee29f8837a3feffc91f156f30ece6a3a3 /lib/CompilerDriver | |
parent | 978bb87f8871b953d159c2846b379bc93be27972 (diff) |
Return -1 only on failure to execute a program.
Also fix some comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CompilerDriver')
-rw-r--r-- | lib/CompilerDriver/CompilationGraph.cpp | 32 | ||||
-rw-r--r-- | lib/CompilerDriver/Main.cpp | 10 |
2 files changed, 22 insertions, 20 deletions
diff --git a/lib/CompilerDriver/CompilationGraph.cpp b/lib/CompilerDriver/CompilationGraph.cpp index 4e953cbe11..9ea69c129f 100644 --- a/lib/CompilerDriver/CompilationGraph.cpp +++ b/lib/CompilerDriver/CompilationGraph.cpp @@ -139,7 +139,7 @@ void CompilationGraph::insertNode(Tool* V) { int CompilationGraph::insertEdge(const std::string& A, Edge* Edg) { Node* B = getNode(Edg->ToolName()); if (B == 0) - return -1; + return 1; if (A == "root") { const char** InLangs = B->ToolPtr->InputLanguages(); @@ -150,7 +150,7 @@ int CompilationGraph::insertEdge(const std::string& A, Edge* Edg) { else { Node* N = getNode(A); if (N == 0) - return -1; + return 1; N->AddEdge(Edg); } @@ -193,11 +193,11 @@ int CompilationGraph::PassThroughGraph (const sys::Path& InFile, const Edge* Edg = ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name()); if (Edg == 0) - return -1; + return 1; CurNode = getNode(Edg->ToolName()); if (CurNode == 0) - return -1; + return 1; In = CurAction.OutFile(); } @@ -295,7 +295,7 @@ int CompilationGraph::BuildInitial (InputLanguagesSet& InLangs, // Find the toolchain corresponding to this file. const Node* N = FindToolChain(In, xLanguage, InLangs, LangMap); if (N == 0) - return -1; + return 1; // Pass file through the chain starting at head. if (int ret = PassThroughGraph(In, N, InLangs, TempDir, LangMap)) return ret; @@ -310,7 +310,7 @@ int CompilationGraph::TopologicalSort(std::vector<const Node*>& Out) { Node* Root = getNode("root"); if (Root == 0) - return -1; + return 1; Q.push(Root); @@ -322,7 +322,7 @@ int CompilationGraph::TopologicalSort(std::vector<const Node*>& Out) { EB != EE; ++EB) { Node* B = getNode((*EB)->ToolName()); if (B == 0) - return -1; + return 1; B->DecrInEdges(); if (B->HasNoInEdges()) @@ -389,11 +389,11 @@ int CompilationGraph::Build (const sys::Path& TempDir, const Edge* Edg = ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name()); if (Edg == 0) - return -1; + return 1; const Node* NextNode = getNode(Edg->ToolName()); if (NextNode == 0) - return -1; + return 1; if (int ret = PassThroughGraph(sys::Path(CurAction.OutFile()), NextNode, InLangs, TempDir, LangMap)) { @@ -417,7 +417,7 @@ int CompilationGraph::CheckLanguageNames() const { EB != EE; ++EB) { const Node* N2 = this->getNode((*EB)->ToolName()); if (N2 == 0) - return -1; + return 1; if (!N2->ToolPtr) { ++ret; @@ -497,7 +497,7 @@ int CompilationGraph::CheckCycles() { Node* Root = getNode("root"); if (Root == 0) - return -1; + return 1; Q.push(Root); @@ -513,7 +513,7 @@ int CompilationGraph::CheckCycles() { EB != EE; ++EB) { Node* B = getNode((*EB)->ToolName()); if (B == 0) - return -1; + return 1; B->DecrInEdges(); if (B->HasNoInEdges()) @@ -539,19 +539,19 @@ int CompilationGraph::Check () { // Check that output/input language names match. ret = this->CheckLanguageNames(); if (ret < 0) - return -1; + return 1; errs += ret; // Check for multiple default edges. ret = this->CheckMultipleDefaultEdges(); if (ret < 0) - return -1; + return 1; errs += ret; // Check for cycles. ret = this->CheckCycles(); if (ret < 0) - return -1; + return 1; errs += ret; return errs; @@ -617,7 +617,7 @@ int CompilationGraph::writeGraph(const std::string& OutputFilename) { } else { PrintError("Error opening file '" + OutputFilename + "' for writing!"); - return -1; + return 1; } return 0; diff --git a/lib/CompilerDriver/Main.cpp b/lib/CompilerDriver/Main.cpp index 28b2737f38..898f16d515 100644 --- a/lib/CompilerDriver/Main.cpp +++ b/lib/CompilerDriver/Main.cpp @@ -30,7 +30,9 @@ namespace { std::stringstream* GlobalTimeLog; - int getTempDir(sys::Path& tempDir) { + /// GetTempDir - Get the temporary directory location. Returns non-zero value + /// on error. + int GetTempDir(sys::Path& tempDir) { // The --temp-dir option. if (!TempDirname.empty()) { tempDir = TempDirname; @@ -53,20 +55,20 @@ namespace { std::string ErrMsg; if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) { PrintError(ErrMsg); - return -1; + return 1; } } return 0; } - /// BuildTargets - A small wrapper for CompilationGraph::Build. + /// BuildTargets - A small wrapper for CompilationGraph::Build. Returns non-zero value int BuildTargets(CompilationGraph& graph, const LanguageMap& langMap) { int ret; sys::Path tempDir; bool toDelete = (SaveTemps == SaveTempsEnum::Unset); - if (int ret = getTempDir(tempDir)) + if (int ret = GetTempDir(tempDir)) return ret; ret = graph.Build(tempDir, langMap); |