Skip to content

Commit

Permalink
Allow derived DOTViewers to choose the functions to illustrate
Browse files Browse the repository at this point in the history
Instead of always showing/printing all functions, a class derived from
the DOTViewer class can overwrite the set of functions that will be
processed.

This will be used (and tested) by Polly's scop viewers, but other users
can be imagined as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243881 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
tobiasgrosser committed Aug 3, 2015
1 parent ca0cc47 commit 1c12df1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions include/llvm/Analysis/DOTGraphTraitsPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ class DOTGraphTraitsViewer : public FunctionPass {
DOTGraphTraitsViewer(StringRef GraphName, char &ID)
: FunctionPass(ID), Name(GraphName) {}

/// @brief Return true if this function should be processed.
///
/// An implementation of this class my override this function to indicate that
/// only certain functions should be viewed.
virtual bool processFunction(Function &F) {
return true;
}

bool runOnFunction(Function &F) override {
if (!processFunction(F))
return false;

GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
std::string GraphName = DOTGraphTraits<GraphT>::getGraphName(Graph);
std::string Title = GraphName + " for '" + F.getName().str() + "' function";
Expand All @@ -63,7 +74,18 @@ class DOTGraphTraitsPrinter : public FunctionPass {
DOTGraphTraitsPrinter(StringRef GraphName, char &ID)
: FunctionPass(ID), Name(GraphName) {}

/// @brief Return true if this function should be processed.
///
/// An implementation of this class my override this function to indicate that
/// only certain functions should be printed.
virtual bool processFunction(Function &F) {
return true;
}

bool runOnFunction(Function &F) override {
if (!processFunction(F))
return false;

GraphT Graph = AnalysisGraphTraitsT::getGraph(&getAnalysis<AnalysisT>());
std::string Filename = Name + "." + F.getName().str() + ".dot";
std::error_code EC;
Expand Down

0 comments on commit 1c12df1

Please sign in to comment.