15 #include "llvm/Config/config.h"
23 cl::desc(
"Execute graph viewer in the background. Creates tmp file litter."));
26 std::string Str(Label);
27 for (
unsigned i = 0; i != Str.length(); ++i)
30 Str.insert(Str.begin()+i,
'\\');
35 Str.insert(Str.begin()+i,
' ');
40 if (i+1 != Str.length())
43 case '|':
case '{':
case '}':
44 Str.erase(Str.begin()+i);
continue;
50 Str.insert(Str.begin()+i,
'\\');
60 static const int NumColors = 20;
61 static const char* Colors[NumColors] = {
62 "aaaaaa",
"aa0000",
"00aa00",
"aa5500",
"0055ff",
"aa00aa",
"00aaaa",
63 "555555",
"ff5555",
"55ff55",
"ffff55",
"5555ff",
"ff55ff",
"55ffff",
64 "ffaaaa",
"aaffaa",
"ffffaa",
"aaaaff",
"ffaaff",
"aaffff"};
65 return Colors[ColorNumber % NumColors];
77 errs() <<
"Writing '" << Filename <<
"'... ";
78 return Filename.
str();
84 StringRef Filename,
bool wait, std::string &ErrMsg) {
87 errs() <<
"Error: " << ErrMsg <<
"\n";
92 errs() <<
" done. \n";
96 errs() <<
"Remember to erase graph file: " << Filename.
str() <<
"\n";
103 std::string Filename = FilenameRef;
107 std::string Graphviz(LLVM_PATH_GRAPHVIZ);
109 std::vector<const char*> args;
110 args.push_back(Graphviz.c_str());
111 args.push_back(Filename.c_str());
114 errs() <<
"Running 'Graphviz' program... ";
119 std::vector<const char*> args;
120 args.push_back(LLVM_PATH_XDOT);
121 args.push_back(Filename.c_str());
133 errs() <<
"Running 'xdot.py' program... ";
137 #elif (HAVE_GV && (HAVE_DOT || HAVE_FDP || HAVE_NEATO || \
138 HAVE_TWOPI || HAVE_CIRCO))
139 std::string PSFilename = Filename +
".ps";
144 prog = LLVM_PATH_CIRCO;
147 prog = LLVM_PATH_TWOPI;
150 prog = LLVM_PATH_NEATO;
153 prog = LLVM_PATH_FDP;
156 prog = LLVM_PATH_DOT;
162 prog = LLVM_PATH_DOT;
166 prog = LLVM_PATH_FDP;
170 prog = LLVM_PATH_NEATO;
174 prog = LLVM_PATH_TWOPI;
178 prog = LLVM_PATH_CIRCO;
181 std::vector<const char*> args;
182 args.push_back(prog.c_str());
183 args.push_back(
"-Tps");
184 args.push_back(
"-Nfontname=Courier");
185 args.push_back(
"-Gsize=7.5,10");
186 args.push_back(Filename.c_str());
187 args.push_back(
"-o");
188 args.push_back(PSFilename.c_str());
191 errs() <<
"Running '" << prog <<
"' program... ";
196 std::string gv(LLVM_PATH_GV);
198 args.push_back(gv.c_str());
199 args.push_back(PSFilename.c_str());
200 args.push_back(
"--spartan");
208 std::string dotty(LLVM_PATH_DOTTY);
210 std::vector<const char*> args;
211 args.push_back(dotty.c_str());
212 args.push_back(Filename.c_str());
216 #if defined (__MINGW32__) || defined (_WINDOWS)
219 errs() <<
"Running 'dotty' program... ";
static cl::opt< bool > ViewBackground("view-background", cl::Hidden, cl::desc("Execute graph viewer in the background. Creates tmp file litter."))
static bool LLVM_ATTRIBUTE_UNUSED ExecGraphViewer(StringRef ExecPath, std::vector< const char * > &args, StringRef Filename, bool wait, std::string &ErrMsg)
std::string str() const
str - Get the contents as an std::string.
int ExecuteAndWait(StringRef Program, const char **args, const char **env=0, const StringRef **redirects=0, unsigned secondsToWait=0, unsigned memoryLimit=0, std::string *ErrMsg=0, bool *ExecutionFailed=0)
ProcessInfo ExecuteNoWait(StringRef Program, const char **args, const char **env=0, const StringRef **redirects=0, unsigned memoryLimit=0, std::string *ErrMsg=0, bool *ExecutionFailed=0)
std::string EscapeString(const std::string &Label)
void DisplayGraph(StringRef Filename, bool wait=true, GraphProgram::Name program=GraphProgram::DOT)
#define LLVM_ATTRIBUTE_UNUSED
error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath)
Create a file in the system temporary directory.
std::string createGraphFilename(const Twine &Name, int &FD)
StringRef getColorString(unsigned NodeNumber)
Get a color string for this node number. Simply round-robin selects from a reasonable number of color...
std::string message() const
StringRef str() const
Explicit conversion to StringRef.
error_code remove(const Twine &path, bool &existed)
Remove path. Equivalent to POSIX remove().