Coverage Report

Created: 2020-10-24 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Tooling/Refactoring/Rename/SymbolOccurrences.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- SymbolOccurrences.cpp - Clang refactoring library ----------------===//
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
#include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h"
10
#include "clang/Tooling/Refactoring/Rename/SymbolName.h"
11
#include "llvm/ADT/STLExtras.h"
12
13
using namespace clang;
14
using namespace tooling;
15
16
SymbolOccurrence::SymbolOccurrence(const SymbolName &Name, OccurrenceKind Kind,
17
                                   ArrayRef<SourceLocation> Locations)
18
460
    : Kind(Kind) {
19
460
  ArrayRef<std::string> NamePieces = Name.getNamePieces();
20
460
  assert(Locations.size() == NamePieces.size() &&
21
460
         "mismatching number of locations and lengths");
22
460
  assert(!Locations.empty() && "no locations");
23
460
  if (Locations.size() == 1) {
24
460
    RangeOrNumRanges = SourceRange(
25
460
        Locations[0], Locations[0].getLocWithOffset(NamePieces[0].size()));
26
460
    return;
27
460
  }
28
0
  MultipleRanges = std::make_unique<SourceRange[]>(Locations.size());
29
0
  RangeOrNumRanges.setBegin(
30
0
      SourceLocation::getFromRawEncoding(Locations.size()));
31
0
  for (const auto &Loc : llvm::enumerate(Locations)) {
32
0
    MultipleRanges[Loc.index()] = SourceRange(
33
0
        Loc.value(),
34
0
        Loc.value().getLocWithOffset(NamePieces[Loc.index()].size()));
35
0
  }
36
0
}