comparison clang-tools-extra/clangd/AST.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
13 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ 13 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_
14 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ 14 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_
15 15
16 #include "index/SymbolID.h" 16 #include "index/SymbolID.h"
17 #include "clang/AST/Decl.h" 17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclObjC.h"
18 #include "clang/AST/NestedNameSpecifier.h" 19 #include "clang/AST/NestedNameSpecifier.h"
19 #include "clang/Basic/SourceLocation.h" 20 #include "clang/Basic/SourceLocation.h"
20 #include "clang/Lex/MacroInfo.h" 21 #include "clang/Lex/MacroInfo.h"
21 #include "llvm/ADT/DenseSet.h" 22 #include "llvm/ADT/DenseSet.h"
22 #include "llvm/ADT/StringRef.h" 23 #include "llvm/ADT/StringRef.h"
62 /// enclosing '<' and '>', e.g for a partial specialization like: template 63 /// enclosing '<' and '>', e.g for a partial specialization like: template
63 /// <typename U> struct Foo<int, U> will return '<int, U>'. Returns an empty 64 /// <typename U> struct Foo<int, U> will return '<int, U>'. Returns an empty
64 /// string if decl is not a template specialization. 65 /// string if decl is not a template specialization.
65 std::string printTemplateSpecializationArgs(const NamedDecl &ND); 66 std::string printTemplateSpecializationArgs(const NamedDecl &ND);
66 67
67 /// Gets the symbol ID for a declaration, if possible. 68 /// Print the Objective-C method name, including the full container name, e.g.
68 llvm::Optional<SymbolID> getSymbolID(const Decl *D); 69 /// `-[MyClass(Category) method:]`
70 std::string printObjCMethod(const ObjCMethodDecl &Method);
69 71
70 /// Gets the symbol ID for a macro, if possible. 72 /// Print the Objective-C container name including categories, e.g. `MyClass`,
73 // `MyClass()`, `MyClass(Category)`, and `MyProtocol`.
74 std::string printObjCContainer(const ObjCContainerDecl &C);
75
76 /// Gets the symbol ID for a declaration. Returned SymbolID might be null.
77 SymbolID getSymbolID(const Decl *D);
78
79 /// Gets the symbol ID for a macro. Returned SymbolID might be null.
71 /// Currently, this is an encoded USR of the macro, which incorporates macro 80 /// Currently, this is an encoded USR of the macro, which incorporates macro
72 /// locations (e.g. file name, offset in file). 81 /// locations (e.g. file name, offset in file).
73 /// FIXME: the USR semantics might not be stable enough as the ID for index 82 /// FIXME: the USR semantics might not be stable enough as the ID for index
74 /// macro (e.g. a change in definition offset can result in a different USR). We 83 /// macro (e.g. a change in definition offset can result in a different USR). We
75 /// could change these semantics in the future by reimplementing this funcure 84 /// could change these semantics in the future by reimplementing this funcure
76 /// (e.g. avoid USR for macros). 85 /// (e.g. avoid USR for macros).
77 llvm::Optional<SymbolID> getSymbolID(const llvm::StringRef MacroName, 86 SymbolID getSymbolID(const llvm::StringRef MacroName, const MacroInfo *MI,
78 const MacroInfo *MI, 87 const SourceManager &SM);
79 const SourceManager &SM);
80 88
81 /// Returns a QualType as string. The result doesn't contain unwritten scopes 89 /// Returns a QualType as string. The result doesn't contain unwritten scopes
82 /// like anonymous/inline namespace. 90 /// like anonymous/inline namespace.
83 std::string printType(const QualType QT, const DeclContext &CurContext); 91 std::string printType(const QualType QT, const DeclContext &CurContext);
84 92
108 // (i.e. vector<T*> rather than vector<type-parameter-0-0 *>. 116 // (i.e. vector<T*> rather than vector<type-parameter-0-0 *>.
109 QualType declaredType(const TypeDecl *D); 117 QualType declaredType(const TypeDecl *D);
110 118
111 /// Retrieves the deduced type at a given location (auto, decltype). 119 /// Retrieves the deduced type at a given location (auto, decltype).
112 /// It will return the underlying type. 120 /// It will return the underlying type.
121 /// If the type is an undeduced auto, returns the type itself.
113 llvm::Optional<QualType> getDeducedType(ASTContext &, SourceLocation Loc); 122 llvm::Optional<QualType> getDeducedType(ASTContext &, SourceLocation Loc);
114 123
115 /// Gets the nested name specifier necessary for spelling \p ND in \p 124 /// Gets the nested name specifier necessary for spelling \p ND in \p
116 /// DestContext, at \p InsertionPoint. It selects the shortest suffix of \p ND 125 /// DestContext, at \p InsertionPoint. It selects the shortest suffix of \p ND
117 /// such that it is visible in \p DestContext. 126 /// such that it is visible in \p DestContext.
160 /// After code completion the initializer is attached, and x has a lambda type. 169 /// After code completion the initializer is attached, and x has a lambda type.
161 /// This means x has "unique external" linkage. If we computed linkage above, 170 /// This means x has "unique external" linkage. If we computed linkage above,
162 /// the cached value is incorrect. (clang catches this with an assertion). 171 /// the cached value is incorrect. (clang catches this with an assertion).
163 bool hasUnstableLinkage(const Decl *D); 172 bool hasUnstableLinkage(const Decl *D);
164 173
174 /// Checks whether \p D is more than \p MaxDepth away from translation unit
175 /// scope.
176 /// This is useful for limiting traversals to keep operation latencies
177 /// reasonable.
178 bool isDeeplyNested(const Decl *D, unsigned MaxDepth = 10);
179
165 } // namespace clangd 180 } // namespace clangd
166 } // namespace clang 181 } // namespace clang
167 182
168 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ 183 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_