Use Doxygen-style comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50833 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov
2008-05-07 21:50:19 +00:00
parent 1fd2e6d84e
commit 4561ab5d81
8 changed files with 145 additions and 110 deletions

View File

@@ -21,8 +21,11 @@ namespace llvmc {
typedef std::vector<std::string> StringVector;
/// Action - A class that encapsulates a single shell command.
class Action {
/// Command_ - The actual command (for example, 'ls').
std::string Command_;
/// Args_ - Command arguments. Stdout redirection is allowed.
std::vector<std::string> Args_;
public:
Action (const std::string& C,
@@ -30,6 +33,7 @@ namespace llvmc {
: Command_(C), Args_(A)
{}
/// Execute - Executes the represented action.
int Execute() const;
};

View File

@@ -23,7 +23,11 @@ namespace llvmc {
typedef llvm::StringMap<std::string> LanguageMap;
class CompilationGraph;
/// PopulateLanguageMap - The auto-generated function that fills in
/// the language map (map from file extensions to language names).
void PopulateLanguageMap(LanguageMap& language_map);
/// PopulateCompilationGraph - The auto-generated function that
/// populates the compilation graph with nodes and edges.
void PopulateCompilationGraph(CompilationGraph& tools);
}

View File

@@ -33,7 +33,7 @@ extern cl::list<std::string> Languages;
namespace {
// Return the edge with the maximum weight.
/// ChooseEdge - Return the edge with the maximum weight.
template <class C>
const Edge* ChooseEdge(const C& EdgesContainer,
const InputLanguagesSet& InLangs,
@@ -304,8 +304,6 @@ TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out) {
std::back_inserter(Out), NotJoinNode);
}
// Build the targets. Command-line options are accessed through global
// variables.
int CompilationGraph::Build (const sys::Path& TempDir) {
InputLanguagesSet InLangs;

View File

@@ -29,8 +29,9 @@
namespace llvmc {
// A wrapper for StringMap that provides set-like functionality.
// Only insert() and count() methods are used by my code.
/// StringSet - A wrapper for StringMap that provides set-like
/// functionality. Only insert() and count() methods are used by my
/// code.
template <class AllocatorTy = llvm::MallocAllocator>
class StringSet : public llvm::StringMap<char, AllocatorTy> {
typedef llvm::StringMap<char, AllocatorTy> base;
@@ -45,7 +46,7 @@ namespace llvmc {
};
typedef StringSet<> InputLanguagesSet;
// An edge of the compilation graph.
/// Edge - Represents an edge of the compilation graph.
class Edge : public llvm::RefCountedBaseVPTR<Edge> {
public:
Edge(const std::string& T) : ToolName_(T) {}
@@ -57,14 +58,14 @@ namespace llvmc {
std::string ToolName_;
};
// Edges that have no properties are instances of this class.
/// SimpleEdge - An edge that has no properties.
class SimpleEdge : public Edge {
public:
SimpleEdge(const std::string& T) : Edge(T) {}
unsigned Weight(const InputLanguagesSet&) const { return 1; }
};
// A node of the compilation graph.
/// Node - A node (vertex) of the compilation graph.
struct Node {
// A Node holds a list of the outward edges.
typedef llvm::SmallVector<llvm::IntrusiveRefCntPtr<Edge>, 3> container_type;
@@ -86,7 +87,8 @@ namespace llvmc {
iterator EdgesEnd() { return OutEdges.end(); }
const_iterator EdgesEnd() const { return OutEdges.end(); }
// Add an outward edge. Takes ownership of the Edge object.
/// AddEdge - Add an outward edge. Takes ownership of the provided
/// Edge object.
void AddEdge(Edge* E)
{ OutEdges.push_back(llvm::IntrusiveRefCntPtr<Edge>(E)); }
@@ -111,56 +113,57 @@ namespace llvmc {
class NodesIterator;
// The compilation graph itself.
/// CompilationGraph - The compilation graph itself.
class CompilationGraph {
// Main data structure.
/// nodes_map_type - The main data structure.
typedef llvm::StringMap<Node> nodes_map_type;
// These are used to map from language names to tools. (We can
// have several tools associated with each language name, hence
// the need for a vector of Edges.)
/// tools_vector_type, tools_map_type - Data structures used to
/// map from language names to tools. (We can have several tools
/// associated with each language name, hence the need for a
/// vector.)
typedef
llvm::SmallVector<llvm::IntrusiveRefCntPtr<Edge>, 3> tools_vector_type;
typedef llvm::StringMap<tools_vector_type> tools_map_type;
// Map from file extensions to language names.
/// ExtsToLangs - Map from file extensions to language names.
LanguageMap ExtsToLangs;
// Map from language names to lists of tool names.
/// ToolsMap - Map from language names to lists of tool names.
tools_map_type ToolsMap;
// Map from tool names to Tool objects.
/// NodesMap - Map from tool names to Tool objects.
nodes_map_type NodesMap;
public:
CompilationGraph();
// insertVertex - insert a new node into the graph. Takes
// ownership of the object.
/// insertNode - Insert a new node into the graph. Takes
/// ownership of the object.
void insertNode(Tool* T);
// insertEdge - Insert a new edge into the graph. Takes ownership
// of the Edge object.
/// insertEdge - Insert a new edge into the graph. Takes ownership
/// of the Edge object.
void 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.
int Build(llvm::sys::Path const& tempDir);
// Return a reference to the node correponding to the given tool
// name. Throws std::runtime_error.
/// 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;
// 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();
// Write a CompilationGraph.dot file.
/// writeGraph - Write a compilation-graph.dot file.
void writeGraph();
// GraphTraits support
// GraphTraits support.
friend NodesIterator GraphBegin(CompilationGraph*);
friend NodesIterator GraphEnd(CompilationGraph*);
friend void PopulateCompilationGraph(CompilationGraph&);
@@ -168,39 +171,42 @@ namespace llvmc {
private:
// Helper functions.
// Find out which language corresponds to the suffix of this file.
/// getLanguage - Find out which language corresponds to the
/// suffix of this file.
const std::string& getLanguage(const llvm::sys::Path& File) const;
// Return a reference to the list of tool names corresponding to
// the given language name. Throws std::runtime_error.
/// 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;
// Pass the input file through the toolchain starting at StartNode.
/// 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;
// 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) const;
// Traverse the initial parts of the toolchains.
/// BuildInitial - Traverse the initial parts of the toolchains.
void BuildInitial(InputLanguagesSet& InLangs,
const llvm::sys::Path& TempDir);
// Sort the nodes in topological order.
/// TopologicalSort - Sort the nodes in topological order.
void TopologicalSort(std::vector<const Node*>& Out);
// 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.
void TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out);
};
/// GraphTraits support code.
// GraphTraits support code.
// Auxiliary class needed to implement GraphTraits support. Can be
// generalised to something like value_iterator for map-like
// containers.
/// 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<Node>::iterator {
typedef llvm::StringMap<Node>::iterator super;
typedef NodesIterator ThisType;
@@ -227,7 +233,7 @@ namespace llvmc {
}
// Another auxiliary class needed by GraphTraits.
/// NodeChildIterator - Another auxiliary class needed by GraphTraits.
class NodeChildIterator : public bidirectional_iterator<Node, ptrdiff_t> {
typedef NodeChildIterator ThisType;
typedef Node::container_type::iterator iterator;

View File

@@ -26,6 +26,7 @@ namespace llvmc {
typedef std::vector<llvm::sys::Path> PathVector;
/// Tool - A class
class Tool : public llvm::RefCountedBaseVPTR<Tool> {
public:
@@ -46,7 +47,7 @@ namespace llvmc {
virtual bool IsJoin() const = 0;
};
// Join tools have an input file list associated with them.
/// JoinTool - A Tool that has an associated input file list.
class JoinTool : public Tool {
public:
void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }

View File

@@ -48,6 +48,7 @@ cl::opt<bool> ViewGraph("view-graph",
cl::Hidden);
namespace {
/// BuildTargets - A small wrapper for CompilationGraph::Build.
int BuildTargets(CompilationGraph& graph) {
int ret;
sys::Path tempDir(sys::Path::GetTemporaryDirectory());