1//===- DeclOccurrence.h - An occurrence of a decl within a file -*- C++ -*-===//
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#ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
10#define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
11
12#include "clang/AST/DeclBase.h"
13#include "clang/Basic/LLVM.h"
14#include "clang/Index/IndexSymbol.h"
15#include "clang/Lex/MacroInfo.h"
16#include "llvm/ADT/ArrayRef.h"
17#include "llvm/ADT/PointerUnion.h"
18#include "llvm/ADT/SmallVector.h"
19
20namespace clang {
21namespace index {
22
23struct DeclOccurrence {
24 SymbolRoleSet Roles;
25 unsigned Offset;
26 llvm::PointerUnion<const Decl *, const MacroInfo *> DeclOrMacro;
27 const IdentifierInfo *MacroName = nullptr;
28 SmallVector<SymbolRelation, 3> Relations;
29
30 DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
31 ArrayRef<SymbolRelation> Relations)
32 : Roles(R), Offset(Offset), DeclOrMacro(D),
33 Relations(Relations.begin(), Relations.end()) {}
34 DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name,
35 const MacroInfo *MI)
36 : Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {}
37
38 friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
39 return LHS.Offset < RHS.Offset;
40 }
41};
42
43} // namespace index
44} // namespace clang
45
46#endif // LLVM_CLANG_INDEX_DECLOCCURRENCE_H
47

source code of clang/include/clang/Index/DeclOccurrence.h