clang  6.0.0svn
SymbolOccurrences.cpp
Go to the documentation of this file.
1 //===--- SymbolOccurrences.cpp - Clang refactoring library ----------------===//
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 
12 #include "llvm/ADT/STLExtras.h"
13 
14 using namespace clang;
15 using namespace tooling;
16 
18  ArrayRef<SourceLocation> Locations)
19  : Kind(Kind) {
20  ArrayRef<std::string> NamePieces = Name.getNamePieces();
21  assert(Locations.size() == NamePieces.size() &&
22  "mismatching number of locations and lengths");
23  assert(!Locations.empty() && "no locations");
24  if (Locations.size() == 1) {
25  RangeOrNumRanges = SourceRange(
26  Locations[0], Locations[0].getLocWithOffset(NamePieces[0].size()));
27  return;
28  }
29  MultipleRanges = llvm::make_unique<SourceRange[]>(Locations.size());
30  RangeOrNumRanges.setBegin(
31  SourceLocation::getFromRawEncoding(Locations.size()));
32  for (const auto &Loc : llvm::enumerate(Locations)) {
33  MultipleRanges[Loc.index()] = SourceRange(
34  Loc.value(),
35  Loc.value().getLocWithOffset(NamePieces[Loc.index()].size()));
36  }
37 }
A name of a symbol.
Definition: SymbolName.h:30
void setBegin(SourceLocation b)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Kind
SymbolOccurrence(const SymbolName &Name, OccurrenceKind Kind, ArrayRef< SourceLocation > Locations)
Dataflow Directional Tag Classes.
ArrayRef< std::string > getNamePieces() const
Definition: SymbolName.h:40
A trivial tuple used to represent a source range.