aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2010-07-23 03:42:55 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2010-07-23 03:42:55 +0000
commitb7b316d8d4fb4e4bad5d4efe34a6256abdaf187c (patch)
treece0ecf3b2a6b2b169c9fd2b43f9af97838e99bbc /include
parent1cc1dfcb1ef766ac33e1b33aa892b6981538535b (diff)
downloadexternal_llvm-b7b316d8d4fb4e4bad5d4efe34a6256abdaf187c.tar.gz
external_llvm-b7b316d8d4fb4e4bad5d4efe34a6256abdaf187c.tar.bz2
external_llvm-b7b316d8d4fb4e4bad5d4efe34a6256abdaf187c.zip
Get rid of exceptions in llvmc.
llvmc can be now compiled with llvm-gcc on Windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109215 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CompilerDriver/Action.h12
-rw-r--r--include/llvm/CompilerDriver/CompilationGraph.h34
-rw-r--r--include/llvm/CompilerDriver/Error.h24
-rw-r--r--include/llvm/CompilerDriver/Plugin.h8
-rw-r--r--include/llvm/CompilerDriver/Tool.h36
5 files changed, 60 insertions, 54 deletions
diff --git a/include/llvm/CompilerDriver/Action.h b/include/llvm/CompilerDriver/Action.h
index 70141393ce..4ff6fd9c02 100644
--- a/include/llvm/CompilerDriver/Action.h
+++ b/include/llvm/CompilerDriver/Action.h
@@ -34,10 +34,14 @@ namespace llvmc {
std::string OutFile_;
public:
- Action (const std::string& C, const StrVector& A,
- bool S, const std::string& O)
- : Command_(C), Args_(A), StopCompilation_(S), OutFile_(O)
- {}
+ void Construct (const std::string& C, const StrVector& A,
+ bool S, const std::string& O) {
+ Command_ = C;
+ Args_ = A;
+ StopCompilation_ = S;
+ OutFile_ = O;
+ }
+ bool IsConstructed () { return (Command_.size() != 0);}
/// Execute - Executes the represented action.
int Execute () const;
diff --git a/include/llvm/CompilerDriver/CompilationGraph.h b/include/llvm/CompilerDriver/CompilationGraph.h
index ba6ff4714c..9f2e50e304 100644
--- a/include/llvm/CompilerDriver/CompilationGraph.h
+++ b/include/llvm/CompilerDriver/CompilationGraph.h
@@ -36,7 +36,7 @@ namespace llvmc {
public:
/// GetLanguage - Find the language name corresponding to a given file.
- const std::string& GetLanguage(const llvm::sys::Path&) const;
+ const std::string* GetLanguage(const llvm::sys::Path&) const;
};
/// Edge - Represents an edge of the compilation graph.
@@ -133,7 +133,7 @@ namespace llvmc {
/// insertEdge - Insert a new edge into the graph. Takes ownership
/// of the Edge object.
- void 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
/// options are passed implicitly as global variables.
@@ -146,8 +146,8 @@ namespace llvmc {
/// getNode - Return a reference to the node correponding to the
/// given tool name. Throws std::runtime_error.
- Node& getNode(const std::string& ToolName);
- const Node& getNode(const std::string& ToolName) const;
+ 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
@@ -157,7 +157,7 @@ namespace llvmc {
void viewGraph();
/// writeGraph - Write Graphviz .dot source file to the current direcotry.
- void writeGraph(const std::string& OutputFilename);
+ int writeGraph(const std::string& OutputFilename);
// GraphTraits support.
friend NodesIterator GraphBegin(CompilationGraph*);
@@ -169,14 +169,14 @@ namespace llvmc {
/// getToolsVector - Return a reference to the list of tool names
/// corresponding to the given language name. Throws
/// 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
/// starting at StartNode.
- void PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode,
- const InputLanguagesSet& InLangs,
- const llvm::sys::Path& TempDir,
- const LanguageMap& LangMap) const;
+ int PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode,
+ const InputLanguagesSet& InLangs,
+ const llvm::sys::Path& TempDir,
+ const LanguageMap& LangMap) const;
/// FindToolChain - Find head of the toolchain corresponding to
/// the given file.
@@ -186,15 +186,15 @@ namespace llvmc {
const LanguageMap& LangMap) const;
/// BuildInitial - Traverse the initial parts of the toolchains.
- void BuildInitial(InputLanguagesSet& InLangs,
- const llvm::sys::Path& TempDir,
- const LanguageMap& LangMap);
+ int BuildInitial(InputLanguagesSet& InLangs,
+ const llvm::sys::Path& TempDir,
+ const LanguageMap& LangMap);
/// TopologicalSort - Sort the nodes in topological order.
- void TopologicalSort(std::vector<const Node*>& Out);
+ int TopologicalSort(std::vector<const Node*>& Out);
/// TopologicalSortFilterJoinNodes - Call TopologicalSort and
/// filter the resulting list to include only Join nodes.
- void TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out);
+ int TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out);
// Functions used to implement Check().
@@ -270,7 +270,7 @@ namespace llvmc {
}
inline pointer operator*() const {
- return &OwningGraph->getNode((*EdgeIter)->ToolName());
+ return OwningGraph->getNode((*EdgeIter)->ToolName());
}
inline pointer operator->() const {
return this->operator*();
@@ -301,7 +301,7 @@ namespace llvm {
typedef llvmc::NodeChildIterator ChildIteratorType;
static NodeType* getEntryNode(GraphType* G) {
- return &G->getNode("root");
+ return G->getNode("root");
}
static ChildIteratorType child_begin(NodeType* N) {
diff --git a/include/llvm/CompilerDriver/Error.h b/include/llvm/CompilerDriver/Error.h
index fa678cfbfb..0233929616 100644
--- a/include/llvm/CompilerDriver/Error.h
+++ b/include/llvm/CompilerDriver/Error.h
@@ -7,29 +7,27 @@
//
//===----------------------------------------------------------------------===//
//
-// Exception classes for llvmc.
+// Error handling.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H
#define LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H
-#include <stdexcept>
+#include "llvm/Support/raw_ostream.h"
-namespace llvmc {
+#include <string>
- /// error_code - This gets thrown during the compilation process if a tool
- /// invocation returns a non-zero exit code.
- class error_code: public std::runtime_error {
- int Code_;
- public:
- error_code (int c)
- : std::runtime_error("Tool returned error code"), Code_(c)
- {}
+namespace llvmc {
- int code() const { return Code_; }
- };
+ inline void PrintError(const char* Err) {
+ extern const char* ProgramName;
+ llvm::errs() << ProgramName << ": " << Err << '\n';
+ }
+ inline void PrintError(const std::string& Err) {
+ PrintError(Err.c_str());
+ }
}
#endif // LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H
diff --git a/include/llvm/CompilerDriver/Plugin.h b/include/llvm/CompilerDriver/Plugin.h
index e9a20488a0..75fd9162df 100644
--- a/include/llvm/CompilerDriver/Plugin.h
+++ b/include/llvm/CompilerDriver/Plugin.h
@@ -32,15 +32,15 @@ namespace llvmc {
/// PreprocessOptions - The auto-generated function that performs various
/// consistency checks on options (like ensuring that -O2 and -O3 are not
/// used together).
- virtual void PreprocessOptions() const = 0;
+ virtual int PreprocessOptions() const = 0;
/// PopulateLanguageMap - The auto-generated function that fills in
/// the language map (map from file extensions to language names).
- virtual void PopulateLanguageMap(LanguageMap&) const = 0;
+ virtual int PopulateLanguageMap(LanguageMap&) const = 0;
/// PopulateCompilationGraph - The auto-generated function that
/// populates the compilation graph with nodes and edges.
- virtual void PopulateCompilationGraph(CompilationGraph&) const = 0;
+ virtual int PopulateCompilationGraph(CompilationGraph&) const = 0;
/// Needed to avoid a compiler warning.
virtual ~BasePlugin() {}
@@ -68,7 +68,7 @@ namespace llvmc {
/// RunInitialization - Calls PreprocessOptions, PopulateLanguageMap and
/// PopulateCompilationGraph methods of all plugins. This populates the
/// global language map and the compilation graph.
- void RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const;
+ int RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const;
private:
// noncopyable
diff --git a/include/llvm/CompilerDriver/Tool.h b/include/llvm/CompilerDriver/Tool.h
index 85d1690bcf..d064a03eeb 100644
--- a/include/llvm/CompilerDriver/Tool.h
+++ b/include/llvm/CompilerDriver/Tool.h
@@ -38,17 +38,19 @@ namespace llvmc {
virtual ~Tool() {}
- virtual Action GenerateAction (const PathVector& inFiles,
- bool HasChildren,
- const llvm::sys::Path& TempDir,
- const InputLanguagesSet& InLangs,
- const LanguageMap& LangMap) const = 0;
-
- virtual Action GenerateAction (const llvm::sys::Path& inFile,
- bool HasChildren,
- const llvm::sys::Path& TempDir,
- const InputLanguagesSet& InLangs,
- const LanguageMap& LangMap) const = 0;
+ virtual int GenerateAction (Action& Out,
+ const PathVector& inFiles,
+ const bool HasChildren,
+ const llvm::sys::Path& TempDir,
+ const InputLanguagesSet& InLangs,
+ const LanguageMap& LangMap) const = 0;
+
+ virtual int GenerateAction (Action& Out,
+ const llvm::sys::Path& inFile,
+ const bool HasChildren,
+ const llvm::sys::Path& TempDir,
+ const InputLanguagesSet& InLangs,
+ const LanguageMap& LangMap) const = 0;
virtual const char* Name() const = 0;
virtual const char** InputLanguages() const = 0;
@@ -74,11 +76,13 @@ namespace llvmc {
void ClearJoinList() { JoinList_.clear(); }
bool JoinListEmpty() const { return JoinList_.empty(); }
- Action GenerateAction(bool HasChildren,
- const llvm::sys::Path& TempDir,
- const InputLanguagesSet& InLangs,
- const LanguageMap& LangMap) const {
- return GenerateAction(JoinList_, HasChildren, TempDir, InLangs, LangMap);
+ int GenerateAction(Action& Out,
+ const bool HasChildren,
+ const llvm::sys::Path& TempDir,
+ const InputLanguagesSet& InLangs,
+ const LanguageMap& LangMap) const {
+ return GenerateAction(Out, JoinList_, HasChildren, TempDir, InLangs,
+ LangMap);
}
// We shouldn't shadow base class's version of GenerateAction.
using Tool::GenerateAction;