//
//===----------------------------------------------------------------------===//
+#include "llvm/CompilerDriver/BuiltinOptions.h"
#include "llvm/CompilerDriver/CompilationGraph.h"
#include "llvm/CompilerDriver/Error.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/GraphWriter.h"
+#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cstring>
-#include <iostream>
#include <iterator>
#include <limits>
#include <queue>
using namespace llvm;
using namespace llvmc;
-extern cl::list<std::string> InputFilenames;
-extern cl::list<std::string> Languages;
-
namespace llvmc {
const std::string& LanguageMap::GetLanguage(const sys::Path& File) const {
LanguageMap::const_iterator Lang = this->find(File.getSuffix());
if (Lang == this->end())
- throw std::runtime_error("Unknown suffix: " + File.getSuffix());
+ throw std::runtime_error(("Unknown suffix: " + File.getSuffix()).str());
return Lang->second;
}
}
if (!N2.ToolPtr) {
++ret;
- std::cerr << "Error: there is an edge from '" << N1.ToolPtr->Name()
- << "' back to the root!\n\n";
+ errs() << "Error: there is an edge from '" << N1.ToolPtr->Name()
+ << "' back to the root!\n\n";
continue;
}
if (!eq) {
++ret;
- std::cerr << "Error: Output->input language mismatch in the edge '" <<
- N1.ToolPtr->Name() << "' -> '" << N2.ToolPtr->Name() << "'!\n";
-
- std::cerr << "Expected one of { ";
+ errs() << "Error: Output->input language mismatch in the edge '"
+ << N1.ToolPtr->Name() << "' -> '" << N2.ToolPtr->Name()
+ << "'!\n"
+ << "Expected one of { ";
InLangs = N2.ToolPtr->InputLanguages();
for (;*InLangs; ++InLangs) {
- std::cerr << '\'' << *InLangs << (*(InLangs+1) ? "', " : "'");
+ errs() << '\'' << *InLangs << (*(InLangs+1) ? "', " : "'");
}
- std::cerr << " }, but got '" << OutLang << "'!\n\n";
+ errs() << " }, but got '" << OutLang << "'!\n\n";
}
}
}
else if (EdgeWeight == MaxWeight) {
++ret;
- std::cerr
- << "Error: there are multiple maximal edges stemming from the '"
- << N.ToolPtr->Name() << "' node!\n\n";
+ errs() << "Error: there are multiple maximal edges stemming from the '"
+ << N.ToolPtr->Name() << "' node!\n\n";
break;
}
}
}
if (deleted != NodesMap.size()) {
- std::cerr << "Error: there are cycles in the compilation graph!\n"
- << "Try inspecting the diagram produced by "
- "'llvmc --view-graph'.\n\n";
+ errs() << "Error: there are cycles in the compilation graph!\n"
+ << "Try inspecting the diagram produced by "
+ << "'llvmc --view-graph'.\n\n";
return 1;
}
struct DOTGraphTraits<llvmc::CompilationGraph*>
: public DefaultDOTGraphTraits
{
+ DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
template<typename GraphType>
- static std::string getNodeLabel(const Node* N, const GraphType&,
- bool ShortNames)
+ static std::string getNodeLabel(const Node* N, const GraphType&)
{
if (N->ToolPtr)
if (N->ToolPtr->IsJoin())
}
void CompilationGraph::writeGraph(const std::string& OutputFilename) {
- std::ofstream O(OutputFilename.c_str());
+ std::string ErrorInfo;
+ raw_fd_ostream O(OutputFilename.c_str(), ErrorInfo);
- if (O.good()) {
- std::cerr << "Writing '"<< OutputFilename << "' file...";
+ if (ErrorInfo.empty()) {
+ errs() << "Writing '"<< OutputFilename << "' file...";
llvm::WriteGraph(O, this);
- std::cerr << "done.\n";
- O.close();
+ errs() << "done.\n";
}
else {
throw std::runtime_error("Error opening file '" + OutputFilename