@@ -12,71 +12,58 @@ bool is_definition(const clang::Decl* decl);
1212// / we consider it as a template while clang does not.
1313bool is_templated (const clang::Decl* decl);
1414
15+ // / Check whether the decl is anonymous.
16+ bool is_anonymous (const clang::NamedDecl* decl);
17+
1518// / Return the decl where it is instantiated from. If could be a template decl
1619// / or a member of a class template. If the decl is a full specialization, return
1720// / itself.
1821const clang::NamedDecl* instantiated_from (const clang::NamedDecl* decl);
1922
2023const clang::NamedDecl* normalize (const clang::NamedDecl* decl);
2124
25+ llvm::StringRef identifier_of (const clang::NamedDecl& D);
26+
27+ llvm::StringRef identifier_of (clang::QualType T);
28+
2229// / Get the name of the decl.
2330std::string name_of (const clang::NamedDecl* decl);
2431
32+ std::string display_name_of (const clang::NamedDecl* decl);
33+
2534// / To response go-to-type-definition request. Some decls actually have a type
2635// / for example the result of `typeof(var)` is the type of `var`. This function
2736// / returns the type for the decl if any.
2837clang::QualType type_of (const clang::NamedDecl* decl);
2938
30- const clang::NamedDecl* get_decl_for_type (const clang::Type* T);
31-
3239// / Get the underlying decl for a type if any.
33- const clang::NamedDecl* decl_of (clang::QualType type);
34-
35- // / Check whether the decl is anonymous.
36- bool is_anonymous (const clang::NamedDecl* decl);
37-
38- clang::NestedNameSpecifierLoc get_qualifier_loc (const clang::NamedDecl* decl);
39-
40- auto get_template_specialization_args (const clang::NamedDecl* decl)
41- -> std::optional<llvm::ArrayRef<clang::TemplateArgumentLoc>>;
40+ auto decl_of (clang::QualType type) -> const clang::NamedDecl*;
4241
43- std::string print_template_specialization_args (const clang::NamedDecl* decl);
42+ // / Recursively strips all pointers, references, and array extents from
43+ // / a TypeLoc. e.g., for "const int*(&)[3]", the result will be location
44+ // / "for int".
45+ auto unwrap_type (clang::TypeLoc type, bool unwrap_function_type = true ) -> clang::TypeLoc;
4446
45- std::string print_name ( const clang::NamedDecl* decl) ;
47+ auto get_only_instantiation ( clang::NamedDecl* templated_decl) -> clang::NamedDecl* ;
4648
47- clang::TemplateTypeParmTypeLoc get_contained_auto_param_type (clang::TypeLoc TL) ;
49+ auto get_only_instantiation (clang::ParmVarDecl* param) -> clang::ParmVarDecl* ;
4850
49- clang::NamedDecl* get_only_instantiation (clang::NamedDecl* TemplatedDecl);
50-
51- // / getSimpleName() returns the plain identifier for an entity, if any.
52- llvm::StringRef getSimpleName (const clang::DeclarationName& DN);
53- llvm::StringRef getSimpleName (const clang::NamedDecl& D);
54- llvm::StringRef getSimpleName (clang::QualType T);
55-
56- std::string summarizeExpr (const clang::Expr* E);
57-
58- // Returns the template parameter pack type from an instantiated function
59- // template, if it exists, nullptr otherwise.
60- const clang::TemplateTypeParmType* getFunctionPackType (const clang::FunctionDecl* Callee);
51+ std::string summarize_expr (const clang::Expr* E);
6152
6253// Returns the template parameter pack type that this parameter was expanded
6354// from (if in the Args... or Args&... or Args&&... form), if this is the case,
6455// nullptr otherwise.
65- const clang::TemplateTypeParmType* getUnderlyingPackType (const clang::ParmVarDecl* Param );
56+ const clang::TemplateTypeParmType* underlying_pack_type (const clang::ParmVarDecl* param );
6657
6758// Returns the parameters that are forwarded from the template parameters.
6859// For example, `template <typename... Args> void foo(Args... args)` will return
6960// the `args` parameters.
70- llvm::SmallVector<const clang::ParmVarDecl*>
71- resolveForwardingParameters (const clang::FunctionDecl* D, unsigned MaxDepth = 10 );
72-
73- // Determines if any intermediate type in desugaring QualType QT is of
74- // substituted template parameter type. Ignore pointer or reference wrappers.
75- bool isSugaredTemplateParameter (clang::QualType QT);
61+ auto resolve_forwarding_params (const clang::FunctionDecl* decl, unsigned max_depth = 10 )
62+ -> llvm::SmallVector<const clang::ParmVarDecl*>;
7663
7764// A simple wrapper for `clang::desugarForDiagnostic` that provides optional
7865// semantic.
79- std::optional<clang::QualType> desugar (clang::ASTContext& AST , clang::QualType QT );
66+ std::optional<clang::QualType> desugar (clang::ASTContext& context , clang::QualType type );
8067
8168// Apply a series of heuristic methods to determine whether or not a QualType QT
8269// is suitable for desugaring (e.g. getting the real name behind the using-alias
@@ -85,12 +72,12 @@ std::optional<clang::QualType> desugar(clang::ASTContext& AST, clang::QualType Q
8572//
8673// This could be refined further. See
8774// https://github.com/clangd/clangd/issues/1298.
88- clang::QualType maybeDesugar (clang::ASTContext& AST , clang::QualType QT );
75+ clang::QualType maybe_desugar (clang::ASTContext& context , clang::QualType type );
8976
9077// Given a callee expression `Fn`, if the call is through a function pointer,
9178// try to find the declaration of the corresponding function pointer type,
9279// so that we can recover argument names from it.
9380// FIXME: This function is mostly duplicated in SemaCodeComplete.cpp; unify.
94- clang::FunctionProtoTypeLoc getPrototypeLoc (clang::Expr* Fn );
81+ clang::FunctionProtoTypeLoc proto_type_loc (clang::Expr* expr );
9582
9683} // namespace clice::ast
0 commit comments