clang  14.0.0git
DeclOccurrence.h
Go to the documentation of this file.
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"
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 
20 namespace clang {
21 namespace index {
22 
25  unsigned Offset;
26  llvm::PointerUnion<const Decl *, const MacroInfo *> DeclOrMacro;
27  const IdentifierInfo *MacroName = nullptr;
29 
30  DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
32  : Roles(R), Offset(Offset), DeclOrMacro(D),
33  Relations(Relations.begin(), Relations.end()) {}
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
clang::index::DeclOccurrence
Definition: DeclOccurrence.h:23
clang::index::DeclOccurrence::DeclOccurrence
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D, ArrayRef< SymbolRelation > Relations)
Definition: DeclOccurrence.h:30
llvm::SmallVector
Definition: LLVM.h:38
clang::index::DeclOccurrence::DeclOrMacro
llvm::PointerUnion< const Decl *, const MacroInfo * > DeclOrMacro
Definition: DeclOccurrence.h:26
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
DeclBase.h
clang::index::DeclOccurrence::operator<
friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS)
Definition: DeclOccurrence.h:38
clang::index::DeclOccurrence::MacroName
const IdentifierInfo * MacroName
Definition: DeclOccurrence.h:27
clang::index::DeclOccurrence::Offset
unsigned Offset
Definition: DeclOccurrence.h:25
llvm::ArrayRef
Definition: LLVM.h:34
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
LLVM.h
IndexSymbol.h
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang
Definition: CalledOnceCheck.h:17
MacroInfo.h
unsigned
clang::index::DeclOccurrence::Relations
SmallVector< SymbolRelation, 3 > Relations
Definition: DeclOccurrence.h:28
clang::index::DeclOccurrence::Roles
SymbolRoleSet Roles
Definition: DeclOccurrence.h:24
clang::index::DeclOccurrence::DeclOccurrence
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name, const MacroInfo *MI)
Definition: DeclOccurrence.h:34