summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/PostOrderCFGView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Analysis/PostOrderCFGView.cpp')
-rw-r--r--clang/lib/Analysis/PostOrderCFGView.cpp56
1 files changed, 4 insertions, 52 deletions
diff --git a/clang/lib/Analysis/PostOrderCFGView.cpp b/clang/lib/Analysis/PostOrderCFGView.cpp
index 714292b3f98..5a3c8182a14 100644
--- a/clang/lib/Analysis/PostOrderCFGView.cpp
+++ b/clang/lib/Analysis/PostOrderCFGView.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements post order views of the blocks in a CFG.
+// This file implements post order view of the blocks in a CFG.
//
//===----------------------------------------------------------------------===//
@@ -17,16 +17,14 @@ using namespace clang;
void PostOrderCFGView::anchor() { }
-ReversePostOrderCFGView::ReversePostOrderCFGView(const CFG *cfg) {
+PostOrderCFGView::PostOrderCFGView(const CFG *cfg) {
Blocks.reserve(cfg->getNumBlockIDs());
CFGBlockSet BSet(cfg);
-
- typedef llvm::po_iterator<const CFG*, CFGBlockSet, true> po_iterator;
-
+
for (po_iterator I = po_iterator::begin(cfg, BSet),
E = po_iterator::end(cfg, BSet); I != E; ++I) {
+ BlockOrder[*I] = Blocks.size() + 1;
Blocks.push_back(*I);
- BlockOrder[*I] = Blocks.size();
}
}
@@ -49,49 +47,3 @@ bool PostOrderCFGView::BlockOrderCompare::operator()(const CFGBlock *b1,
return b1V > b2V;
}
-PostOrderCFGView::PostOrderCFGView(const CFG *cfg) {
- unsigned size = cfg->getNumBlockIDs();
- Blocks.reserve(size);
- CFGBlockSet BSet(cfg);
-
- typedef llvm::po_iterator<const CFG*, CFGBlockSet, true,
- llvm::GraphTraits<llvm::Inverse<const CFG*> >
- > po_iterator;
-
- for (po_iterator I = po_iterator::begin(cfg, BSet),
- E = po_iterator::end(cfg, BSet); I != E; ++I) {
- Blocks.push_back(*I);
- BlockOrder[*I] = Blocks.size();
- }
-
- // It may be that some blocks are inaccessible going from the CFG exit upwards
- // (e.g. infinite loops); we still need to add them.
- for (CFG::const_iterator I = cfg->begin(), E = cfg->end();
- (Blocks.size() < size) && (I != E); ++I) {
- const CFGBlock* block = *I;
- // Add a chain going upwards.
- while (!BlockOrder.count(block)) {
- Blocks.push_back(block);
- BlockOrder[block] = Blocks.size();
- CFGBlock::const_pred_iterator PI = block->pred_begin(),
- PE = block->pred_end();
- for (; PI != PE; ++PI) {
- const CFGBlock* pred = *PI;
- if (pred && !BlockOrder.count(pred)) {
- block = pred;
- break;
- }
- }
- // Chain ends when we couldn't find an unmapped pred.
- if (PI == PE) break;
- }
- }
-}
-
-ReversePostOrderCFGView *
-ReversePostOrderCFGView::create(AnalysisDeclContext &ctx) {
- const CFG *cfg = ctx.getCFG();
- if (!cfg)
- return nullptr;
- return new ReversePostOrderCFGView(cfg);
-}
OpenPOWER on IntegriCloud