blob: 074f7e19e5d39edc681ff97f2fbb8908ad238d43 [file] [log] [blame]
#include "CFGGraphDrawer.h"
#include "TVTreeItem.h"
#include "llvm/Function.h"
#include "llvm/ModuleProvider.h"
#include "llvm/Analysis/CFGPrinter.h"
#include "llvm/PassManager.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
// CFGGraphDrawer implementation
wxImage *CFGGraphDrawer::drawFunctionGraph (Function *fn) {
ModuleProvider *MP = new ExistingModuleProvider (fn->getParent ());
FunctionPassManager PM (MP);
PM.add (createCFGOnlyPrinterPass ());
PM.run (*fn);
MP->releaseModule (); // Don't delete it when you go away, says I
delete MP;
return buildwxImageFromDotFile ("cfg." + fn->getName() + ".dot");
}
std::string CFGGraphDrawer::getDisplayTitle (TVTreeItemData *item) {
std::string title ("Control-flow graph");
if (item) title += " of " + item->getTitle ();
return title;
}