diff options
Diffstat (limited to 'contrib/llvm/lib/CompilerDriver')
-rw-r--r-- | contrib/llvm/lib/CompilerDriver/Action.cpp | 26 | ||||
-rw-r--r-- | contrib/llvm/lib/CompilerDriver/CompilationGraph.cpp | 66 | ||||
-rw-r--r-- | contrib/llvm/lib/CompilerDriver/Main.cpp | 9 | ||||
-rw-r--r-- | contrib/llvm/lib/CompilerDriver/Tool.cpp | 6 |
4 files changed, 63 insertions, 44 deletions
diff --git a/contrib/llvm/lib/CompilerDriver/Action.cpp b/contrib/llvm/lib/CompilerDriver/Action.cpp index 0be8049..a8d625c 100644 --- a/contrib/llvm/lib/CompilerDriver/Action.cpp +++ b/contrib/llvm/lib/CompilerDriver/Action.cpp @@ -14,11 +14,12 @@ #include "llvm/CompilerDriver/Action.h" #include "llvm/CompilerDriver/BuiltinOptions.h" #include "llvm/CompilerDriver/Error.h" +#include "llvm/CompilerDriver/Main.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/SystemUtils.h" -#include "llvm/System/Program.h" -#include "llvm/System/TimeValue.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/TimeValue.h" #include <stdexcept> #include <string> @@ -28,7 +29,6 @@ using namespace llvmc; namespace llvmc { -extern int Main(int argc, char** argv); extern const char* ProgramName; } @@ -53,15 +53,19 @@ namespace { #endif } - int ExecuteProgram (const std::string& name, - const StrVector& args) { - sys::Path prog = sys::Program::FindProgramByName(name); + int ExecuteProgram (const std::string& name, const StrVector& args) { + sys::Path prog(name); - if (prog.isEmpty()) { - prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main); - if (prog.isEmpty()) { - PrintError("Can't find program '" + name + "'"); - return -1; + if (sys::path::is_relative(prog.str())) { + prog = PrependMainExecutablePath(name, ProgramName, + (void *)(intptr_t)&Main); + + if (!prog.canExecute()) { + prog = sys::Program::FindProgramByName(name); + if (prog.isEmpty()) { + PrintError("Can't find program '" + name + "'"); + return -1; + } } } if (!prog.canExecute()) { diff --git a/contrib/llvm/lib/CompilerDriver/CompilationGraph.cpp b/contrib/llvm/lib/CompilerDriver/CompilationGraph.cpp index d0c0e15..33c6566 100644 --- a/contrib/llvm/lib/CompilerDriver/CompilationGraph.cpp +++ b/contrib/llvm/lib/CompilerDriver/CompilationGraph.cpp @@ -32,7 +32,8 @@ using namespace llvmc; namespace llvmc { const std::string* LanguageMap::GetLanguage(const sys::Path& File) const { - StringRef suf = File.getSuffix(); + // Remove the '.'. + StringRef suf = sys::path::extension(File.str()).substr(1); LanguageMap::const_iterator Lang = this->find(suf.empty() ? "*empty*" : suf); if (Lang == this->end()) { @@ -218,10 +219,11 @@ FindToolChain(const sys::Path& In, const std::string* ForceLanguage, InputLanguagesSet& InLangs, const LanguageMap& LangMap) const { // Determine the input language. - const std::string* InLang = LangMap.GetLanguage(In); + const std::string* InLang = (ForceLanguage ? ForceLanguage + : LangMap.GetLanguage(In)); if (InLang == 0) return 0; - const std::string& InLanguage = (ForceLanguage ? *ForceLanguage : *InLang); + const std::string& InLanguage = *InLang; // Add the current input language to the input language set. InLangs.insert(InLanguage); @@ -439,13 +441,17 @@ int CompilationGraph::CheckLanguageNames() const { continue; } - const char* OutLang = N1.ToolPtr->OutputLanguage(); + const char** OutLangs = N1.ToolPtr->OutputLanguages(); const char** InLangs = N2->ToolPtr->InputLanguages(); bool eq = false; - for (;*InLangs; ++InLangs) { - if (std::strcmp(OutLang, *InLangs) == 0) { - eq = true; - break; + const char* OutLang = 0; + for (;*OutLangs; ++OutLangs) { + OutLang = *OutLangs; + for (;*InLangs; ++InLangs) { + if (std::strcmp(OutLang, *InLangs) == 0) { + eq = true; + break; + } } } @@ -480,7 +486,7 @@ int CompilationGraph::CheckMultipleDefaultEdges() const { for (const_nodes_iterator B = this->NodesMap.begin(), E = this->NodesMap.end(); B != E; ++B) { const Node& N = B->second; - int MaxWeight = 0; + int MaxWeight = -1024; // Ignore the root node. if (!N.ToolPtr) @@ -572,6 +578,26 @@ int CompilationGraph::Check () { // Code related to graph visualization. +namespace { + +std::string SquashStrArray (const char** StrArr) { + std::string ret; + + for (; *StrArr; ++StrArr) { + if (*(StrArr + 1)) { + ret += *StrArr; + ret += ", "; + } + else { + ret += *StrArr; + } + } + + return ret; +} + +} // End anonymous namespace. + namespace llvm { template <> struct DOTGraphTraits<llvmc::CompilationGraph*> @@ -586,7 +612,8 @@ namespace llvm { if (N->ToolPtr->IsJoin()) return N->Name() + "\n (join" + (N->HasChildren() ? ")" - : std::string(": ") + N->ToolPtr->OutputLanguage() + ')'); + : std::string(": ") + + SquashStrArray(N->ToolPtr->OutputLanguages()) + ')'); else return N->Name(); else @@ -596,28 +623,15 @@ namespace llvm { template<typename EdgeIter> static std::string getEdgeSourceLabel(const Node* N, EdgeIter I) { if (N->ToolPtr) { - return N->ToolPtr->OutputLanguage(); + return SquashStrArray(N->ToolPtr->OutputLanguages()); } else { - const char** InLangs = I->ToolPtr->InputLanguages(); - std::string ret; - - for (; *InLangs; ++InLangs) { - if (*(InLangs + 1)) { - ret += *InLangs; - ret += ", "; - } - else { - ret += *InLangs; - } - } - - return ret; + return SquashStrArray(I->ToolPtr->InputLanguages()); } } }; -} +} // End namespace llvm int CompilationGraph::writeGraph(const std::string& OutputFilename) { std::string ErrorInfo; diff --git a/contrib/llvm/lib/CompilerDriver/Main.cpp b/contrib/llvm/lib/CompilerDriver/Main.cpp index 0a6613a..7120027 100644 --- a/contrib/llvm/lib/CompilerDriver/Main.cpp +++ b/contrib/llvm/lib/CompilerDriver/Main.cpp @@ -16,8 +16,9 @@ #include "llvm/CompilerDriver/CompilationGraph.h" #include "llvm/CompilerDriver/Error.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/System/Path.h" +#include "llvm/Support/Path.h" #include <sstream> #include <string> @@ -43,15 +44,15 @@ namespace { return 0; } else if (SaveTemps == SaveTempsEnum::Obj && !OutputFilename.empty()) { - tempDir = OutputFilename; - tempDir = tempDir.getDirname(); + tempDir = sys::path::parent_path(OutputFilename); } else { // SaveTemps == Cwd --> use current dir (leave tempDir empty). return 0; } - if (!tempDir.exists()) { + bool Exists; + if (llvm::sys::fs::exists(tempDir.str(), Exists) || !Exists) { std::string ErrMsg; if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) { PrintError(ErrMsg); diff --git a/contrib/llvm/lib/CompilerDriver/Tool.cpp b/contrib/llvm/lib/CompilerDriver/Tool.cpp index c8488b2..876759a 100644 --- a/contrib/llvm/lib/CompilerDriver/Tool.cpp +++ b/contrib/llvm/lib/CompilerDriver/Tool.cpp @@ -15,7 +15,7 @@ #include "llvm/CompilerDriver/Tool.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/System/Path.h" +#include "llvm/Support/Path.h" #include <algorithm> @@ -61,7 +61,7 @@ sys::Path Tool::OutFilename(const sys::Path& In, Out.appendSuffix(OutputSuffix); } else { - Out.set(In.getBasename()); + Out.set(sys::path::stem(In.str())); Out.appendSuffix(OutputSuffix); } } @@ -69,7 +69,7 @@ sys::Path Tool::OutFilename(const sys::Path& In, if (IsJoin()) Out = MakeTempFile(TempDir, "tmp", OutputSuffix); else - Out = MakeTempFile(TempDir, In.getBasename(), OutputSuffix); + Out = MakeTempFile(TempDir, sys::path::stem(In.str()), OutputSuffix); } return Out; } |