Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REF_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REF_H
14 #include "clang/Index/IndexSymbol.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/Hashing.h"
17 #include "llvm/Support/Allocator.h"
18 #include "llvm/Support/StringSaver.h"
19 #include "llvm/Support/raw_ostream.h"
72 return static_cast<RefKind>(static_cast<uint8_t>(L) |
73 static_cast<uint8_t>(R));
77 return static_cast<RefKind>(static_cast<uint8_t>(A) &
78 static_cast<uint8_t>(B));
100 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Ref &);
118 size_t size()
const {
return Refs.size(); }
120 bool empty()
const {
return Refs.empty(); }
123 return sizeof(*this) + Arena.getTotalMemory() +
143 friend struct llvm::DenseMapInfo<Entry>;
145 llvm::BumpPtrAllocator
Arena;
146 llvm::UniqueStringSaver UniqueStrings;
147 llvm::DenseSet<Entry> Entries;
155 llvm::BumpPtrAllocator
Arena;
156 std::vector<value_type>
Refs;
165 template <>
struct DenseMapInfo<
clang::clangd::RefSlab::Builder::Entry> {
166 using Entry = clang::clangd::RefSlab::Builder::Entry;
176 return llvm::hash_combine(
177 Val.Symbol, reinterpret_cast<uintptr_t>(Val.Reference.Location.FileURI),
178 Val.Reference.Location.Start.rep(), Val.Reference.Location.End.rep());
181 return std::tie(LHS.Symbol, LHS.Reference.Location.FileURI,
182 LHS.Reference.Kind) ==
183 std::tie(RHS.Symbol, RHS.Reference.Location.FileURI,
184 RHS.Reference.Kind) &&
185 LHS.Reference.Location.Start == RHS.Reference.Location.Start &&
186 LHS.Reference.Location.End == RHS.Reference.Location.End;
191 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REF_H
Some operations such as code completion produce a set of candidates.
RefKind
Describes the kind of a cross-reference.
const_iterator end() const
RefSlab::Builder is a mutable container that can 'freeze' to RefSlab.
static Entry getEmptyKey()
An efficient structure of storing large set of symbol references in memory.
DeclRelationSet operator&(DeclRelation L, DeclRelation R)
static bool isEqual(const Entry &LHS, const Entry &RHS)
std::pair< SymbolID, llvm::ArrayRef< Ref > > value_type
clang::clangd::RefSlab::Builder::Entry Entry
SymbolLocation Location
The source location where the symbol is named.
IncludeGraphNode::SourceFlag & operator|=(IncludeGraphNode::SourceFlag &A, IncludeGraphNode::SourceFlag B)
The class presents a C++ symbol, e.g.
RefSlab build() &&
Consumes the builder to finalize the slab.
void insert(const SymbolID &ID, const Ref &S)
Adds a ref to the slab. Deep copy: Strings will be owned by the slab.
std::array< uint8_t, 20 > SymbolID
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
static unsigned getHashValue(const Entry &Val)
std::vector< value_type >::const_iterator const_iterator
Represents a symbol occurrence in the source file.
const_iterator begin() const
DeclRelationSet operator|(DeclRelation L, DeclRelation R)
RefSlab & operator=(RefSlab &&RHS)=default
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::BumpPtrAllocator Arena
bool operator<(const Ref &L, const Ref &R)
size_t size() const
Gets the number of symbols.
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
static Entry getTombstoneKey()