Mercurial > hg > CbC > CbC_llvm
comparison clang-tools-extra/clangd/XRefs.h @ 221:79ff65ed7e25
LLVM12 Original
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Jun 2021 19:15:29 +0900 |
parents | 0572611fdcc8 |
children | c4bab56944e8 |
comparison
equal
deleted
inserted
replaced
220:42394fc6a535 | 221:79ff65ed7e25 |
---|---|
14 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H | 14 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H |
15 | 15 |
16 #include "Protocol.h" | 16 #include "Protocol.h" |
17 #include "SourceCode.h" | 17 #include "SourceCode.h" |
18 #include "index/Index.h" | 18 #include "index/Index.h" |
19 #include "index/SymbolID.h" | |
19 #include "index/SymbolLocation.h" | 20 #include "index/SymbolLocation.h" |
20 #include "support/Path.h" | 21 #include "support/Path.h" |
21 #include "clang/AST/ASTTypeTraits.h" | 22 #include "clang/AST/ASTTypeTraits.h" |
22 #include "clang/AST/Type.h" | 23 #include "clang/AST/Type.h" |
23 #include "clang/Format/Format.h" | 24 #include "clang/Format/Format.h" |
45 std::string Name; | 46 std::string Name; |
46 // The canonical or best declaration: where most users find its interface. | 47 // The canonical or best declaration: where most users find its interface. |
47 Location PreferredDeclaration; | 48 Location PreferredDeclaration; |
48 // Where the symbol is defined, if known. May equal PreferredDeclaration. | 49 // Where the symbol is defined, if known. May equal PreferredDeclaration. |
49 llvm::Optional<Location> Definition; | 50 llvm::Optional<Location> Definition; |
51 // SymbolID of the located symbol if available. | |
52 SymbolID ID; | |
50 }; | 53 }; |
51 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const LocatedSymbol &); | 54 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const LocatedSymbol &); |
52 /// Get definition of symbol at a specified \p Pos. | 55 /// Get definition of symbol at a specified \p Pos. |
53 /// Multiple locations may be returned, corresponding to distinct symbols. | 56 /// Multiple locations may be returned, corresponding to distinct symbols. |
54 std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos, | 57 std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos, |
77 /// Returns highlights for all usages of a symbol at \p Pos. | 80 /// Returns highlights for all usages of a symbol at \p Pos. |
78 std::vector<DocumentHighlight> findDocumentHighlights(ParsedAST &AST, | 81 std::vector<DocumentHighlight> findDocumentHighlights(ParsedAST &AST, |
79 Position Pos); | 82 Position Pos); |
80 | 83 |
81 struct ReferencesResult { | 84 struct ReferencesResult { |
82 std::vector<Location> References; | 85 // Bitmask describing whether the occurrence is a declaration, definition etc. |
86 enum ReferenceAttributes : unsigned { | |
87 Declaration = 1 << 0, | |
88 Definition = 1 << 1, | |
89 // The occurrence is an override of the target base method. | |
90 Override = 1 << 2, | |
91 }; | |
92 struct Reference { | |
93 Location Loc; | |
94 unsigned Attributes = 0; | |
95 }; | |
96 std::vector<Reference> References; | |
83 bool HasMore = false; | 97 bool HasMore = false; |
84 }; | 98 }; |
99 llvm::raw_ostream &operator<<(llvm::raw_ostream &, | |
100 const ReferencesResult::Reference &); | |
101 | |
102 /// Returns implementations at a specified \p Pos: | |
103 /// - overrides for a virtual method; | |
104 /// - subclasses for a base class; | |
105 std::vector<LocatedSymbol> findImplementations(ParsedAST &AST, Position Pos, | |
106 const SymbolIndex *Index); | |
107 | |
85 /// Returns references of the symbol at a specified \p Pos. | 108 /// Returns references of the symbol at a specified \p Pos. |
86 /// \p Limit limits the number of results returned (0 means no limit). | 109 /// \p Limit limits the number of results returned (0 means no limit). |
87 ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit, | 110 ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit, |
88 const SymbolIndex *Index = nullptr); | 111 const SymbolIndex *Index = nullptr); |
89 | 112 |
103 | 126 |
104 void resolveTypeHierarchy(TypeHierarchyItem &Item, int ResolveLevels, | 127 void resolveTypeHierarchy(TypeHierarchyItem &Item, int ResolveLevels, |
105 TypeHierarchyDirection Direction, | 128 TypeHierarchyDirection Direction, |
106 const SymbolIndex *Index); | 129 const SymbolIndex *Index); |
107 | 130 |
131 /// Get call hierarchy information at \p Pos. | |
132 std::vector<CallHierarchyItem> | |
133 prepareCallHierarchy(ParsedAST &AST, Position Pos, PathRef TUPath); | |
134 | |
135 std::vector<CallHierarchyIncomingCall> | |
136 incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index); | |
137 | |
108 /// Returns all decls that are referenced in the \p FD except local symbols. | 138 /// Returns all decls that are referenced in the \p FD except local symbols. |
109 llvm::DenseSet<const Decl *> getNonLocalDeclRefs(ParsedAST &AST, | 139 llvm::DenseSet<const Decl *> getNonLocalDeclRefs(ParsedAST &AST, |
110 const FunctionDecl *FD); | 140 const FunctionDecl *FD); |
111 } // namespace clangd | 141 } // namespace clangd |
112 } // namespace clang | 142 } // namespace clang |