diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 06:18:16 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 06:18:16 +0000 |
commit | ffcf3a1a699a63bec6d70b250adbe99effab852c (patch) | |
tree | e52d55106efa0db4d52ebb462a2dcfa4050a8b40 /tools | |
parent | aa3bb17fcca35b9720dd2c39d47443d001990513 (diff) | |
download | external_llvm-ffcf3a1a699a63bec6d70b250adbe99effab852c.zip external_llvm-ffcf3a1a699a63bec6d70b250adbe99effab852c.tar.gz external_llvm-ffcf3a1a699a63bec6d70b250adbe99effab852c.tar.bz2 |
Make it possible to have multiple input languages for a single tool.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51742 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvmc2/CompilationGraph.cpp | 33 | ||||
-rw-r--r-- | tools/llvmc2/Tool.h | 2 | ||||
-rw-r--r-- | tools/llvmc2/examples/Clang.td | 6 |
3 files changed, 26 insertions, 15 deletions
diff --git a/tools/llvmc2/CompilationGraph.cpp b/tools/llvmc2/CompilationGraph.cpp index bf34b33..92f3104 100644 --- a/tools/llvmc2/CompilationGraph.cpp +++ b/tools/llvmc2/CompilationGraph.cpp @@ -115,16 +115,18 @@ void CompilationGraph::insertNode(Tool* V) { } } -void CompilationGraph::insertEdge(const std::string& A, Edge* E) { - Node& B = getNode(E->ToolName()); +void CompilationGraph::insertEdge(const std::string& A, Edge* Edg) { + Node& B = getNode(Edg->ToolName()); if (A == "root") { - const std::string& InputLanguage = B.ToolPtr->InputLanguage(); - ToolsMap[InputLanguage].push_back(IntrusiveRefCntPtr<Edge>(E)); - NodesMap["root"].AddEdge(E); + const StrVector& InputLanguages = B.ToolPtr->InputLanguages(); + for (StrVector::const_iterator B = InputLanguages.begin(), + E = InputLanguages.end(); B != E; ++B) + ToolsMap[*B].push_back(IntrusiveRefCntPtr<Edge>(Edg)); + NodesMap["root"].AddEdge(Edg); } else { Node& N = getNode(A); - N.AddEdge(E); + N.AddEdge(Edg); } // Increase the inward edge counter. B.IncrInEdges(); @@ -381,10 +383,23 @@ namespace llvm { template<typename EdgeIter> static std::string getEdgeSourceLabel(const Node* N, EdgeIter I) { - if (N->ToolPtr) + if (N->ToolPtr) { return N->ToolPtr->OutputLanguage(); - else - return I->ToolPtr->InputLanguage(); + } + else { + const StrVector& InputLanguages = I->ToolPtr->InputLanguages(); + std::string ret; + + for (StrVector::const_iterator B = InputLanguages.begin(), + E = InputLanguages.end(); B != E; ++B) { + if (llvm::next(B) != E) + ret += *B + ", "; + else + ret += *B; + } + + return ret; + } } }; diff --git a/tools/llvmc2/Tool.h b/tools/llvmc2/Tool.h index 294c6fb..ec9d154 100644 --- a/tools/llvmc2/Tool.h +++ b/tools/llvmc2/Tool.h @@ -43,7 +43,7 @@ namespace llvmc { const InputLanguagesSet& InLangs) const = 0; virtual const char* Name() const = 0; - virtual const char* InputLanguage() const = 0; + virtual StrVector InputLanguages() const = 0; virtual const char* OutputLanguage() const = 0; virtual const char* OutputSuffix() const = 0; diff --git a/tools/llvmc2/examples/Clang.td b/tools/llvmc2/examples/Clang.td index 45ee638..c067372 100644 --- a/tools/llvmc2/examples/Clang.td +++ b/tools/llvmc2/examples/Clang.td @@ -4,12 +4,8 @@ include "Common.td" -// TOFIX: It should be possible to use a string list in the 'in_language' -// tool property. There should be also an 'in_language' test in the -// 'case' construct. - def clang : Tool< -[(in_language "c"), +[(in_language ["c", "c++", "objective-c"]), (out_language "llvm-bitcode"), (output_suffix "bc"), (cmd_line (case (switch_on "E"), "clang -E $INFILE -o $OUTFILE", |