Coverage Report

Created: 2020-09-19 12:23

/Users/buildslave/jenkins/workspace/coverage/llvm-project/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
28.1k
PostOrderCFGView::PostOrderCFGView(const CFG *cfg) {
22
28.1k
  Blocks.reserve(cfg->getNumBlockIDs());
23
28.1k
  CFGBlockSet BSet(cfg);
24
28.1k
25
28.1k
  for (po_iterator I = po_iterator::begin(cfg, BSet),
26
132k
                   E = po_iterator::end(cfg, BSet); I != E; 
++I104k
) {
27
104k
    BlockOrder[*I] = Blocks.size() + 1;
28
104k
    Blocks.push_back(*I);
29
104k
  }
30
28.1k
}
31
32
std::unique_ptr<PostOrderCFGView>
33
28.1k
PostOrderCFGView::create(AnalysisDeclContext &ctx) {
34
28.1k
  const CFG *cfg = ctx.getCFG();
35
28.1k
  if (!cfg)
36
0
    return nullptr;
37
28.1k
  return std::make_unique<PostOrderCFGView>(cfg);
38
28.1k
}
39
40
54.1k
const void *PostOrderCFGView::getTag() { static int x; return &x; }
41
42
bool PostOrderCFGView::BlockOrderCompare::operator()(const CFGBlock *b1,
43
176k
                                                     const CFGBlock *b2) const {
44
176k
  PostOrderCFGView::BlockOrderTy::const_iterator b1It = POV.BlockOrder.find(b1);
45
176k
  PostOrderCFGView::BlockOrderTy::const_iterator b2It = POV.BlockOrder.find(b2);
46
176k
47
174k
  unsigned b1V = (b1It == POV.BlockOrder.end()) ? 
01.98k
: b1It->second;
48
173k
  unsigned b2V = (b2It == POV.BlockOrder.end()) ? 
02.49k
: b2It->second;
49
176k
  return b1V > b2V;
50
176k
}