DeclOccurrence.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DeclOccurrence.h - An occurrence of a decl within a file -*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
  14. #define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
  15. #include "clang/AST/DeclBase.h"
  16. #include "clang/Basic/LLVM.h"
  17. #include "clang/Index/IndexSymbol.h"
  18. #include "clang/Lex/MacroInfo.h"
  19. #include "llvm/ADT/ArrayRef.h"
  20. #include "llvm/ADT/PointerUnion.h"
  21. #include "llvm/ADT/SmallVector.h"
  22. namespace clang {
  23. namespace index {
  24. struct DeclOccurrence {
  25. SymbolRoleSet Roles;
  26. unsigned Offset;
  27. llvm::PointerUnion<const Decl *, const MacroInfo *> DeclOrMacro;
  28. const IdentifierInfo *MacroName = nullptr;
  29. SmallVector<SymbolRelation, 3> Relations;
  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. friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
  38. return LHS.Offset < RHS.Offset;
  39. }
  40. };
  41. } // namespace index
  42. } // namespace clang
  43. #endif // LLVM_CLANG_INDEX_DECLOCCURRENCE_H
  44. #ifdef __GNUC__
  45. #pragma GCC diagnostic pop
  46. #endif