9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_H
15#include "clang/Index/IndexSymbol.h"
16#include "llvm/ADT/BitmaskEnum.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/StringSaver.h"
43 index::SymbolInfo
SymInfo = index::SymbolInfo();
97 LLVM_MARK_AS_BITMASK_ENUM(
Import)
159 static_cast<uint8_t
>(B));
166llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const Symbol &S);
180 auto RawCharPointerCB = [&CB](
const char *&P) {
181 llvm::StringRef S(P);
183 assert(!S.data()[S.size()] &&
"Visited StringRef must be null-terminated");
190 CB(Include.IncludeHeader);
215 bool empty()
const {
return Symbols.empty(); }
218 return sizeof(*this) + Arena.getTotalMemory() +
219 Symbols.capacity() *
sizeof(
Symbol);
237 auto I = Symbols.find(ID);
238 return I == Symbols.end() ? nullptr : &I->second;
245 llvm::BumpPtrAllocator Arena;
247 llvm::UniqueStringSaver UniqueStrings;
249 llvm::DenseMap<SymbolID, Symbol> Symbols;
256 llvm::BumpPtrAllocator Arena;
260llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const SymbolSlab &Slab);
const Symbol * find(const SymbolID &ID)
Returns the symbol with an ID, if it exists. Valid until insert/remove.
void erase(const SymbolID &ID)
Removes the symbol with an ID, if it exists.
void insert(const Symbol &S)
Adds a symbol, overwriting any existing one with the same ID.
SymbolSlab build() &&
Consumes the builder to finalize the slab.
const_iterator begin() const
const_iterator end() const
const_iterator find(const SymbolID &SymID) const
std::vector< Symbol >::const_iterator const_iterator
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
void visitStrings(Symbol &S, const Callback &CB)
Invokes Callback with each StringRef& contained in the Symbol.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
DeclRelationSet operator|(DeclRelation L, DeclRelation R)
float quality(const Symbol &S)
Computes query-independent quality score for a Symbol.
IncludeGraphNode::SourceFlag & operator|=(IncludeGraphNode::SourceFlag &A, IncludeGraphNode::SourceFlag B)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
The class presents a C++ symbol, e.g.
@ IndexedForCodeCompletion
Whether or not this symbol is meant to be used for the code completion.
@ Deprecated
Indicates if the symbol is deprecated.
@ ImplementationDetail
Symbol is an implementation detail.
@ HasDocComment
Symbol has an attached documentation comment.
@ VisibleOutsideFile
Symbol is visible to other files (not e.g. a static helper function).
@ Include
#include "header.h"
@ Import
#import "header.h"
SymbolLocation Definition
The location of the symbol's definition, if one was found.
llvm::StringRef Type
Raw representation of the OpaqueType of the symbol, used for scoring purposes.
llvm::StringRef Documentation
Documentation including comment for the symbol declaration.
index::SymbolInfo SymInfo
The symbol information, like symbol kind.
llvm::SmallVector< IncludeHeaderWithReferences, 1 > IncludeHeaders
One Symbol can potentially be included via different headers.
llvm::StringRef Name
The unqualified name of the symbol, e.g. "bar" (for ns::bar).
llvm::StringRef Scope
The containing namespace. e.g. "" (global), "ns::" (top-level namespace).
llvm::StringRef Signature
A brief description of the symbol that can be appended in the completion candidate list.
unsigned References
The number of translation units that reference this symbol from their main file.
llvm::StringRef ReturnType
Type when this symbol is used in an expression.
llvm::StringRef TemplateSpecializationArgs
Argument list in human-readable format, will be displayed to help disambiguate between different spec...
SymbolLocation CanonicalDeclaration
The location of the preferred declaration of the symbol.
llvm::StringRef CompletionSnippetSuffix
What to insert when completing this symbol, after the symbol name.
SymbolID ID
The ID of the symbol.
SymbolOrigin Origin
Where this symbol came from. Usually an index provides a constant value.