Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Analysis/PostOrderCFGView.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- PostOrderCFGView.cpp - Post order view of CFG blocks ---------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements post order view of the blocks in a CFG.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/Analysis/Analyses/PostOrderCFGView.h"
14
#include "clang/Analysis/AnalysisDeclContext.h"
15
#include "clang/Analysis/CFG.h"
16
17
using namespace clang;
18
19
0
void PostOrderCFGView::anchor() {}
20
21
109k
PostOrderCFGView::PostOrderCFGView(const CFG *cfg) {
22
109k
  Blocks.reserve(cfg->getNumBlockIDs());
23
109k
  CFGBlockSet BSet(cfg);
24
109k
25
109k
  for (po_iterator I = po_iterator::begin(cfg, BSet),
26
961k
                   E = po_iterator::end(cfg, BSet); I != E; 
++I851k
) {
27
851k
    BlockOrder[*I] = Blocks.size() + 1;
28
851k
    Blocks.push_back(*I);
29
851k
  }
30
109k
}
31
32
109k
PostOrderCFGView *PostOrderCFGView::create(AnalysisDeclContext &ctx) {
33
109k
  const CFG *cfg = ctx.getCFG();
34
109k
  if (!cfg)
35
0
    return nullptr;
36
109k
  return new PostOrderCFGView(cfg);
37
109k
}
38
39
109k
const void *PostOrderCFGView::getTag() { static int x; return &x; }
40
41
bool PostOrderCFGView::BlockOrderCompare::operator()(const CFGBlock *b1,
42
126k
                                                     const CFGBlock *b2) const {
43
126k
  PostOrderCFGView::BlockOrderTy::const_iterator b1It = POV.BlockOrder.find(b1);
44
126k
  PostOrderCFGView::BlockOrderTy::const_iterator b2It = POV.BlockOrder.find(b2);
45
126k
46
126k
  unsigned b1V = (b1It == POV.BlockOrder.end()) ? 
01.92k
:
b1It->second124k
;
47
126k
  unsigned b2V = (b2It == POV.BlockOrder.end()) ? 
02.37k
:
b2It->second124k
;
48
126k
  return b1V > b2V;
49
126k
}