xref: /freebsd/contrib/llvm-project/clang/include/clang/Index/DeclOccurrence.h (revision fe6060f10f634930ff71b7c50291ddc610da2475)
10b57cec5SDimitry Andric //===- DeclOccurrence.h - An occurrence of a decl within a file -*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
100b57cec5SDimitry Andric #define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
110b57cec5SDimitry Andric 
12*fe6060f1SDimitry Andric #include "clang/AST/DeclBase.h"
130b57cec5SDimitry Andric #include "clang/Basic/LLVM.h"
140b57cec5SDimitry Andric #include "clang/Index/IndexSymbol.h"
15*fe6060f1SDimitry Andric #include "clang/Lex/MacroInfo.h"
160b57cec5SDimitry Andric #include "llvm/ADT/ArrayRef.h"
17*fe6060f1SDimitry Andric #include "llvm/ADT/PointerUnion.h"
180b57cec5SDimitry Andric #include "llvm/ADT/SmallVector.h"
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric namespace clang {
210b57cec5SDimitry Andric namespace index {
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric struct DeclOccurrence {
240b57cec5SDimitry Andric   SymbolRoleSet Roles;
250b57cec5SDimitry Andric   unsigned Offset;
26*fe6060f1SDimitry Andric   llvm::PointerUnion<const Decl *, const MacroInfo *> DeclOrMacro;
27*fe6060f1SDimitry Andric   const IdentifierInfo *MacroName = nullptr;
280b57cec5SDimitry Andric   SmallVector<SymbolRelation, 3> Relations;
290b57cec5SDimitry Andric 
DeclOccurrenceDeclOccurrence300b57cec5SDimitry Andric   DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
310b57cec5SDimitry Andric                  ArrayRef<SymbolRelation> Relations)
32*fe6060f1SDimitry Andric       : Roles(R), Offset(Offset), DeclOrMacro(D),
330b57cec5SDimitry Andric         Relations(Relations.begin(), Relations.end()) {}
DeclOccurrenceDeclOccurrence34*fe6060f1SDimitry Andric   DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name,
35*fe6060f1SDimitry Andric                  const MacroInfo *MI)
36*fe6060f1SDimitry Andric       : Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {}
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
390b57cec5SDimitry Andric     return LHS.Offset < RHS.Offset;
400b57cec5SDimitry Andric   }
410b57cec5SDimitry Andric };
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric } // namespace index
440b57cec5SDimitry Andric } // namespace clang
450b57cec5SDimitry Andric 
460b57cec5SDimitry Andric #endif // LLVM_CLANG_INDEX_DECLOCCURRENCE_H
47