Coverage Report

Created: 2017-08-18 19:41

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/Support/ScopLocation.cpp
Line
Count
Source
1
//=== ScopLocation.cpp - Debug location for ScopDetection ----- -*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// Helper function for extracting region debug information.
11
//
12
//===----------------------------------------------------------------------===//
13
//
14
#include "polly/Support/ScopLocation.h"
15
#include "llvm/Analysis/RegionInfo.h"
16
#include "llvm/IR/BasicBlock.h"
17
#include "llvm/IR/DebugInfo.h"
18
#include "llvm/IR/DebugLoc.h"
19
20
using namespace llvm;
21
22
namespace polly {
23
24
void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
25
6
                      std::string &FileName) {
26
6
  LineBegin = -1;
27
6
  LineEnd = 0;
28
6
29
6
  for (const BasicBlock *BB : R->blocks())
30
27
    
for (const Instruction &Inst : *BB) 27
{81
31
81
      DebugLoc DL = Inst.getDebugLoc();
32
81
      if (!DL)
33
67
        continue;
34
81
35
81
      auto *Scope = cast<DIScope>(DL.getScope());
36
14
37
14
      if (FileName.empty())
38
2
        FileName = Scope->getFilename();
39
14
40
14
      unsigned NewLine = DL.getLine();
41
14
42
14
      LineBegin = std::min(LineBegin, NewLine);
43
14
      LineEnd = std::max(LineEnd, NewLine);
44
14
    }
45
6
}
46
} // namespace polly