clang 10.0.0git

FileIndexRecord.h
Go to the documentation of this file.
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
9 #ifndef LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
10 #define LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
11
12 #include "clang/Basic/SourceLocation.h"
13 #include "clang/Index/DeclOccurrence.h"
14 #include "clang/Index/IndexSymbol.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include <vector>
18
19 namespace clang {
20 class IdentifierInfo;
21
22 namespace index {
23
24 /// Stores the declaration occurrences seen in a particular source or header
25 /// file of a translation unit
26 class FileIndexRecord {
27 private:
28 FileID FID;
29 bool IsSystem;
30 std::vector<DeclOccurrence> Decls;
31
32 public:
33 FileIndexRecord(FileID FID, bool IsSystem) : FID(FID), IsSystem(IsSystem) {}
34
35 ArrayRef<DeclOccurrence> getDeclOccurrencesSortedByOffset() const {
36 return Decls;
37 }
38
39 FileID getFileID() const { return FID; }
40 bool isSystem() const { return IsSystem; }
41
42 /// Adds an occurrence of the canonical declaration \c D at the supplied
43 /// \c Offset
44 ///
45 /// \param Roles the roles the occurrence fulfills in this position.
46 /// \param Offset the offset in the file of this occurrence.
47 /// \param D the canonical declaration this is an occurrence of.
48 /// \param Relations the set of symbols related to this occurrence.
49 void addDeclOccurence(SymbolRoleSet Roles, unsigned Offset, const Decl *D,
50 ArrayRef<SymbolRelation> Relations);
51 void print(llvm::raw_ostream &OS) const;
52 };
53
54 } // end namespace index
55 } // end namespace clang
56
57 #endif // LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
clang::index::FileIndexRecord::getDeclOccurrencesSortedByOffset
ArrayRef< DeclOccurrence > getDeclOccurrencesSortedByOffset() const
Definition: FileIndexRecord.h:35
clang::index::FileIndexRecord::print
void print(llvm::raw_ostream &OS) const
Definition: FileIndexRecord.cpp:43
DeclOccurrence.h
llvm::ArrayRef
Definition: LLVM.h:31
clang::index::SymbolRoleSet
unsigned SymbolRoleSet
Definition: IndexSymbol.h:127
Offset
unsigned Offset
Definition: Format.cpp:1827
clang::index::FileIndexRecord::isSystem
bool isSystem() const
Definition: FileIndexRecord.h:40
IndexSymbol.h
clang::index::FileIndexRecord::addDeclOccurence
void addDeclOccurence(SymbolRoleSet Roles, unsigned Offset, const Decl *D, ArrayRef< SymbolRelation > Relations)
Adds an occurrence of the canonical declaration D at the supplied Offset.
Definition: FileIndexRecord.cpp:19
clang::index::FileIndexRecord::getFileID
FileID getFileID() const
Definition: FileIndexRecord.h:39
clang::index::FileIndexRecord
Stores the declaration occurrences seen in a particular source or header file of a translation unit...
Definition: FileIndexRecord.h:26
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::index::FileIndexRecord::FileIndexRecord
FileIndexRecord(FileID FID, bool IsSystem)
Definition: FileIndexRecord.h:33
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.