clang-tools 8.0.0

AST.h
Go to the documentation of this file.
1 //===--- AST.h - Utility AST functions -------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Various code that examines C++ source code using AST.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_
15 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_
16
17 #include "index/Index.h"
18 #include "clang/AST/Decl.h"
19 #include "clang/Basic/SourceLocation.h"
20
21 namespace clang {
22 class SourceManager;
23 class Decl;
24
25 namespace clangd {
26
27 /// Returns true if the declaration is considered implementation detail based on
28 /// heuristics. For example, a declaration whose name is not explicitly spelled
29 /// in code is considered implementation detail.
30 bool isImplementationDetail(const Decl *D);
31
32 /// Find the identifier source location of the given D.
33 ///
34 /// The returned location is usually the spelling location where the name of the
35 /// decl occurs in the code.
36 SourceLocation findNameLoc(const clang::Decl *D);
37
38 /// Returns the qualified name of ND. The scope doesn't contain unwritten scopes
39 /// like inline namespaces.
40 std::string printQualifiedName(const NamedDecl &ND);
41
42 /// Returns the first enclosing namespace scope starting from \p DC.
43 std::string printNamespaceScope(const DeclContext &DC);
44
45 /// Prints unqualified name of the decl for the purpose of displaying it to the
46 /// user. Anonymous decls return names of the form "(anonymous {kind})", e.g.
47 /// "(anonymous struct)" or "(anonymous namespace)".
48 std::string printName(const ASTContext &Ctx, const NamedDecl &ND);
49
50 /// Gets the symbol ID for a declaration, if possible.
51 llvm::Optional<SymbolID> getSymbolID(const Decl *D);
52
53 /// Gets the symbol ID for a macro, if possible.
54 /// Currently, this is an encoded USR of the macro, which incorporates macro
55 /// locations (e.g. file name, offset in file).
56 /// FIXME: the USR semantics might not be stable enough as the ID for index
57 /// macro (e.g. a change in definition offset can result in a different USR). We
58 /// could change these semantics in the future by reimplementing this funcure
59 /// (e.g. avoid USR for macros).
60 llvm::Optional<SymbolID> getSymbolID(const IdentifierInfo &II,
61 const MacroInfo *MI,
62 const SourceManager &SM);
63
64 } // namespace clangd
65 } // namespace clang
66
67 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_
clang::clangd::printName
std::string printName(const ASTContext &Ctx, const NamedDecl &ND)
Prints unqualified name of the decl for the purpose of displaying it to the user. ...
Definition: AST.cpp:80
clang::clangd::printQualifiedName
std::string printQualifiedName(const NamedDecl &ND)
Returns the qualified name of ND.
Definition: AST.cpp:54
clang::clangd::getSymbolID
llvm::Optional< SymbolID > getSymbolID(const Decl *D)
Gets the symbol ID for a declaration, if possible.
Definition: AST.cpp:117
Index.h
clang::clangd::printNamespaceScope
std::string printNamespaceScope(const DeclContext &DC)
Returns the first enclosing namespace scope starting from DC.
Definition: AST.cpp:109
clang::clangd::findNameLoc
SourceLocation findNameLoc(const clang::Decl *D)
Find the identifier source location of the given D.
Definition: AST.cpp:46
Ctx
Context Ctx
Definition: TUScheduler.cpp:224
D
const Decl * D
Definition: XRefs.cpp:79
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::clangd::isImplementationDetail
bool isImplementationDetail(const Decl *D)
Returns true if the declaration is considered implementation detail based on heuristics.
Definition: AST.cpp:44