From f8c430b3da9a9f6ebd9fc070bf409435d65bb4f2 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Fri, 9 Jan 2009 16:16:27 +0000 Subject: Add a --check-graph option to llvmc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61989 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CompilerDriver/CompilationGraph.h | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CompilerDriver/CompilationGraph.h b/include/llvm/CompilerDriver/CompilationGraph.h index 029623f..090ff5f 100644 --- a/include/llvm/CompilerDriver/CompilationGraph.h +++ b/include/llvm/CompilerDriver/CompilationGraph.h @@ -123,6 +123,9 @@ namespace llvmc { public: + typedef nodes_map_type::iterator nodes_iterator; + typedef nodes_map_type::const_iterator const_nodes_iterator; + CompilationGraph(); /// insertNode - Insert a new node into the graph. Takes @@ -137,6 +140,11 @@ namespace llvmc { /// options are passed implicitly as global variables. 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. + int Check(); + /// getNode - Return a reference to the node correponding to the /// given tool name. Throws std::runtime_error. Node& getNode(const std::string& ToolName); @@ -171,7 +179,8 @@ namespace llvmc { const llvm::sys::Path& TempDir, const LanguageMap& LangMap) const; - /// FindToolChain - Find head of the toolchain corresponding to the given file. + /// FindToolChain - Find head of the toolchain corresponding to + /// the given file. const Node* FindToolChain(const llvm::sys::Path& In, const std::string* ForceLanguage, InputLanguagesSet& InLangs, @@ -187,6 +196,18 @@ namespace llvmc { /// TopologicalSortFilterJoinNodes - Call TopologicalSort and /// filter the resulting list to include only Join nodes. void TopologicalSortFilterJoinNodes(std::vector& Out); + + // Functions used to implement Check(). + + /// CheckLanguageNames - Check that output/input language names + /// match for all nodes. + int CheckLanguageNames() const; + /// CheckMultipleDefaultEdges - check that there are no multiple + /// default default edges. + int CheckMultipleDefaultEdges() const; + /// CheckCycles - Check that there are no cycles in the graph. + int CheckCycles(); + }; // GraphTraits support code. @@ -194,8 +215,8 @@ namespace llvmc { /// NodesIterator - Auxiliary class needed to implement GraphTraits /// support. Can be generalised to something like value_iterator /// for map-like containers. - class NodesIterator : public llvm::StringMap::iterator { - typedef llvm::StringMap::iterator super; + class NodesIterator : public CompilationGraph::nodes_iterator { + typedef CompilationGraph::nodes_iterator super; typedef NodesIterator ThisType; typedef Node* pointer; typedef Node& reference; -- cgit v1.1