clang 20.0.0git
TypeLocBuilder.h
Go to the documentation of this file.
1//===--- TypeLocBuilder.h - Type Source Info collector ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines TypeLocBuilder, a class for building TypeLocs
10// bottom-up.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_SEMA_TYPELOCBUILDER_H
15#define LLVM_CLANG_LIB_SEMA_TYPELOCBUILDER_H
16
18#include "clang/AST/TypeLoc.h"
19
20namespace clang {
21
23 enum { InlineCapacity = 8 * sizeof(SourceLocation) };
24
25 /// The underlying location-data buffer. Data grows from the end
26 /// of the buffer backwards.
27 char *Buffer;
28
29 /// The capacity of the current buffer.
30 size_t Capacity;
31
32 /// The index of the first occupied byte in the buffer.
33 size_t Index;
34
35#ifndef NDEBUG
36 /// The last type pushed on this builder.
37 QualType LastTy;
38#endif
39
40 /// The inline buffer.
41 enum { BufferMaxAlignment = alignof(void *) };
42 alignas(BufferMaxAlignment) char InlineBuffer[InlineCapacity];
43 unsigned NumBytesAtAlign4;
44 bool AtAlign8;
45
46public:
48 : Buffer(InlineBuffer), Capacity(InlineCapacity), Index(InlineCapacity),
49 NumBytesAtAlign4(0), AtAlign8(false) {}
50
52 if (Buffer != InlineBuffer)
53 delete[] Buffer;
54 }
55
56 TypeLocBuilder(const TypeLocBuilder &) = delete;