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"
70 return static_cast<RefKind>(
static_cast<uint8_t
>(L) |
71 static_cast<uint8_t
>(R));
75 return static_cast<RefKind>(
static_cast<uint8_t
>(A) &
76 static_cast<uint8_t
>(B));
96 return std::tie(L.Location, L.Kind, L.Container) <
100 return std::tie(L.Location, L.Kind, L.Container) ==
104llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
const Ref &);
122 size_t size()
const {
return Refs.size(); }
124 bool empty()
const {
return Refs.empty(); }
127 return sizeof(*this) + Arena.getTotalMemory() +
147 friend struct llvm::DenseMapInfo<
Entry>;
149 llvm::BumpPtrAllocator
Arena;
150 llvm::UniqueStringSaver UniqueStrings;
151 llvm::DenseSet<Entry> Entries;
155 RefSlab(std::vector<value_type> Refs, llvm::BumpPtrAllocator
Arena,
157 :
Arena(std::move(
Arena)), Refs(std::move(Refs)), NumRefs(NumRefs) {}
159 llvm::BumpPtrAllocator
Arena;
160 std::vector<value_type> Refs;
169template <>
struct DenseMapInfo<
clang::clangd::RefSlab::Builder::Entry> {
170 using Entry = clang::clangd::RefSlab::Builder::Entry;
180 return llvm::hash_combine(
181 Val.Symbol,
reinterpret_cast<uintptr_t
>(Val.Reference.Location.FileURI),
182 Val.Reference.Location.Start.rep(), Val.Reference.Location.End.rep());
185 return std::tie(LHS.Symbol, LHS.Reference.Location.FileURI,
186 LHS.Reference.Kind) ==
187 std::tie(RHS.Symbol, RHS.Reference.Location.FileURI,
188 RHS.Reference.Kind) &&
189 LHS.Reference.Location.Start == RHS.Reference.Location.Start &&
190 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)