Coverage Report

Created: 2021-09-21 08:58

/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
16.7M
        NumBytesAtAlign4(0), NumBytesAtAlign8(0) {}
49
50
16.7M
  ~TypeLocBuilder() {
51
16.7M
    if (Buffer != InlineBuffer)
52
1.38M
      delete[] Buffer;
53
16.7M
  }
54
55
  /// Ensures that this buffer has at least as much capacity as described.
56
11.0M
  void reserve(size_t Requested) {
57
11.0M
    if (Requested > Capacity)
58
      // For now, match the request exactly.
59
820k
      grow(Requested);
60
11.0M
  }
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.39M
  TypeSpecTypeLoc pushTypeSpec(QualType T) {
69
1.39M
    size_t LocalSize = TypeSpecTypeLoc::LocalDataSize;
70
1.39M
    unsigned LocalAlign = TypeSpecTypeLoc::LocalDataAlignment;
71
1.39M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TypeSpecTypeLoc>();
72
1.39M
  }
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
1.77M
  void TypeWasModifiedSafely(QualType T) {
86
1.77M
#ifndef NDEBUG
87
1.77M
    LastTy = T;
88
1.77M
#endif
89
1.77M
  }
90
91
  /// Pushes space for a new TypeLoc of the given type.  Invalidates
92
  /// any TypeLocs previously retrieved from this builder.
93
18.7M
  template <class TyLocType> TyLocType push(QualType T) {
94
18.7M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
18.7M
    size_t LocalSize = Loc.getLocalDataSize();
96
18.7M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
18.7M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
18.7M
  }
clang::ObjCObjectPointerTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
89
  template <class TyLocType> TyLocType push(QualType T) {
94
89
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
89
    size_t LocalSize = Loc.getLocalDataSize();
96
89
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
89
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
89
  }
clang::ArrayTypeLoc clang::TypeLocBuilder::push<clang::ArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
10.2k
  template <class TyLocType> TyLocType push(QualType T) {
94
10.2k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
10.2k
    size_t LocalSize = Loc.getLocalDataSize();
96
10.2k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
10.2k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
10.2k
  }
clang::MatrixTypeLoc clang::TypeLocBuilder::push<clang::MatrixTypeLoc>(clang::QualType)
Line
Count
Source
93
212
  template <class TyLocType> TyLocType push(QualType T) {
94
212
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
212
    size_t LocalSize = Loc.getLocalDataSize();
96
212
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
212
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
212
  }
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
75
  template <class TyLocType> TyLocType push(QualType T) {
94
75
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
75
    size_t LocalSize = Loc.getLocalDataSize();
96
75
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
75
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
75
  }
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::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::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
  }
clang::IncompleteArrayTypeLoc clang::TypeLocBuilder::push<clang::IncompleteArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
4.48k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.48k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.48k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.48k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.48k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.48k
  }
Unexecuted instantiation: clang::VariableArrayTypeLoc clang::TypeLocBuilder::push<clang::VariableArrayTypeLoc>(clang::QualType)
clang::AtomicTypeLoc clang::TypeLocBuilder::push<clang::AtomicTypeLoc>(clang::QualType)
Line
Count
Source
93
584
  template <class TyLocType> TyLocType push(QualType T) {
94
584
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
584
    size_t LocalSize = Loc.getLocalDataSize();
96
584
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
584
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
584
  }
clang::AttributedTypeLoc clang::TypeLocBuilder::push<clang::AttributedTypeLoc>(clang::QualType)
Line
Count
Source
93
362
  template <class TyLocType> TyLocType push(QualType T) {
94
362
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
362
    size_t LocalSize = Loc.getLocalDataSize();
96
362
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
362
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
362
  }
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
400k
  template <class TyLocType> TyLocType push(QualType T) {
94
400k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
400k
    size_t LocalSize = Loc.getLocalDataSize();
96
400k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
400k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
400k
  }
Unexecuted instantiation: clang::ComplexTypeLoc clang::TypeLocBuilder::push<clang::ComplexTypeLoc>(clang::QualType)
clang::DecltypeTypeLoc clang::TypeLocBuilder::push<clang::DecltypeTypeLoc>(clang::QualType)
Line
Count
Source
93
129k
  template <class TyLocType> TyLocType push(QualType T) {
94
129k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
129k
    size_t LocalSize = Loc.getLocalDataSize();
96
129k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
129k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
129k
  }
clang::AutoTypeLoc clang::TypeLocBuilder::push<clang::AutoTypeLoc>(clang::QualType)
Line
Count
Source
93
40.4k
  template <class TyLocType> TyLocType push(QualType T) {
94
40.4k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
40.4k
    size_t LocalSize = Loc.getLocalDataSize();
96
40.4k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
40.4k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
40.4k
  }
clang::DeducedTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DeducedTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
507
  template <class TyLocType> TyLocType push(QualType T) {
94
507
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
507
    size_t LocalSize = Loc.getLocalDataSize();
96
507
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
507
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
507
  }
Unexecuted instantiation: clang::DependentAddressSpaceTypeLoc clang::TypeLocBuilder::push<clang::DependentAddressSpaceTypeLoc>(clang::QualType)
Unexecuted instantiation: clang::DependentExtIntTypeLoc clang::TypeLocBuilder::push<clang::DependentExtIntTypeLoc>(clang::QualType)
clang::DependentNameTypeLoc clang::TypeLocBuilder::push<clang::DependentNameTypeLoc>(clang::QualType)
Line
Count
Source
93
485k
  template <class TyLocType> TyLocType push(QualType T) {
94
485k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
485k
    size_t LocalSize = Loc.getLocalDataSize();
96
485k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
485k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
485k
  }
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::DependentTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DependentTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
30.4k
  template <class TyLocType> TyLocType push(QualType T) {
94
30.4k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
30.4k
    size_t LocalSize = Loc.getLocalDataSize();
96
30.4k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
30.4k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
30.4k
  }
Unexecuted instantiation: clang::DependentVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentVectorTypeLoc>(clang::QualType)
clang::ElaboratedTypeLoc clang::TypeLocBuilder::push<clang::ElaboratedTypeLoc>(clang::QualType)
Line
Count
Source
93
926k
  template <class TyLocType> TyLocType push(QualType T) {
94
926k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
926k
    size_t LocalSize = Loc.getLocalDataSize();
96
926k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
926k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
926k
  }
clang::ExtIntTypeLoc clang::TypeLocBuilder::push<clang::ExtIntTypeLoc>(clang::QualType)
Line
Count
Source
93
4
  template <class TyLocType> TyLocType push(QualType T) {
94
4
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4
    size_t LocalSize = Loc.getLocalDataSize();
96
4
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4
  }
Unexecuted instantiation: clang::FunctionNoProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionNoProtoTypeLoc>(clang::QualType)
clang::FunctionProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionProtoTypeLoc>(clang::QualType)
Line
Count
Source
93
987k
  template <class TyLocType> TyLocType push(QualType T) {
94
987k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
987k
    size_t LocalSize = Loc.getLocalDataSize();
96
987k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
987k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
987k
  }
clang::InjectedClassNameTypeLoc clang::TypeLocBuilder::push<clang::InjectedClassNameTypeLoc>(clang::QualType)
Line
Count
Source
93
1.20k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.20k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.20k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.20k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.20k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.20k
  }
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
  }
Unexecuted instantiation: clang::DependentSizedMatrixTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedMatrixTypeLoc>(clang::QualType)
clang::MemberPointerTypeLoc clang::TypeLocBuilder::push<clang::MemberPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
441
  template <class TyLocType> TyLocType push(QualType T) {
94
441
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
441
    size_t LocalSize = Loc.getLocalDataSize();
96
441
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
441
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
441
  }
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
  }
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
  }
Unexecuted instantiation: clang::ObjCTypeParamTypeLoc clang::TypeLocBuilder::push<clang::ObjCTypeParamTypeLoc>(clang::QualType)
clang::PackExpansionTypeLoc clang::TypeLocBuilder::push<clang::PackExpansionTypeLoc>(clang::QualType)
Line
Count
Source
93
305k
  template <class TyLocType> TyLocType push(QualType T) {
94
305k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
305k
    size_t LocalSize = Loc.getLocalDataSize();
96
305k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
305k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
305k
  }
clang::ParenTypeLoc clang::TypeLocBuilder::push<clang::ParenTypeLoc>(clang::QualType)
Line
Count
Source
93
6.33k
  template <class TyLocType> TyLocType push(QualType T) {
94
6.33k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
6.33k
    size_t LocalSize = Loc.getLocalDataSize();
96
6.33k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
6.33k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
6.33k
  }
Unexecuted instantiation: clang::PipeTypeLoc clang::TypeLocBuilder::push<clang::PipeTypeLoc>(clang::QualType)
clang::PointerTypeLoc clang::TypeLocBuilder::push<clang::PointerTypeLoc>(clang::QualType)
Line
Count
Source
93
393k
  template <class TyLocType> TyLocType push(QualType T) {
94
393k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
393k
    size_t LocalSize = Loc.getLocalDataSize();
96
393k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
393k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
393k
  }
clang::LValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::LValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
691k
  template <class TyLocType> TyLocType push(QualType T) {
94
691k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
691k
    size_t LocalSize = Loc.getLocalDataSize();
96
691k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
691k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
691k
  }
clang::RValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::RValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
233k
  template <class TyLocType> TyLocType push(QualType T) {
94
233k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
233k
    size_t LocalSize = Loc.getLocalDataSize();
96
233k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
233k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
233k
  }
clang::SubstTemplateTypeParmPackTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmPackTypeLoc>(clang::QualType)
Line
Count
Source
93
42.2k
  template <class TyLocType> TyLocType push(QualType T) {
94
42.2k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
42.2k
    size_t LocalSize = Loc.getLocalDataSize();
96
42.2k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
42.2k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
42.2k
  }
clang::SubstTemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
4.64M
  template <class TyLocType> TyLocType push(QualType T) {
94
4.64M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.64M
    size_t LocalSize = Loc.getLocalDataSize();
96
4.64M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.64M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.64M
  }
clang::EnumTypeLoc clang::TypeLocBuilder::push<clang::EnumTypeLoc>(clang::QualType)
Line
Count
Source
93
5.54k
  template <class TyLocType> TyLocType push(QualType T) {
94
5.54k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
5.54k
    size_t LocalSize = Loc.getLocalDataSize();
96
5.54k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
5.54k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
5.54k
  }
clang::RecordTypeLoc clang::TypeLocBuilder::push<clang::RecordTypeLoc>(clang::QualType)
Line
Count
Source
93
153k
  template <class TyLocType> TyLocType push(QualType T) {
94
153k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
153k
    size_t LocalSize = Loc.getLocalDataSize();
96
153k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
153k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
153k
  }
clang::TemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::TemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
6.25M
  template <class TyLocType> TyLocType push(QualType T) {
94
6.25M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
6.25M
    size_t LocalSize = Loc.getLocalDataSize();
96
6.25M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
6.25M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
6.25M
  }
clang::TemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::TemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
1.70M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.70M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.70M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.70M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.70M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.70M
  }
clang::TypeOfExprTypeLoc clang::TypeLocBuilder::push<clang::TypeOfExprTypeLoc>(clang::QualType)
Line
Count
Source
93
320
  template <class TyLocType> TyLocType push(QualType T) {
94
320
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
320
    size_t LocalSize = Loc.getLocalDataSize();
96
320
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
320
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
320
  }
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.32M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.32M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.32M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.32M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.32M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.32M
  }
clang::UnaryTransformTypeLoc clang::TypeLocBuilder::push<clang::UnaryTransformTypeLoc>(clang::QualType)
Line
Count
Source
93
964
  template <class TyLocType> TyLocType push(QualType T) {
94
964
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
964
    size_t LocalSize = Loc.getLocalDataSize();
96
964
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
964
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
964
  }
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
  }
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
  }
clang::ExtVectorTypeLoc clang::TypeLocBuilder::push<clang::ExtVectorTypeLoc>(clang::QualType)
Line
Count
Source
93
16
  template <class TyLocType> TyLocType push(QualType T) {
94
16
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
16
    size_t LocalSize = Loc.getLocalDataSize();
96
16
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
16
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
16
  }
99
100
  /// Creates a TypeSourceInfo for the given type.
101
14.9M
  TypeSourceInfo *getTypeSourceInfo(ASTContext& Context, QualType T) {
102
14.9M
#ifndef NDEBUG
103
14.9M
    assert(T == LastTy && "type doesn't match last type pushed!");
104
0
#endif
105
106
0
    size_t FullDataSize = Capacity - Index;
107
14.9M
    TypeSourceInfo *DI = Context.CreateTypeSourceInfo(T, FullDataSize);
108
14.9M
    memcpy(DI->getTypeLoc().getOpaqueData(), &Buffer[Index], FullDataSize);
109
14.9M
    return DI;
110
14.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
1.58M
  TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) {
115
1.58M
#ifndef NDEBUG
116
1.58M
    assert(T == LastTy && "type doesn't match last type pushed!");
117
0
#endif
118
119
0
    size_t FullDataSize = Capacity - Index;
120
1.58M
    void *Mem = Context.Allocate(FullDataSize);
121
1.58M
    memcpy(Mem, &Buffer[Index], FullDataSize);
122
1.58M
    return TypeLoc(T, Mem);
123
1.58M
  }
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
20.1M
  TypeLoc getTemporaryTypeLoc(QualType T) {
139
20.1M
#ifndef NDEBUG
140
20.1M
    assert(LastTy == T && "type doesn't match last type pushed!");
141
0
#endif
142
0
    return TypeLoc(T, &Buffer[Index]);
143
20.1M
  }
144
};
145
146
}
147
148
#endif