FileIndexRecord.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //===--- FileIndexRecord.h - Index data per 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. #ifndef LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
  9. #define LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
  10. #include "clang/Basic/SourceLocation.h"
  11. #include "clang/Index/DeclOccurrence.h"
  12. #include "clang/Index/IndexSymbol.h"
  13. #include "llvm/ADT/ArrayRef.h"
  14. #include "llvm/ADT/SmallVector.h"
  15. #include <vector>
  16. namespace clang {
  17. class IdentifierInfo;
  18. namespace index {
  19. /// Stores the declaration occurrences seen in a particular source or header
  20. /// file of a translation unit
  21. class FileIndexRecord {
  22. private:
  23. FileID FID;
  24. bool IsSystem;
  25. std::vector<DeclOccurrence> Decls;
  26. public:
  27. FileIndexRecord(FileID FID, bool IsSystem) : FID(FID), IsSystem(IsSystem) {}
  28. ArrayRef<DeclOccurrence> getDeclOccurrencesSortedByOffset() const {
  29. return Decls;
  30. }
  31. FileID getFileID() const { return FID; }
  32. bool isSystem() const { return IsSystem; }
  33. /// Adds an occurrence of the canonical declaration \c D at the supplied
  34. /// \c Offset
  35. ///
  36. /// \param Roles the roles the occurrence fulfills in this position.
  37. /// \param Offset the offset in the file of this occurrence.
  38. /// \param D the canonical declaration this is an occurrence of.
  39. /// \param Relations the set of symbols related to this occurrence.
  40. void addDeclOccurence(SymbolRoleSet Roles, unsigned Offset, const Decl *D,
  41. ArrayRef<SymbolRelation> Relations);
  42. void print(llvm::raw_ostream &OS) const;
  43. };
  44. } // end namespace index
  45. } // end namespace clang
  46. #endif // LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H