15#ifndef LLVM_LIB_CAS_DATABASEFILE_H
16#define LLVM_LIB_CAS_DATABASEFILE_H
44 explicit operator bool()
const {
return H; }
48 template <
class T>
static void check() {
50 std::is_same<
decltype(T::Header::GenericHeader),
Header>::value,
51 "T::GenericHeader should be of type TableHandle::Header");
52 static_assert(
offsetof(
typename T::Header, GenericHeader) == 0,
53 "T::GenericHeader must be the head of T::Header");
55 template <
class T>
bool is()
const {
return T::Kind == H->Kind; }
59 return T(*Region, *
reinterpret_cast<typename T::Header *
>(H));
62 template <
class T>
T cast()
const {
68 auto *Begin =
reinterpret_cast<const char *
>(H) + H->NameRelOffset;
76 *reinterpret_cast<
Header *>(Region.
data() + HeaderOffset)) {
121 size_t size()
const {
return Alloc.size(); }
125 get(std::unique_ptr<MappedFileRegionArena>
Alloc) {
135 DatabaseFile(std::unique_ptr<MappedFileRegionArena>
Alloc)
136 : DatabaseFile(*
Alloc) {
137 OwnedAlloc = std::move(
Alloc);
141 MappedFileRegionArena &
Alloc;
142 std::unique_ptr<MappedFileRegionArena> OwnedAlloc;
146 StringRef TableName,
const Twine &Msg);
149 StringRef Path, StringRef TrieName);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Prepare AGPR Alloc
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define offsetof(TYPE, MEMBER)
This file declares interface for MappedFileRegionArena, a bump pointer allocator, backed by a memory-...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Allocator for an owned mapped file region that supports thread-safe and process-safe bump pointer all...
sys::fs::mapped_file_region RegionT
Encapsulate a database file, which:
static Expected< DatabaseFile > create(const Twine &Path, uint64_t Capacity, function_ref< Error(DatabaseFile &)> NewDBConstructor)
Create the DatabaseFile at Path with Capacity.
std::optional< TableHandle > findTable(StringRef Name)
Find a table. May return null.
static constexpr uint32_t getVersion()
MappedFileRegionArena & getAlloc()
static constexpr uint32_t getMagic()
MappedFileRegion & getRegion()
const Header & getHeader()
Error addTable(TableHandle Table)
Add a table.
Generic handle for a table.
TableHandle(MappedFileRegion &Region, Header &H)
const Header & getHeader() const
StringRef getName() const
MappedFileRegion & getRegion() const
TableHandle(MappedFileRegion &Region, intptr_t HeaderOffset)
An efficient, type-erasing, non-owning reference to a callable.
Error createTableConfigError(std::errc ErrC, StringRef Path, StringRef TableName, const Twine &Msg)
MappedFileRegionArena::RegionT MappedFileRegion
Error checkTable(StringRef Label, size_t Expected, size_t Observed, StringRef Path, StringRef TrieName)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
int32_t NameRelOffset
Relative to Header.