return &getNode(ChooseEdge(TV, InLangs)->ToolName());
}
return &getNode(ChooseEdge(TV, InLangs)->ToolName());
}
-// Build the targets. Command-line options are passed through
-// temporary variables.
-int CompilationGraph::Build (const sys::Path& TempDir) {
-
- InputLanguagesSet InLangs;
-
+// Helper function used by Build().
+// Traverses initial portions of the toolchains (up to the first Join node).
+// This function is also responsible for handling the -x option.
+void CompilationGraph::BuildInitial (InputLanguagesSet& InLangs,
+ const sys::Path& TempDir) {
// This is related to -x option handling.
cl::list<std::string>::const_iterator xIter = Languages.begin(),
xBegin = xIter, xEnd = Languages.end();
// This is related to -x option handling.
cl::list<std::string>::const_iterator xIter = Languages.begin(),
xBegin = xIter, xEnd = Languages.end();
// Pass file through the chain starting at head.
PassThroughGraph(In, N, InLangs, TempDir);
}
// Pass file through the chain starting at head.
PassThroughGraph(In, N, InLangs, TempDir);
}
+}
+
+// Build the targets. Command-line options are passed through
+// temporary variables.
+int CompilationGraph::Build (const sys::Path& TempDir) {
+
+ InputLanguagesSet InLangs;
+
+ // Traverse initial parts of the toolchains and fill in InLangs.
+ BuildInitial(InLangs, TempDir);
std::vector<const Node*> JTV;
TopologicalSortFilterJoinNodes(JTV);
std::vector<const Node*> JTV;
TopologicalSortFilterJoinNodes(JTV);
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/iterator"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/iterator"
-//#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/System/Path.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/System/Path.h"
#include <string>
namespace llvmc {
#include <string>
namespace llvmc {
- typedef std::set<std::string> InputLanguagesSet;
+ typedef llvm::SmallSet<std::string, 5> InputLanguagesSet;
// An edge of the compilation graph.
class Edge : public llvm::RefCountedBaseVPTR<Edge> {
// An edge of the compilation graph.
class Edge : public llvm::RefCountedBaseVPTR<Edge> {
// the given language name. Throws std::runtime_error.
const tools_vector_type& getToolsVector(const std::string& LangName) const;
// 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.
+ // 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;
void PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode,
const InputLanguagesSet& InLangs,
const llvm::sys::Path& TempDir) const;
const std::string* forceLanguage,
InputLanguagesSet& InLangs) const;
const std::string* forceLanguage,
InputLanguagesSet& InLangs) const;
+ // Traverse the initial parts of the toolchains.
+ void BuildInitial(InputLanguagesSet& InLangs,
+ const llvm::sys::Path& TempDir);
+
// Sort the nodes in topological order.
void TopologicalSort(std::vector<const Node*>& Out);
// Call TopologicalSort and filter the resulting list to include
// Sort the nodes in topological order.
void TopologicalSort(std::vector<const Node*>& Out);
// Call TopologicalSort and filter the resulting list to include