Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Sema/TypeLocBuilder.h
Line
Count
Source (jump to first uncovered line)
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, NumBytesAtAlign8;
44
45
public:
46
  TypeLocBuilder()
47
      : Buffer(InlineBuffer), Capacity(InlineCapacity), Index(InlineCapacity),
48
21.4M
        NumBytesAtAlign4(0), NumBytesAtAlign8(0) {}
49
50
21.4M
  ~TypeLocBuilder() {
51
21.4M
    if (Buffer != InlineBuffer)
52
1.82M
      delete[] Buffer;
53
21.4M
  }
54
55
  /// Ensures that this buffer has at least as much capacity as described.
56
13.9M
  void reserve(size_t Requested) {
57
13.9M
    if (Requested > Capacity)
58
      // For now, match the request exactly.
59
1.05M
      grow(Requested);
60
13.9M
  }
61
62
  /// Pushes a copy of the given TypeLoc onto this builder.  The builder
63
  /// must be empty for this to work.
64
  void pushFullCopy(TypeLoc L);
65
66
  /// Pushes space for a typespec TypeLoc.  Invalidates any TypeLocs
67
  /// previously retrieved from this builder.
68
1.67M
  TypeSpecTypeLoc pushTypeSpec(QualType T) {
69
1.67M
    size_t LocalSize = TypeSpecTypeLoc::LocalDataSize;
70
1.67M
    unsigned LocalAlign = TypeSpecTypeLoc::LocalDataAlignment;
71
1.67M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TypeSpecTypeLoc>();
72
1.67M
  }
73
74
  /// Resets this builder to the newly-initialized state.
75
0
  void clear() {
76
0
#ifndef NDEBUG
77
0
    LastTy = QualType();
78
0
#endif
79
0
    Index = Capacity;
80
0
    NumBytesAtAlign4 = NumBytesAtAlign8 = 0;
81
0
  }
82
83
  /// Tell the TypeLocBuilder that the type it is storing has been
84
  /// modified in some safe way that doesn't affect type-location information.
85
2.18M
  void TypeWasModifiedSafely(QualType T) {
86
2.18M
#ifndef NDEBUG
87
2.18M
    LastTy = T;
88
2.18M
#endif
89
2.18M
  }
90
91
  /// Pushes space for a new TypeLoc of the given type.  Invalidates
92
  /// any TypeLocs previously retrieved from this builder.
93
23.7M
  template <class TyLocType> TyLocType push(QualType T) {
94
23.7M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
23.7M
    size_t LocalSize = Loc.getLocalDataSize();
96
23.7M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
23.7M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
23.7M
  }
clang::ObjCObjectPointerTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
90
  template <class TyLocType> TyLocType push(QualType T) {
94
90
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
90
    size_t LocalSize = Loc.getLocalDataSize();
96
90
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
90
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
90
  }
clang::DecayedTypeLoc clang::TypeLocBuilder::push<clang::DecayedTypeLoc>(clang::QualType)
Line
Count
Source
93
1.06k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.06k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.06k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.06k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.06k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.06k
  }
clang::ArrayTypeLoc clang::TypeLocBuilder::push<clang::ArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
11.4k
  template <class TyLocType> TyLocType push(QualType T) {
94
11.4k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
11.4k
    size_t LocalSize = Loc.getLocalDataSize();
96
11.4k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
11.4k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
11.4k
  }
clang::IncompleteArrayTypeLoc clang::TypeLocBuilder::push<clang::IncompleteArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
4.62k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.62k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.62k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.62k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.62k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.62k
  }
clang::AtomicTypeLoc clang::TypeLocBuilder::push<clang::AtomicTypeLoc>(clang::QualType)
Line
Count
Source
93
617
  template <class TyLocType> TyLocType push(QualType T) {
94
617
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
617
    size_t LocalSize = Loc.getLocalDataSize();
96
617
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
617
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
617
  }
clang::AttributedTypeLoc clang::TypeLocBuilder::push<clang::AttributedTypeLoc>(clang::QualType)
Line
Count
Source
93
366
  template <class TyLocType> TyLocType push(QualType T) {
94
366
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
366
    size_t LocalSize = Loc.getLocalDataSize();
96
366
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
366
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
366
  }
clang::BitIntTypeLoc clang::TypeLocBuilder::push<clang::BitIntTypeLoc>(clang::QualType)
Line
Count
Source
93
150
  template <class TyLocType> TyLocType push(QualType T) {
94
150
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
150
    size_t LocalSize = Loc.getLocalDataSize();
96
150
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
150
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
150
  }
clang::BlockPointerTypeLoc clang::TypeLocBuilder::push<clang::BlockPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
14
  template <class TyLocType> TyLocType push(QualType T) {
94
14
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
14
    size_t LocalSize = Loc.getLocalDataSize();
96
14
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
14
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
14
  }
clang::BuiltinTypeLoc clang::TypeLocBuilder::push<clang::BuiltinTypeLoc>(clang::QualType)
Line
Count
Source
93
459k
  template <class TyLocType> TyLocType push(QualType T) {
94
459k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
459k
    size_t LocalSize = Loc.getLocalDataSize();
96
459k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
459k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
459k
  }
Unexecuted instantiation: clang::ComplexTypeLoc clang::TypeLocBuilder::push<clang::ComplexTypeLoc>(clang::QualType)
clang::DecltypeTypeLoc clang::TypeLocBuilder::push<clang::DecltypeTypeLoc>(clang::QualType)
Line
Count
Source
93
169k
  template <class TyLocType> TyLocType push(QualType T) {
94
169k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
169k
    size_t LocalSize = Loc.getLocalDataSize();
96
169k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
169k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
169k
  }
clang::DependentTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DependentTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
24.3k
  template <class TyLocType> TyLocType push(QualType T) {
94
24.3k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
24.3k
    size_t LocalSize = Loc.getLocalDataSize();
96
24.3k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
24.3k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
24.3k
  }
clang::TemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::TemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
8.15M
  template <class TyLocType> TyLocType push(QualType T) {
94
8.15M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
8.15M
    size_t LocalSize = Loc.getLocalDataSize();
96
8.15M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
8.15M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
8.15M
  }
clang::AutoTypeLoc clang::TypeLocBuilder::push<clang::AutoTypeLoc>(clang::QualType)
Line
Count
Source
93
105k
  template <class TyLocType> TyLocType push(QualType T) {
94
105k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
105k
    size_t LocalSize = Loc.getLocalDataSize();
96
105k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
105k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
105k
  }
clang::DeducedTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DeducedTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
819
  template <class TyLocType> TyLocType push(QualType T) {
94
819
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
819
    size_t LocalSize = Loc.getLocalDataSize();
96
819
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
819
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
819
  }
Unexecuted instantiation: clang::DependentAddressSpaceTypeLoc clang::TypeLocBuilder::push<clang::DependentAddressSpaceTypeLoc>(clang::QualType)
clang::DependentBitIntTypeLoc clang::TypeLocBuilder::push<clang::DependentBitIntTypeLoc>(clang::QualType)
Line
Count
Source
93
1
  template <class TyLocType> TyLocType push(QualType T) {
94
1
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1
    size_t LocalSize = Loc.getLocalDataSize();
96
1
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1
  }
clang::DependentNameTypeLoc clang::TypeLocBuilder::push<clang::DependentNameTypeLoc>(clang::QualType)
Line
Count
Source
93
732k
  template <class TyLocType> TyLocType push(QualType T) {
94
732k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
732k
    size_t LocalSize = Loc.getLocalDataSize();
96
732k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
732k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
732k
  }
clang::DependentSizedExtVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedExtVectorTypeLoc>(clang::QualType)
Line
Count
Source
93
2
  template <class TyLocType> TyLocType push(QualType T) {
94
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
2
    size_t LocalSize = Loc.getLocalDataSize();
96
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
2
  }
clang::ExtVectorTypeLoc clang::TypeLocBuilder::push<clang::ExtVectorTypeLoc>(clang::QualType)
Line
Count
Source
93
121
  template <class TyLocType> TyLocType push(QualType T) {
94
121
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
121
    size_t LocalSize = Loc.getLocalDataSize();
96
121
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
121
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
121
  }
Unexecuted instantiation: clang::DependentVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentVectorTypeLoc>(clang::QualType)
clang::VectorTypeLoc clang::TypeLocBuilder::push<clang::VectorTypeLoc>(clang::QualType)
Line
Count
Source
93
45
  template <class TyLocType> TyLocType push(QualType T) {
94
45
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
45
    size_t LocalSize = Loc.getLocalDataSize();
96
45
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
45
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
45
  }
Unexecuted instantiation: clang::FunctionNoProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionNoProtoTypeLoc>(clang::QualType)
clang::PackExpansionTypeLoc clang::TypeLocBuilder::push<clang::PackExpansionTypeLoc>(clang::QualType)
Line
Count
Source
93
274k
  template <class TyLocType> TyLocType push(QualType T) {
94
274k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
274k
    size_t LocalSize = Loc.getLocalDataSize();
96
274k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
274k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
274k
  }
clang::FunctionProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionProtoTypeLoc>(clang::QualType)
Line
Count
Source
93
1.12M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.12M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.12M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.12M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.12M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.12M
  }
clang::MacroQualifiedTypeLoc clang::TypeLocBuilder::push<clang::MacroQualifiedTypeLoc>(clang::QualType)
Line
Count
Source
93
23
  template <class TyLocType> TyLocType push(QualType T) {
94
23
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
23
    size_t LocalSize = Loc.getLocalDataSize();
96
23
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
23
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
23
  }
clang::ConstantMatrixTypeLoc clang::TypeLocBuilder::push<clang::ConstantMatrixTypeLoc>(clang::QualType)
Line
Count
Source
93
130
  template <class TyLocType> TyLocType push(QualType T) {
94
130
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
130
    size_t LocalSize = Loc.getLocalDataSize();
96
130
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
130
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
130
  }
clang::MatrixTypeLoc clang::TypeLocBuilder::push<clang::MatrixTypeLoc>(clang::QualType)
Line
Count
Source
93
233
  template <class TyLocType> TyLocType push(QualType T) {
94
233
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
233
    size_t LocalSize = Loc.getLocalDataSize();
96
233
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
233
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
233
  }
clang::AdjustedTypeLoc clang::TypeLocBuilder::push<clang::AdjustedTypeLoc>(clang::QualType)
Line
Count
Source
93
2
  template <class TyLocType> TyLocType push(QualType T) {
94
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
2
    size_t LocalSize = Loc.getLocalDataSize();
96
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
2
  }
clang::MemberPointerTypeLoc clang::TypeLocBuilder::push<clang::MemberPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
545
  template <class TyLocType> TyLocType push(QualType T) {
94
545
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
545
    size_t LocalSize = Loc.getLocalDataSize();
96
545
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
545
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
545
  }
clang::ObjCObjectTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectTypeLoc>(clang::QualType)
Line
Count
Source
93
15
  template <class TyLocType> TyLocType push(QualType T) {
94
15
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
15
    size_t LocalSize = Loc.getLocalDataSize();
96
15
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
15
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
15
  }
Unexecuted instantiation: clang::ObjCTypeParamTypeLoc clang::TypeLocBuilder::push<clang::ObjCTypeParamTypeLoc>(clang::QualType)
clang::ParenTypeLoc clang::TypeLocBuilder::push<clang::ParenTypeLoc>(clang::QualType)
Line
Count
Source
93
8.64k
  template <class TyLocType> TyLocType push(QualType T) {
94
8.64k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
8.64k
    size_t LocalSize = Loc.getLocalDataSize();
96
8.64k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
8.64k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
8.64k
  }
Unexecuted instantiation: clang::PipeTypeLoc clang::TypeLocBuilder::push<clang::PipeTypeLoc>(clang::QualType)
clang::PointerTypeLoc clang::TypeLocBuilder::push<clang::PointerTypeLoc>(clang::QualType)
Line
Count
Source
93
471k
  template <class TyLocType> TyLocType push(QualType T) {
94
471k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
471k
    size_t LocalSize = Loc.getLocalDataSize();
96
471k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
471k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
471k
  }
clang::LValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::LValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
842k
  template <class TyLocType> TyLocType push(QualType T) {
94
842k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
842k
    size_t LocalSize = Loc.getLocalDataSize();
96
842k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
842k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
842k
  }
clang::RValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::RValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
309k
  template <class TyLocType> TyLocType push(QualType T) {
94
309k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
309k
    size_t LocalSize = Loc.getLocalDataSize();
96
309k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
309k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
309k
  }
clang::SubstTemplateTypeParmPackTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmPackTypeLoc>(clang::QualType)
Line
Count
Source
93
19.3k
  template <class TyLocType> TyLocType push(QualType T) {
94
19.3k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
19.3k
    size_t LocalSize = Loc.getLocalDataSize();
96
19.3k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
19.3k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
19.3k
  }
clang::SubstTemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
5.98M
  template <class TyLocType> TyLocType push(QualType T) {
94
5.98M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
5.98M
    size_t LocalSize = Loc.getLocalDataSize();
96
5.98M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
5.98M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
5.98M
  }
clang::EnumTypeLoc clang::TypeLocBuilder::push<clang::EnumTypeLoc>(clang::QualType)
Line
Count
Source
93
8.27k
  template <class TyLocType> TyLocType push(QualType T) {
94
8.27k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
8.27k
    size_t LocalSize = Loc.getLocalDataSize();
96
8.27k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
8.27k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
8.27k
  }
clang::RecordTypeLoc clang::TypeLocBuilder::push<clang::RecordTypeLoc>(clang::QualType)
Line
Count
Source
93
169k
  template <class TyLocType> TyLocType push(QualType T) {
94
169k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
169k
    size_t LocalSize = Loc.getLocalDataSize();
96
169k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
169k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
169k
  }
clang::TemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::TemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
2.11M
  template <class TyLocType> TyLocType push(QualType T) {
94
2.11M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
2.11M
    size_t LocalSize = Loc.getLocalDataSize();
96
2.11M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
2.11M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
2.11M
  }
clang::TypeOfExprTypeLoc clang::TypeLocBuilder::push<clang::TypeOfExprTypeLoc>(clang::QualType)
Line
Count
Source
93
321
  template <class TyLocType> TyLocType push(QualType T) {
94
321
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
321
    size_t LocalSize = Loc.getLocalDataSize();
96
321
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
321
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
321
  }
clang::TypeOfTypeLoc clang::TypeLocBuilder::push<clang::TypeOfTypeLoc>(clang::QualType)
Line
Count
Source
93
2
  template <class TyLocType> TyLocType push(QualType T) {
94
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
2
    size_t LocalSize = Loc.getLocalDataSize();
96
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
2
  }
clang::TypedefTypeLoc clang::TypeLocBuilder::push<clang::TypedefTypeLoc>(clang::QualType)
Line
Count
Source
93
1.53M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.53M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.53M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.53M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.53M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.53M
  }
clang::UnaryTransformTypeLoc clang::TypeLocBuilder::push<clang::UnaryTransformTypeLoc>(clang::QualType)
Line
Count
Source
93
1.06k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.06k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.06k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.06k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.06k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.06k
  }
clang::ElaboratedTypeLoc clang::TypeLocBuilder::push<clang::ElaboratedTypeLoc>(clang::QualType)
Line
Count
Source
93
1.21M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.21M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.21M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.21M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.21M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.21M
  }
clang::ReferenceTypeLoc clang::TypeLocBuilder::push<clang::ReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
115
  template <class TyLocType> TyLocType push(QualType T) {
94
115
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
115
    size_t LocalSize = Loc.getLocalDataSize();
96
115
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
115
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
115
  }
clang::QualifiedTypeLoc clang::TypeLocBuilder::push<clang::QualifiedTypeLoc>(clang::QualType)
Line
Count
Source
93
131
  template <class TyLocType> TyLocType push(QualType T) {
94
131
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
131
    size_t LocalSize = Loc.getLocalDataSize();
96
131
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
131
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
131
  }
clang::ConstantArrayTypeLoc clang::TypeLocBuilder::push<clang::ConstantArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
8
  template <class TyLocType> TyLocType push(QualType T) {
94
8
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
8
    size_t LocalSize = Loc.getLocalDataSize();
96
8
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
8
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
8
  }
clang::DependentSizedArrayTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
22
  template <class TyLocType> TyLocType push(QualType T) {
94
22
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
22
    size_t LocalSize = Loc.getLocalDataSize();
96
22
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
22
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
22
  }
Unexecuted instantiation: clang::VariableArrayTypeLoc clang::TypeLocBuilder::push<clang::VariableArrayTypeLoc>(clang::QualType)
Unexecuted instantiation: clang::BTFTagAttributedTypeLoc clang::TypeLocBuilder::push<clang::BTFTagAttributedTypeLoc>(clang::QualType)
clang::InjectedClassNameTypeLoc clang::TypeLocBuilder::push<clang::InjectedClassNameTypeLoc>(clang::QualType)
Line
Count
Source
93
1.14k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.14k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.14k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.14k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.14k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.14k
  }
Unexecuted instantiation: clang::DependentSizedMatrixTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedMatrixTypeLoc>(clang::QualType)
clang::ObjCInterfaceTypeLoc clang::TypeLocBuilder::push<clang::ObjCInterfaceTypeLoc>(clang::QualType)
Line
Count
Source
93
28
  template <class TyLocType> TyLocType push(QualType T) {
94
28
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
28
    size_t LocalSize = Loc.getLocalDataSize();
96
28
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
28
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
28
  }
clang::UnresolvedUsingTypeLoc clang::TypeLocBuilder::push<clang::UnresolvedUsingTypeLoc>(clang::QualType)
Line
Count
Source
93
1
  template <class TyLocType> TyLocType push(QualType T) {
94
1
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1
    size_t LocalSize = Loc.getLocalDataSize();
96
1
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1
  }
Unexecuted instantiation: clang::UsingTypeLoc clang::TypeLocBuilder::push<clang::UsingTypeLoc>(clang::QualType)
99
100
  /// Creates a TypeSourceInfo for the given type.
101
18.9M
  TypeSourceInfo *getTypeSourceInfo(ASTContext& Context, QualType T) {
102
18.9M
#ifndef NDEBUG
103
18.9M
    assert(T == LastTy && "type doesn't match last type pushed!");
104
0
#endif
105
106
0
    size_t FullDataSize = Capacity - Index;
107
18.9M
    TypeSourceInfo *DI = Context.CreateTypeSourceInfo(T, FullDataSize);
108
18.9M
    memcpy(DI->getTypeLoc().getOpaqueData(), &Buffer[Index], FullDataSize);
109
18.9M
    return DI;
110
18.9M
  }
111
112
  /// Copies the type-location information to the given AST context and
113
  /// returns a \c TypeLoc referring into the AST context.
114
2.04M
  TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) {
115
2.04M
#ifndef NDEBUG
116
2.04M
    assert(T == LastTy && "type doesn't match last type pushed!");
117
0
#endif
118
119
0
    size_t FullDataSize = Capacity - Index;
120
2.04M
    void *Mem = Context.Allocate(FullDataSize);
121
2.04M
    memcpy(Mem, &Buffer[Index], FullDataSize);
122
2.04M
    return TypeLoc(T, Mem);
123
2.04M
  }
124
125
private:
126
127
  TypeLoc pushImpl(QualType T, size_t LocalSize, unsigned LocalAlignment);
128
129
  /// Grow to the given capacity.
130
  void grow(size_t NewCapacity);
131
132
  /// Retrieve a temporary TypeLoc that refers into this \c TypeLocBuilder
133
  /// object.
134
  ///
135
  /// The resulting \c TypeLoc should only be used so long as the
136
  /// \c TypeLocBuilder is active and has not had more type information
137
  /// pushed into it.
138
25.4M
  TypeLoc getTemporaryTypeLoc(QualType T) {
139
25.4M
#ifndef NDEBUG
140
25.4M
    assert(LastTy == T && "type doesn't match last type pushed!");
141
0
#endif
142
0
    return TypeLoc(T, &Buffer[Index]);
143
25.4M
  }
144
};
145
146
}
147
148
#endif