mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
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
This commit is contained in:
@ -43,7 +43,7 @@ namespace llvmc {
|
|||||||
}
|
}
|
||||||
bool IsConstructed () { return (Command_.size() != 0);}
|
bool IsConstructed () { return (Command_.size() != 0);}
|
||||||
|
|
||||||
/// Execute - Executes the represented action.
|
/// Execute - Executes the command. Returns -1 on error.
|
||||||
int Execute () const;
|
int Execute () const;
|
||||||
bool StopCompilation () const { return StopCompilation_; }
|
bool StopCompilation () const { return StopCompilation_; }
|
||||||
const std::string& OutFile() { return OutFile_; }
|
const std::string& OutFile() { return OutFile_; }
|
||||||
|
@ -132,28 +132,28 @@ namespace llvmc {
|
|||||||
void insertNode(Tool* T);
|
void insertNode(Tool* T);
|
||||||
|
|
||||||
/// insertEdge - Insert a new edge into the graph. Takes ownership
|
/// 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);
|
int insertEdge(const std::string& A, Edge* E);
|
||||||
|
|
||||||
/// Build - Build target(s) from the input file set. Command-line
|
/// Build - Build target(s) from the input file set. Command-line options
|
||||||
/// options are passed implicitly as global variables.
|
/// 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);
|
int Build(llvm::sys::Path const& TempDir, const LanguageMap& LangMap);
|
||||||
|
|
||||||
/// Check - Check the compilation graph for common errors like
|
/// Check - Check the compilation graph for common errors like cycles,
|
||||||
/// cycles, input/output language mismatch and multiple default
|
/// input/output language mismatch and multiple default edges. Prints error
|
||||||
/// edges. Prints error messages and in case it finds any errors.
|
/// messages and in case it finds any errors.
|
||||||
int Check();
|
int Check();
|
||||||
|
|
||||||
/// getNode - Return a reference to the node correponding to the
|
/// getNode - Return a reference to the node corresponding to the given tool
|
||||||
/// given tool name. Throws std::runtime_error.
|
/// name. Returns 0 on error.
|
||||||
Node* getNode(const std::string& ToolName);
|
Node* getNode(const std::string& ToolName);
|
||||||
const Node* getNode(const std::string& ToolName) const;
|
const Node* getNode(const std::string& ToolName) const;
|
||||||
|
|
||||||
/// viewGraph - This function is meant for use from the debugger.
|
/// viewGraph - This function is meant for use from the debugger. You can
|
||||||
/// You can just say 'call G->viewGraph()' and a ghostview window
|
/// just say 'call G->viewGraph()' and a ghostview window should pop up from
|
||||||
/// should pop up from the program, displaying the compilation
|
/// the program, displaying the compilation graph. This depends on there
|
||||||
/// graph. This depends on there being a 'dot' and 'gv' program
|
/// being a 'dot' and 'gv' program in your path.
|
||||||
/// in your path.
|
|
||||||
void viewGraph();
|
void viewGraph();
|
||||||
|
|
||||||
/// writeGraph - Write Graphviz .dot source file to the current direcotry.
|
/// writeGraph - Write Graphviz .dot source file to the current direcotry.
|
||||||
@ -167,12 +167,11 @@ namespace llvmc {
|
|||||||
// Helper functions.
|
// Helper functions.
|
||||||
|
|
||||||
/// getToolsVector - Return a reference to the list of tool names
|
/// getToolsVector - Return a reference to the list of tool names
|
||||||
/// corresponding to the given language name. Throws
|
/// corresponding to the given language name. Returns 0 on error.
|
||||||
/// std::runtime_error.
|
|
||||||
const tools_vector_type* getToolsVector(const std::string& LangName) const;
|
const tools_vector_type* getToolsVector(const std::string& LangName) const;
|
||||||
|
|
||||||
/// PassThroughGraph - Pass the input file through the toolchain
|
/// PassThroughGraph - Pass the input file through the toolchain starting at
|
||||||
/// starting at StartNode.
|
/// StartNode.
|
||||||
int PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode,
|
int PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode,
|
||||||
const InputLanguagesSet& InLangs,
|
const InputLanguagesSet& InLangs,
|
||||||
const llvm::sys::Path& TempDir,
|
const llvm::sys::Path& TempDir,
|
||||||
@ -185,26 +184,32 @@ namespace llvmc {
|
|||||||
InputLanguagesSet& InLangs,
|
InputLanguagesSet& InLangs,
|
||||||
const LanguageMap& LangMap) const;
|
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,
|
int BuildInitial(InputLanguagesSet& InLangs,
|
||||||
const llvm::sys::Path& TempDir,
|
const llvm::sys::Path& TempDir,
|
||||||
const LanguageMap& LangMap);
|
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);
|
int TopologicalSort(std::vector<const Node*>& Out);
|
||||||
/// TopologicalSortFilterJoinNodes - Call TopologicalSort and
|
/// TopologicalSortFilterJoinNodes - Call TopologicalSort and filter the
|
||||||
/// filter the resulting list to include only Join nodes.
|
/// resulting list to include only Join nodes. Returns non-zero value on
|
||||||
|
/// error.
|
||||||
int TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out);
|
int TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out);
|
||||||
|
|
||||||
// Functions used to implement Check().
|
// Functions used to implement Check().
|
||||||
|
|
||||||
/// CheckLanguageNames - Check that output/input language names
|
/// CheckLanguageNames - Check that output/input language names match for
|
||||||
/// match for all nodes.
|
/// all nodes. Returns non-zero value on error (number of errors
|
||||||
|
/// encountered).
|
||||||
int CheckLanguageNames() const;
|
int CheckLanguageNames() const;
|
||||||
/// CheckMultipleDefaultEdges - check that there are no multiple
|
/// CheckMultipleDefaultEdges - check that there are no multiple default
|
||||||
/// default default edges.
|
/// default edges. Returns non-zero value on error (number of errors
|
||||||
|
/// encountered).
|
||||||
int CheckMultipleDefaultEdges() const;
|
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();
|
int CheckCycles();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -38,6 +38,8 @@ namespace llvmc {
|
|||||||
|
|
||||||
virtual ~Tool() {}
|
virtual ~Tool() {}
|
||||||
|
|
||||||
|
/// GenerateAction - Generate an Action given particular command-line
|
||||||
|
/// options. Returns non-zero value on error.
|
||||||
virtual int GenerateAction (Action& Out,
|
virtual int GenerateAction (Action& Out,
|
||||||
const PathVector& inFiles,
|
const PathVector& inFiles,
|
||||||
const bool HasChildren,
|
const bool HasChildren,
|
||||||
@ -45,6 +47,8 @@ namespace llvmc {
|
|||||||
const InputLanguagesSet& InLangs,
|
const InputLanguagesSet& InLangs,
|
||||||
const LanguageMap& LangMap) const = 0;
|
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,
|
virtual int GenerateAction (Action& Out,
|
||||||
const llvm::sys::Path& inFile,
|
const llvm::sys::Path& inFile,
|
||||||
const bool HasChildren,
|
const bool HasChildren,
|
||||||
|
@ -139,7 +139,7 @@ void CompilationGraph::insertNode(Tool* V) {
|
|||||||
int CompilationGraph::insertEdge(const std::string& A, Edge* Edg) {
|
int CompilationGraph::insertEdge(const std::string& A, Edge* Edg) {
|
||||||
Node* B = getNode(Edg->ToolName());
|
Node* B = getNode(Edg->ToolName());
|
||||||
if (B == 0)
|
if (B == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
if (A == "root") {
|
if (A == "root") {
|
||||||
const char** InLangs = B->ToolPtr->InputLanguages();
|
const char** InLangs = B->ToolPtr->InputLanguages();
|
||||||
@ -150,7 +150,7 @@ int CompilationGraph::insertEdge(const std::string& A, Edge* Edg) {
|
|||||||
else {
|
else {
|
||||||
Node* N = getNode(A);
|
Node* N = getNode(A);
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
N->AddEdge(Edg);
|
N->AddEdge(Edg);
|
||||||
}
|
}
|
||||||
@ -193,11 +193,11 @@ int CompilationGraph::PassThroughGraph (const sys::Path& InFile,
|
|||||||
|
|
||||||
const Edge* Edg = ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name());
|
const Edge* Edg = ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name());
|
||||||
if (Edg == 0)
|
if (Edg == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
CurNode = getNode(Edg->ToolName());
|
CurNode = getNode(Edg->ToolName());
|
||||||
if (CurNode == 0)
|
if (CurNode == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
In = CurAction.OutFile();
|
In = CurAction.OutFile();
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ int CompilationGraph::BuildInitial (InputLanguagesSet& InLangs,
|
|||||||
// Find the toolchain corresponding to this file.
|
// Find the toolchain corresponding to this file.
|
||||||
const Node* N = FindToolChain(In, xLanguage, InLangs, LangMap);
|
const Node* N = FindToolChain(In, xLanguage, InLangs, LangMap);
|
||||||
if (N == 0)
|
if (N == 0)
|
||||||
return -1;
|
return 1;
|
||||||
// Pass file through the chain starting at head.
|
// Pass file through the chain starting at head.
|
||||||
if (int ret = PassThroughGraph(In, N, InLangs, TempDir, LangMap))
|
if (int ret = PassThroughGraph(In, N, InLangs, TempDir, LangMap))
|
||||||
return ret;
|
return ret;
|
||||||
@ -310,7 +310,7 @@ int CompilationGraph::TopologicalSort(std::vector<const Node*>& Out) {
|
|||||||
|
|
||||||
Node* Root = getNode("root");
|
Node* Root = getNode("root");
|
||||||
if (Root == 0)
|
if (Root == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
Q.push(Root);
|
Q.push(Root);
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ int CompilationGraph::TopologicalSort(std::vector<const Node*>& Out) {
|
|||||||
EB != EE; ++EB) {
|
EB != EE; ++EB) {
|
||||||
Node* B = getNode((*EB)->ToolName());
|
Node* B = getNode((*EB)->ToolName());
|
||||||
if (B == 0)
|
if (B == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
B->DecrInEdges();
|
B->DecrInEdges();
|
||||||
if (B->HasNoInEdges())
|
if (B->HasNoInEdges())
|
||||||
@ -389,11 +389,11 @@ int CompilationGraph::Build (const sys::Path& TempDir,
|
|||||||
|
|
||||||
const Edge* Edg = ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name());
|
const Edge* Edg = ChooseEdge(CurNode->OutEdges, InLangs, CurNode->Name());
|
||||||
if (Edg == 0)
|
if (Edg == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
const Node* NextNode = getNode(Edg->ToolName());
|
const Node* NextNode = getNode(Edg->ToolName());
|
||||||
if (NextNode == 0)
|
if (NextNode == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
if (int ret = PassThroughGraph(sys::Path(CurAction.OutFile()), NextNode,
|
if (int ret = PassThroughGraph(sys::Path(CurAction.OutFile()), NextNode,
|
||||||
InLangs, TempDir, LangMap)) {
|
InLangs, TempDir, LangMap)) {
|
||||||
@ -417,7 +417,7 @@ int CompilationGraph::CheckLanguageNames() const {
|
|||||||
EB != EE; ++EB) {
|
EB != EE; ++EB) {
|
||||||
const Node* N2 = this->getNode((*EB)->ToolName());
|
const Node* N2 = this->getNode((*EB)->ToolName());
|
||||||
if (N2 == 0)
|
if (N2 == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
if (!N2->ToolPtr) {
|
if (!N2->ToolPtr) {
|
||||||
++ret;
|
++ret;
|
||||||
@ -497,7 +497,7 @@ int CompilationGraph::CheckCycles() {
|
|||||||
|
|
||||||
Node* Root = getNode("root");
|
Node* Root = getNode("root");
|
||||||
if (Root == 0)
|
if (Root == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
Q.push(Root);
|
Q.push(Root);
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ int CompilationGraph::CheckCycles() {
|
|||||||
EB != EE; ++EB) {
|
EB != EE; ++EB) {
|
||||||
Node* B = getNode((*EB)->ToolName());
|
Node* B = getNode((*EB)->ToolName());
|
||||||
if (B == 0)
|
if (B == 0)
|
||||||
return -1;
|
return 1;
|
||||||
|
|
||||||
B->DecrInEdges();
|
B->DecrInEdges();
|
||||||
if (B->HasNoInEdges())
|
if (B->HasNoInEdges())
|
||||||
@ -539,19 +539,19 @@ int CompilationGraph::Check () {
|
|||||||
// Check that output/input language names match.
|
// Check that output/input language names match.
|
||||||
ret = this->CheckLanguageNames();
|
ret = this->CheckLanguageNames();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return 1;
|
||||||
errs += ret;
|
errs += ret;
|
||||||
|
|
||||||
// Check for multiple default edges.
|
// Check for multiple default edges.
|
||||||
ret = this->CheckMultipleDefaultEdges();
|
ret = this->CheckMultipleDefaultEdges();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return 1;
|
||||||
errs += ret;
|
errs += ret;
|
||||||
|
|
||||||
// Check for cycles.
|
// Check for cycles.
|
||||||
ret = this->CheckCycles();
|
ret = this->CheckCycles();
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return 1;
|
||||||
errs += ret;
|
errs += ret;
|
||||||
|
|
||||||
return errs;
|
return errs;
|
||||||
@ -617,7 +617,7 @@ int CompilationGraph::writeGraph(const std::string& OutputFilename) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PrintError("Error opening file '" + OutputFilename + "' for writing!");
|
PrintError("Error opening file '" + OutputFilename + "' for writing!");
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -30,7 +30,9 @@ namespace {
|
|||||||
|
|
||||||
std::stringstream* GlobalTimeLog;
|
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.
|
// The --temp-dir option.
|
||||||
if (!TempDirname.empty()) {
|
if (!TempDirname.empty()) {
|
||||||
tempDir = TempDirname;
|
tempDir = TempDirname;
|
||||||
@ -53,20 +55,20 @@ namespace {
|
|||||||
std::string ErrMsg;
|
std::string ErrMsg;
|
||||||
if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) {
|
if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) {
|
||||||
PrintError(ErrMsg);
|
PrintError(ErrMsg);
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
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 BuildTargets(CompilationGraph& graph, const LanguageMap& langMap) {
|
||||||
int ret;
|
int ret;
|
||||||
sys::Path tempDir;
|
sys::Path tempDir;
|
||||||
bool toDelete = (SaveTemps == SaveTempsEnum::Unset);
|
bool toDelete = (SaveTemps == SaveTempsEnum::Unset);
|
||||||
|
|
||||||
if (int ret = getTempDir(tempDir))
|
if (int ret = GetTempDir(tempDir))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = graph.Build(tempDir, langMap);
|
ret = graph.Build(tempDir, langMap);
|
||||||
|
@ -1960,7 +1960,7 @@ struct ActionHandlingCallbackBase
|
|||||||
<< "PrintError(\""
|
<< "PrintError(\""
|
||||||
<< (d.getNumArgs() >= 1 ? InitPtrToString(d.getArg(0)) : "Unknown error!")
|
<< (d.getNumArgs() >= 1 ? InitPtrToString(d.getArg(0)) : "Unknown error!")
|
||||||
<< "\");\n";
|
<< "\");\n";
|
||||||
O.indent(IndentLevel) << "return -1;\n";
|
O.indent(IndentLevel) << "return 1;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void onWarningDag(const DagInit& d,
|
void onWarningDag(const DagInit& d,
|
||||||
|
Reference in New Issue
Block a user