[llvm-commits] [llvm] r109499 - in /llvm/trunk: include/llvm/CompilerDriver/Action.h include/llvm/CompilerDriver/CompilationGraph.h include/llvm/CompilerDriver/Tool.h lib/CompilerDriver/CompilationGraph.cpp lib/CompilerDriver/Main.cpp utils/TableGen/LLVMCConfigurationEmitter.cpp

Mikhail Glushenkov foldr at codedgers.com
Tue Jul 27 04:19:36 PDT 2010


Author: foldr
Date: Tue Jul 27 06:19:36 2010
New Revision: 109499

URL: http://llvm.org/viewvc/llvm-project?rev=109499&view=rev
Log:
Return -1 only on failure to execute a program.

Also fix some comments.

Modified:
    llvm/trunk/include/llvm/CompilerDriver/Action.h
    llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h
    llvm/trunk/include/llvm/CompilerDriver/Tool.h
    llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp
    llvm/trunk/lib/CompilerDriver/Main.cpp
    llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp

Modified: llvm/trunk/include/llvm/CompilerDriver/Action.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Action.h?rev=109499&r1=109498&r2=109499&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CompilerDriver/Action.h (original)
+++ llvm/trunk/include/llvm/CompilerDriver/Action.h Tue Jul 27 06:19:36 2010
@@ -43,7 +43,7 @@
     }
     bool IsConstructed () { return (Command_.size() != 0);}
 
-    /// Execute - Executes the represented action.
+    /// Execute - Executes the command. Returns -1 on error.
     int Execute () const;
     bool StopCompilation () const { return StopCompilation_; }
     const std::string& OutFile() { return OutFile_; }

Modified: llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h?rev=109499&r1=109498&r2=109499&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h (original)
+++ llvm/trunk/include/llvm/CompilerDriver/CompilationGraph.h Tue Jul 27 06:19:36 2010
@@ -132,28 +132,28 @@
     void insertNode(Tool* T);
 
     /// insertEdge - Insert a new edge into the graph. Takes ownership
-    /// of the Edge object.
+    /// of the Edge object. Returns non-zero value on error.
     int insertEdge(const std::string& A, Edge* E);
 
-    /// Build - Build target(s) from the input file set. Command-line
-    /// options are passed implicitly as global variables.
+    /// Build - Build target(s) from the input file set. Command-line options
+    /// are passed implicitly as global variables. Returns non-zero value on
+    /// error (usually the failed program's exit code).
     int Build(llvm::sys::Path const& TempDir, const LanguageMap& LangMap);
 
-    /// Check - Check the compilation graph for common errors like
-    /// cycles, input/output language mismatch and multiple default
-    /// edges. Prints error messages and in case it finds any errors.
+    /// Check - Check the compilation graph for common errors like cycles,
+    /// input/output language mismatch and multiple default edges. Prints error
+    /// messages and in case it finds any errors.
     int Check();
 
-    /// getNode - Return a reference to the node correponding to the
-    /// given tool name. Throws std::runtime_error.
+    /// getNode - Return a reference to the node corresponding to the given tool
+    /// name. Returns 0 on error.
     Node* getNode(const std::string& ToolName);
     const Node* getNode(const std::string& ToolName) const;
 
-    /// viewGraph - This function is meant for use from the debugger.
-    /// You can just say 'call G->viewGraph()' and a ghostview window
-    /// should pop up from the program, displaying the compilation
-    /// graph. This depends on there being a 'dot' and 'gv' program
-    /// in your path.
+    /// viewGraph - This function is meant for use from the debugger. You can
+    /// just say 'call G->viewGraph()' and a ghostview window should pop up from
+    /// the program, displaying the compilation graph. This depends on there
+    /// being a 'dot' and 'gv' program in your path.
     void viewGraph();
 
     /// writeGraph - Write Graphviz .dot source file to the current direcotry.
@@ -167,12 +167,11 @@
     // Helper functions.
 
     /// getToolsVector - Return a reference to the list of tool names
-    /// corresponding to the given language name. Throws
-    /// std::runtime_error.
+    /// corresponding to the given language name. Returns 0 on error.
     const tools_vector_type* getToolsVector(const std::string& LangName) const;
 
-    /// PassThroughGraph - Pass the input file through the toolchain
-    /// starting at StartNode.
+    /// PassThroughGraph - Pass the input file through the toolchain starting at
+    /// StartNode.
     int PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode,
                           const InputLanguagesSet& InLangs,
                           const llvm::sys::Path& TempDir,
@@ -185,26 +184,32 @@
                               InputLanguagesSet& InLangs,
                               const LanguageMap& LangMap) const;
 
-    /// BuildInitial - Traverse the initial parts of the toolchains.
+    /// BuildInitial - Traverse the initial parts of the toolchains. Returns
+    /// non-zero value on error.
     int BuildInitial(InputLanguagesSet& InLangs,
                      const llvm::sys::Path& TempDir,
                      const LanguageMap& LangMap);
 
-    /// TopologicalSort - Sort the nodes in topological order.
+    /// TopologicalSort - Sort the nodes in topological order. Returns non-zero
+    /// value on error.
     int TopologicalSort(std::vector<const Node*>& Out);
-    /// TopologicalSortFilterJoinNodes - Call TopologicalSort and
-    /// filter the resulting list to include only Join nodes.
+    /// TopologicalSortFilterJoinNodes - Call TopologicalSort and filter the
+    /// resulting list to include only Join nodes. Returns non-zero value on
+    /// error.
     int TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out);
 
     // Functions used to implement Check().
 
-    /// CheckLanguageNames - Check that output/input language names
-    /// match for all nodes.
+    /// CheckLanguageNames - Check that output/input language names match for
+    /// all nodes. Returns non-zero value on error (number of errors
+    /// encountered).
     int CheckLanguageNames() const;
-    /// CheckMultipleDefaultEdges - check that there are no multiple
-    /// default default edges.
+    /// CheckMultipleDefaultEdges - check that there are no multiple default
+    /// default edges. Returns non-zero value on error (number of errors
+    /// encountered).
     int CheckMultipleDefaultEdges() const;
-    /// CheckCycles - Check that there are no cycles in the graph.
+    /// CheckCycles - Check that there are no cycles in the graph. Returns
+    /// non-zero value on error (number of errors encountered).
     int CheckCycles();
 
   };

Modified: llvm/trunk/include/llvm/CompilerDriver/Tool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Tool.h?rev=109499&r1=109498&r2=109499&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CompilerDriver/Tool.h (original)
+++ llvm/trunk/include/llvm/CompilerDriver/Tool.h Tue Jul 27 06:19:36 2010
@@ -38,6 +38,8 @@
 
     virtual ~Tool() {}
 
+    /// GenerateAction - Generate an Action given particular command-line
+    /// options. Returns non-zero value on error.
     virtual int GenerateAction (Action& Out,
                                 const PathVector& inFiles,
                                 const bool HasChildren,
@@ -45,6 +47,8 @@
                                 const InputLanguagesSet& InLangs,
                                 const LanguageMap& LangMap) const = 0;
 
+    /// GenerateAction - Generate an Action given particular command-line
+    /// options. Returns non-zero value on error.
     virtual int GenerateAction (Action& Out,
                                 const llvm::sys::Path& inFile,
                                 const bool HasChildren,

Modified: llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp?rev=109499&r1=109498&r2=109499&view=diff
==============================================================================
--- llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp Tue Jul 27 06:19:36 2010
@@ -139,7 +139,7 @@
 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 @@
   else {
     Node* N = getNode(A);
     if (N == 0)
-      return -1;
+      return 1;
 
     N->AddEdge(Edg);
   }
@@ -193,11 +193,11 @@
 
     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 @@
     // 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 @@
 
   Node* Root = getNode("root");
   if (Root == 0)
-    return -1;
+    return 1;
 
   Q.push(Root);
 
@@ -322,7 +322,7 @@
          EB != EE; ++EB) {
       Node* B = getNode((*EB)->ToolName());
       if (B == 0)
-        return -1;
+        return 1;
 
       B->DecrInEdges();
       if (B->HasNoInEdges())
@@ -389,11 +389,11 @@
 
     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 @@
            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 @@
 
   Node* Root = getNode("root");
   if (Root == 0)
-    return -1;
+    return 1;
 
   Q.push(Root);
 
@@ -513,7 +513,7 @@
          EB != EE; ++EB) {
       Node* B = getNode((*EB)->ToolName());
       if (B == 0)
-        return -1;
+        return 1;
 
       B->DecrInEdges();
       if (B->HasNoInEdges())
@@ -539,19 +539,19 @@
   // 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 @@
   }
   else {
     PrintError("Error opening file '" + OutputFilename + "' for writing!");
-    return -1;
+    return 1;
   }
 
   return 0;

Modified: llvm/trunk/lib/CompilerDriver/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=109499&r1=109498&r2=109499&view=diff
==============================================================================
--- llvm/trunk/lib/CompilerDriver/Main.cpp (original)
+++ llvm/trunk/lib/CompilerDriver/Main.cpp Tue Jul 27 06:19:36 2010
@@ -30,7 +30,9 @@
 
   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 @@
       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);

Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=109499&r1=109498&r2=109499&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Jul 27 06:19:36 2010
@@ -1960,7 +1960,7 @@
       << "PrintError(\""
       << (d.getNumArgs() >= 1 ? InitPtrToString(d.getArg(0)) : "Unknown error!")
       << "\");\n";
-    O.indent(IndentLevel) << "return -1;\n";
+    O.indent(IndentLevel) << "return 1;\n";
   }
 
   void onWarningDag(const DagInit& d,





More information about the llvm-commits mailing list