9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REF_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REF_H
14#include "llvm/ADT/Hashing.h"
15#include "llvm/Support/Allocator.h"
16#include "llvm/Support/StringSaver.h"
17#include "llvm/Support/raw_ostream.h"
73 return static_cast<RefKind>(
static_cast<uint8_t
>(L) |
74 static_cast<uint8_t
>(R));
78 return static_cast<RefKind>(
static_cast<uint8_t
>(A) &
79 static_cast<uint8_t
>(B));
99 return std::tie(L.Location, L.Kind, L.Container) <
103 return std::tie(L.Location, L.Kind, L.Container) ==
107llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Ref &);
125 size_t size()
const {
return Refs.size(); }
127 bool empty()
const {
return Refs.empty(); }
130 return sizeof(*this) + Arena.getTotalMemory() +
150 friend struct llvm::DenseMapInfo<
Entry>;
152 llvm::BumpPtrAllocator
Arena;
153 llvm::UniqueStringSaver UniqueStrings;
154 llvm::DenseSet<Entry> Entries;
158 RefSlab(std::vector<value_type> Refs, llvm::BumpPtrAllocator
Arena,
160 :
Arena(std::move(
Arena)), Refs(std::move(Refs)), NumRefs(NumRefs) {}
162 llvm::BumpPtrAllocator
Arena;
163 std::vector<value_type> Refs;
172template <>
struct DenseMapInfo<
clang::clangd::RefSlab::Builder::Entry> {
173 using Entry = clang::clangd::RefSlab::Builder::Entry;
183 return llvm::hash_combine(
184 Val.Symbol,
reinterpret_cast<uintptr_t
>(Val.Reference.Location.FileURI),
185 Val.Reference.Location.Start.rep(), Val.Reference.Location.End.rep());
188 return std::tie(LHS.Symbol, LHS.Reference.Location.FileURI,
189 LHS.Reference.Kind) ==
190 std::tie(RHS.Symbol, RHS.Reference.Location.FileURI,
191 RHS.Reference.Kind) &&
192 LHS.Reference.Location.Start == RHS.Reference.Location.Start &&
193 LHS.Reference.Location.End == RHS.Reference.Location.End;
llvm::BumpPtrAllocator Arena
RefSlab::Builder is a mutable container that can 'freeze' to RefSlab.
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.
An efficient structure of storing large set of symbol references in memory.
std::pair< SymbolID, llvm::ArrayRef< Ref > > value_type
RefSlab(RefSlab &&Slab)=default
const_iterator end() const
std::vector< value_type >::const_iterator const_iterator
size_t size() const
Gets the number of symbols.
RefSlab & operator=(RefSlab &&RHS)=default
const_iterator begin() const
DeclRelationSet operator&(DeclRelation L, DeclRelation R)
bool operator==(const Inclusion &LHS, const Inclusion &RHS)
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
DeclRelationSet operator|(DeclRelation L, DeclRelation R)
bool operator<(const Ref &L, const Ref &R)
RefKind
Describes the kind of a cross-reference.
IncludeGraphNode::SourceFlag & operator|=(IncludeGraphNode::SourceFlag &A, IncludeGraphNode::SourceFlag B)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Some operations such as code completion produce a set of candidates.
Represents a symbol occurrence in the source file.
SymbolID Container
The ID of the symbol whose definition contains this reference.
SymbolLocation Location
The source location where the symbol is named.
The class presents a C++ symbol, e.g.
clang::clangd::RefSlab::Builder::Entry Entry
static Entry getTombstoneKey()
static Entry getEmptyKey()
static unsigned getHashValue(const Entry &Val)
static bool isEqual(const Entry &LHS, const Entry &RHS)