Small PostDominatorTree improvements

* Do not SEGFAULT if tree entryNode() is NULL
 * Print function names in dotty printer

llvm-svn: 90130
This commit is contained in:
Tobias Grosser 2009-11-30 12:06:37 +00:00
parent 6cf9fe9d69
commit 38b3077d08
2 changed files with 13 additions and 4 deletions

View File

@ -81,7 +81,10 @@ template <> struct GraphTraits<PostDominatorTree*>
}
static nodes_iterator nodes_begin(PostDominatorTree *N) {
return df_begin(getEntryNode(N));
if (getEntryNode(N))
return df_begin(getEntryNode(N));
else
return df_end(getEntryNode(N));
}
static nodes_iterator nodes_end(PostDominatorTree *N) {

View File

@ -85,9 +85,11 @@ struct GenericGraphViewer : public FunctionPass {
virtual bool runOnFunction(Function &F) {
Analysis *Graph;
std::string Title, GraphName;
Graph = &getAnalysis<Analysis>();
ViewGraph(Graph, Name, OnlyBBS);
GraphName = DOTGraphTraits<Analysis*>::getGraphName(Graph);
Title = GraphName + " for '" + F.getNameStr() + "' function";
ViewGraph(Graph, Name, OnlyBBS, Title);
return false;
}
@ -163,8 +165,12 @@ struct GenericGraphPrinter : public FunctionPass {
raw_fd_ostream File(Filename.c_str(), ErrorInfo);
Graph = &getAnalysis<Analysis>();
std::string Title, GraphName;
GraphName = DOTGraphTraits<Analysis*>::getGraphName(Graph);
Title = GraphName + " for '" + F.getNameStr() + "' function";
if (ErrorInfo.empty())
WriteGraph(File, Graph, OnlyBBS);
WriteGraph(File, Graph, OnlyBBS, Name, Title);
else
errs() << " error opening file for writing!";
errs() << "\n";