clang
20.0.0git
lib
Sema
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
17
#include "
clang/AST/ASTContext.h
"
18
#include "
clang/AST/TypeLoc.h
"
19
20
namespace
clang
{
21
22
class
TypeLocBuilder
{
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
46
public
:
47
TypeLocBuilder
()
48
: Buffer(InlineBuffer), Capacity(InlineCapacity), Index(InlineCapacity),
49
NumBytesAtAlign4(0), AtAlign8(
false
) {}
50
51
~TypeLocBuilder
() {
52
if
(Buffer != InlineBuffer)
53
delete
[] Buffer;
54
}
55
56
TypeLocBuilder
(
const
TypeLocBuilder
&) =
delete
;