summaryrefslogtreecommitdiff
path: root/lib/Analysis/CFGPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-11 21:48:18 +0000
committerChris Lattner <sabre@nondot.org>2003-12-11 21:48:18 +0000
commit1ca2a583cb234cc8b26710e0f2ff68da2b6d24cd (patch)
tree083e7acd733a1319a10fd63a3dd5554205eccbb3 /lib/Analysis/CFGPrinter.cpp
parent13015151972a5be8d7aad94b49e42de990516cc8 (diff)
Finegrainify namespacification
Add new -print-cfg-only pass git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFGPrinter.cpp')
-rw-r--r--lib/Analysis/CFGPrinter.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp
index bd11522c961..ac78970cc29 100644
--- a/lib/Analysis/CFGPrinter.cpp
+++ b/lib/Analysis/CFGPrinter.cpp
@@ -25,8 +25,7 @@
#include "llvm/Support/CFG.h"
#include <sstream>
#include <fstream>
-
-namespace llvm {
+using namespace llvm;
/// CFGOnly flag - This is used to control whether or not the CFG graph printer
/// prints out the contents of basic blocks or not. This is acceptable because
@@ -34,6 +33,7 @@ namespace llvm {
///
static bool CFGOnly = false;
+namespace llvm {
template<>
struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
static std::string getGraphName(const Function *F) {
@@ -87,6 +87,7 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
return "";
}
};
+}
namespace {
struct CFGPrinter : public FunctionPass {
@@ -112,7 +113,26 @@ namespace {
RegisterAnalysis<CFGPrinter> P1("print-cfg",
"Print CFG of function to 'dot' file");
-};
+
+ struct CFGOnlyPrinter : public CFGPrinter {
+ virtual bool runOnFunction(Function &F) {
+ bool OldCFGOnly = CFGOnly;
+ CFGOnly = true;
+ CFGPrinter::runOnFunction(F);
+ CFGOnly = OldCFGOnly;
+ return false;
+ }
+ void print(std::ostream &OS) const {}
+
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ }
+ };
+
+ RegisterAnalysis<CFGOnlyPrinter>
+ P2("print-cfg-only",
+ "Print CFG of function to 'dot' file (with no function bodies)");
+}
/// viewCFG - This function is meant for use from the debugger. You can just
/// say 'call F->viewCFG()' and a ghostview window should pop up from the
@@ -153,5 +173,3 @@ void Function::viewCFGOnly() const {
viewCFG();
CFGOnly = false;
}
-
-} // End llvm namespace