Coverage Report

Created: 2020-09-19 12:23

/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
15.5M
        NumBytesAtAlign4(0), NumBytesAtAlign8(0) {}
49
50
15.5M
  ~TypeLocBuilder() {
51
15.5M
    if (Buffer != InlineBuffer)
52
6.49M
      delete[] Buffer;
53
15.5M
  }
54
55
  /// Ensures that this buffer has at least as much capacity as described.
56
10.1M
  void reserve(size_t Requested) {
57
10.1M
    if (Requested > Capacity)
58
      // For now, match the request exactly.
59
2.00M
      grow(Requested);
60
10.1M
  }
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.32M
  TypeSpecTypeLoc pushTypeSpec(QualType T) {
69
1.32M
    size_t LocalSize = TypeSpecTypeLoc::LocalDataSize;
70
1.32M
    unsigned LocalAlign = TypeSpecTypeLoc::LocalDataAlignment;
71
1.32M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TypeSpecTypeLoc>();
72
1.32M
  }
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.65M
  void TypeWasModifiedSafely(QualType T) {
86
1.65M
#ifndef NDEBUG
87
1.65M
    LastTy = T;
88
1.65M
#endif
89
1.65M
  }
90
91
  /// Pushes space for a new TypeLoc of the given type.  Invalidates
92
  /// any TypeLocs previously retrieved from this builder.
93
17.3M
  template <class TyLocType> TyLocType push(QualType T) {
94
17.3M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
17.3M
    size_t LocalSize = Loc.getLocalDataSize();
96
17.3M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
17.3M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
17.3M
  }
clang::ObjCObjectPointerTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
87
  template <class TyLocType> TyLocType push(QualType T) {
94
87
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
87
    size_t LocalSize = Loc.getLocalDataSize();
96
87
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
87
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
87
  }
clang::ArrayTypeLoc clang::TypeLocBuilder::push<clang::ArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
9.70k
  template <class TyLocType> TyLocType push(QualType T) {
94
9.70k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
9.70k
    size_t LocalSize = Loc.getLocalDataSize();
96
9.70k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
9.70k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
9.70k
  }
clang::MatrixTypeLoc clang::TypeLocBuilder::push<clang::MatrixTypeLoc>(clang::QualType)
Line
Count
Source
93
168
  template <class TyLocType> TyLocType push(QualType T) {
94
168
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
168
    size_t LocalSize = Loc.getLocalDataSize();
96
168
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
168
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
168
  }
clang::ReferenceTypeLoc clang::TypeLocBuilder::push<clang::ReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
107
  template <class TyLocType> TyLocType push(QualType T) {
94
107
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
107
    size_t LocalSize = Loc.getLocalDataSize();
96
107
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
107
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
107
  }
clang::QualifiedTypeLoc clang::TypeLocBuilder::push<clang::QualifiedTypeLoc>(clang::QualType)
Line
Count
Source
93
6.67k
  template <class TyLocType> TyLocType push(QualType T) {
94
6.67k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
6.67k
    size_t LocalSize = Loc.getLocalDataSize();
96
6.67k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
6.67k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
6.67k
  }
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.30k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.30k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.30k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.30k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.30k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.30k
  }
Unexecuted instantiation: clang::VariableArrayTypeLoc clang::TypeLocBuilder::push<clang::VariableArrayTypeLoc>(clang::QualType)
clang::AtomicTypeLoc clang::TypeLocBuilder::push<clang::AtomicTypeLoc>(clang::QualType)
Line
Count
Source
93
546
  template <class TyLocType> TyLocType push(QualType T) {
94
546
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
546
    size_t LocalSize = Loc.getLocalDataSize();
96
546
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
546
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
546
  }
clang::AttributedTypeLoc clang::TypeLocBuilder::push<clang::AttributedTypeLoc>(clang::QualType)
Line
Count
Source
93
338
  template <class TyLocType> TyLocType push(QualType T) {
94
338
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
338
    size_t LocalSize = Loc.getLocalDataSize();
96
338
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
338
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
338
  }
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
382k
  template <class TyLocType> TyLocType push(QualType T) {
94
382k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
382k
    size_t LocalSize = Loc.getLocalDataSize();
96
382k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
382k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
382k
  }
Unexecuted instantiation: clang::ComplexTypeLoc clang::TypeLocBuilder::push<clang::ComplexTypeLoc>(clang::QualType)
clang::DecltypeTypeLoc clang::TypeLocBuilder::push<clang::DecltypeTypeLoc>(clang::QualType)
Line
Count
Source
93
66.9k
  template <class TyLocType> TyLocType push(QualType T) {
94
66.9k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
66.9k
    size_t LocalSize = Loc.getLocalDataSize();
96
66.9k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
66.9k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
66.9k
  }
clang::AutoTypeLoc clang::TypeLocBuilder::push<clang::AutoTypeLoc>(clang::QualType)
Line
Count
Source
93
29.3k
  template <class TyLocType> TyLocType push(QualType T) {
94
29.3k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
29.3k
    size_t LocalSize = Loc.getLocalDataSize();
96
29.3k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
29.3k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
29.3k
  }
clang::DeducedTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DeducedTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
282
  template <class TyLocType> TyLocType push(QualType T) {
94
282
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
282
    size_t LocalSize = Loc.getLocalDataSize();
96
282
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
282
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
282
  }
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
395k
  template <class TyLocType> TyLocType push(QualType T) {
94
395k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
395k
    size_t LocalSize = Loc.getLocalDataSize();
96
395k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
395k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
395k
  }
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
82.3k
  template <class TyLocType> TyLocType push(QualType T) {
94
82.3k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
82.3k
    size_t LocalSize = Loc.getLocalDataSize();
96
82.3k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
82.3k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
82.3k
  }
Unexecuted instantiation: clang::DependentVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentVectorTypeLoc>(clang::QualType)
clang::ElaboratedTypeLoc clang::TypeLocBuilder::push<clang::ElaboratedTypeLoc>(clang::QualType)
Line
Count
Source
93
922k
  template <class TyLocType> TyLocType push(QualType T) {
94
922k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
922k
    size_t LocalSize = Loc.getLocalDataSize();
96
922k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
922k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
922k
  }
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
941k
  template <class TyLocType> TyLocType push(QualType T) {
94
941k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
941k
    size_t LocalSize = Loc.getLocalDataSize();
96
941k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
941k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
941k
  }
clang::InjectedClassNameTypeLoc clang::TypeLocBuilder::push<clang::InjectedClassNameTypeLoc>(clang::QualType)
Line
Count
Source
93
1.10k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.10k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.10k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.10k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.10k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.10k
  }
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
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::DependentSizedMatrixTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedMatrixTypeLoc>(clang::QualType)
clang::MemberPointerTypeLoc clang::TypeLocBuilder::push<clang::MemberPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
389
  template <class TyLocType> TyLocType push(QualType T) {
94
389
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
389
    size_t LocalSize = Loc.getLocalDataSize();
96
389
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
389
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
389
  }
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
171k
  template <class TyLocType> TyLocType push(QualType T) {
94
171k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
171k
    size_t LocalSize = Loc.getLocalDataSize();
96
171k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
171k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
171k
  }
clang::ParenTypeLoc clang::TypeLocBuilder::push<clang::ParenTypeLoc>(clang::QualType)
Line
Count
Source
93
4.77k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.77k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.77k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.77k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.77k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.77k
  }
Unexecuted instantiation: clang::PipeTypeLoc clang::TypeLocBuilder::push<clang::PipeTypeLoc>(clang::QualType)
clang::PointerTypeLoc clang::TypeLocBuilder::push<clang::PointerTypeLoc>(clang::QualType)
Line
Count
Source
93
318k
  template <class TyLocType> TyLocType push(QualType T) {
94
318k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
318k
    size_t LocalSize = Loc.getLocalDataSize();
96
318k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
318k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
318k
  }
clang::LValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::LValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
690k
  template <class TyLocType> TyLocType push(QualType T) {
94
690k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
690k
    size_t LocalSize = Loc.getLocalDataSize();
96
690k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
690k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
690k
  }
clang::RValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::RValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
231k
  template <class TyLocType> TyLocType push(QualType T) {
94
231k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
231k
    size_t LocalSize = Loc.getLocalDataSize();
96
231k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
231k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
231k
  }
clang::SubstTemplateTypeParmPackTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmPackTypeLoc>(clang::QualType)
Line
Count
Source
93
58.8k
  template <class TyLocType> TyLocType push(QualType T) {
94
58.8k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
58.8k
    size_t LocalSize = Loc.getLocalDataSize();
96
58.8k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
58.8k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
58.8k
  }
clang::SubstTemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
4.21M
  template <class TyLocType> TyLocType push(QualType T) {
94
4.21M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.21M
    size_t LocalSize = Loc.getLocalDataSize();
96
4.21M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.21M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.21M
  }
clang::EnumTypeLoc clang::TypeLocBuilder::push<clang::EnumTypeLoc>(clang::QualType)
Line
Count
Source
93
4.86k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.86k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.86k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.86k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.86k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.86k
  }
clang::RecordTypeLoc clang::TypeLocBuilder::push<clang::RecordTypeLoc>(clang::QualType)
Line
Count
Source
93
158k
  template <class TyLocType> TyLocType push(QualType T) {
94
158k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
158k
    size_t LocalSize = Loc.getLocalDataSize();
96
158k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
158k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
158k
  }
clang::TemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::TemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
5.79M
  template <class TyLocType> TyLocType push(QualType T) {
94
5.79M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
5.79M
    size_t LocalSize = Loc.getLocalDataSize();
96
5.79M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
5.79M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
5.79M
  }
clang::TemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::TemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
1.60M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.60M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.60M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.60M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.60M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.60M
  }
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.28M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.28M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.28M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.28M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.28M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.28M
  }
clang::UnaryTransformTypeLoc clang::TypeLocBuilder::push<clang::UnaryTransformTypeLoc>(clang::QualType)
Line
Count
Source
93
863
  template <class TyLocType> TyLocType push(QualType T) {
94
863
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
863
    size_t LocalSize = Loc.getLocalDataSize();
96
863
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
863
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
863
  }
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
30
  template <class TyLocType> TyLocType push(QualType T) {
94
30
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
30
    size_t LocalSize = Loc.getLocalDataSize();
96
30
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
30
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
30
  }
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
13.8M
  TypeSourceInfo *getTypeSourceInfo(ASTContext& Context, QualType T) {
102
13.8M
#ifndef NDEBUG
103
13.8M
    assert(T == LastTy && "type doesn't match last type pushed!");
104
13.8M
#endif
105
13.8M
106
13.8M
    size_t FullDataSize = Capacity - Index;
107
13.8M
    TypeSourceInfo *DI = Context.CreateTypeSourceInfo(T, FullDataSize);
108
13.8M
    memcpy(DI->getTypeLoc().getOpaqueData(), &Buffer[Index], FullDataSize);
109
13.8M
    return DI;
110
13.8M
  }
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.50M
  TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) {
115
1.50M
#ifndef NDEBUG
116
1.50M
    assert(T == LastTy && "type doesn't match last type pushed!");
117
1.50M
#endif
118
1.50M
119
1.50M
    size_t FullDataSize = Capacity - Index;
120
1.50M
    void *Mem = Context.Allocate(FullDataSize);
121
1.50M
    memcpy(Mem, &Buffer[Index], FullDataSize);
122
1.50M
    return TypeLoc(T, Mem);
123
1.50M
  }
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
18.7M
  TypeLoc getTemporaryTypeLoc(QualType T) {
139
18.7M
#ifndef NDEBUG
140
18.7M
    assert(LastTy == T && "type doesn't match last type pushed!");
141
18.7M
#endif
142
18.7M
    return TypeLoc(T, &Buffer[Index]);
143
18.7M
  }
144
};
145
146
}
147
148
#endif