From 1c12df14a6b168f01790abcc41a8e9d0f2f12de4 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Mon, 3 Aug 2015 16:37:12 +0000 Subject: [PATCH] Allow derived DOTViewers to choose the functions to illustrate 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 --- include/llvm/Analysis/DOTGraphTraitsPass.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/llvm/Analysis/DOTGraphTraitsPass.h b/include/llvm/Analysis/DOTGraphTraitsPass.h index cb74e9f32d3..3b2c0cb2b15 100644 --- a/include/llvm/Analysis/DOTGraphTraitsPass.h +++ b/include/llvm/Analysis/DOTGraphTraitsPass.h @@ -36,7 +36,18 @@ public: 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()); std::string GraphName = DOTGraphTraits::getGraphName(Graph); std::string Title = GraphName + " for '" + F.getName().str() + "' function"; @@ -63,7 +74,18 @@ public: 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()); std::string Filename = Name + "." + F.getName().str() + ".dot"; std::error_code EC; -- 2.34.1