Coverage Report

Created: 2021-01-23 06:44

/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.7M
        NumBytesAtAlign4(0), NumBytesAtAlign8(0) {}
49
50
15.7M
  ~TypeLocBuilder() {
51
15.7M
    if (Buffer != InlineBuffer)
52
1.37M
      delete[] Buffer;
53
15.7M
  }
54
55
  /// Ensures that this buffer has at least as much capacity as described.
56
10.2M
  void reserve(size_t Requested) {
57
10.2M
    if (Requested > Capacity)
58
      // For now, match the request exactly.
59
889k
      grow(Requested);
60
10.2M
  }
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.34M
  TypeSpecTypeLoc pushTypeSpec(QualType T) {
69
1.34M
    size_t LocalSize = TypeSpecTypeLoc::LocalDataSize;
70
1.34M
    unsigned LocalAlign = TypeSpecTypeLoc::LocalDataAlignment;
71
1.34M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TypeSpecTypeLoc>();
72
1.34M
  }
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.63M
  void TypeWasModifiedSafely(QualType T) {
86
1.63M
#ifndef NDEBUG
87
1.63M
    LastTy = T;
88
1.63M
#endif
89
1.63M
  }
90
91
  /// Pushes space for a new TypeLoc of the given type.  Invalidates
92
  /// any TypeLocs previously retrieved from this builder.
93
17.5M
  template <class TyLocType> TyLocType push(QualType T) {
94
17.5M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
17.5M
    size_t LocalSize = Loc.getLocalDataSize();
96
17.5M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
17.5M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
17.5M
  }
clang::ObjCObjectPointerTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
88
  template <class TyLocType> TyLocType push(QualType T) {
94
88
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
88
    size_t LocalSize = Loc.getLocalDataSize();
96
88
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
88
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
88
  }
clang::ArrayTypeLoc clang::TypeLocBuilder::push<clang::ArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
9.98k
  template <class TyLocType> TyLocType push(QualType T) {
94
9.98k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
9.98k
    size_t LocalSize = Loc.getLocalDataSize();
96
9.98k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
9.98k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
9.98k
  }
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
109
  template <class TyLocType> TyLocType push(QualType T) {
94
109
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
109
    size_t LocalSize = Loc.getLocalDataSize();
96
109
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
109
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
109
  }
clang::QualifiedTypeLoc clang::TypeLocBuilder::push<clang::QualifiedTypeLoc>(clang::QualType)
Line
Count
Source
93
6.40k
  template <class TyLocType> TyLocType push(QualType T) {
94
6.40k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
6.40k
    size_t LocalSize = Loc.getLocalDataSize();
96
6.40k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
6.40k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
6.40k
  }
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.07k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.07k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.07k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.07k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.07k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.07k
  }
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.39k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.39k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.39k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.39k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.39k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.39k
  }
Unexecuted instantiation: clang::VariableArrayTypeLoc clang::TypeLocBuilder::push<clang::VariableArrayTypeLoc>(clang::QualType)
clang::AtomicTypeLoc clang::TypeLocBuilder::push<clang::AtomicTypeLoc>(clang::QualType)
Line
Count
Source
93
562
  template <class TyLocType> TyLocType push(QualType T) {
94
562
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
562
    size_t LocalSize = Loc.getLocalDataSize();
96
562
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
562
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
562
  }
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
381k
  template <class TyLocType> TyLocType push(QualType T) {
94
381k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
381k
    size_t LocalSize = Loc.getLocalDataSize();
96
381k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
381k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
381k
  }
Unexecuted instantiation: clang::ComplexTypeLoc clang::TypeLocBuilder::push<clang::ComplexTypeLoc>(clang::QualType)
clang::DecltypeTypeLoc clang::TypeLocBuilder::push<clang::DecltypeTypeLoc>(clang::QualType)
Line
Count
Source
93
72.2k
  template <class TyLocType> TyLocType push(QualType T) {
94
72.2k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
72.2k
    size_t LocalSize = Loc.getLocalDataSize();
96
72.2k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
72.2k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
72.2k
  }
clang::AutoTypeLoc clang::TypeLocBuilder::push<clang::AutoTypeLoc>(clang::QualType)
Line
Count
Source
93
36.5k
  template <class TyLocType> TyLocType push(QualType T) {
94
36.5k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
36.5k
    size_t LocalSize = Loc.getLocalDataSize();
96
36.5k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
36.5k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
36.5k
  }
clang::DeducedTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DeducedTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
488
  template <class TyLocType> TyLocType push(QualType T) {
94
488
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
488
    size_t LocalSize = Loc.getLocalDataSize();
96
488
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
488
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
488
  }
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
388k
  template <class TyLocType> TyLocType push(QualType T) {
94
388k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
388k
    size_t LocalSize = Loc.getLocalDataSize();
96
388k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
388k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
388k
  }
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
112k
  template <class TyLocType> TyLocType push(QualType T) {
94
112k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
112k
    size_t LocalSize = Loc.getLocalDataSize();
96
112k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
112k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
112k
  }
Unexecuted instantiation: clang::DependentVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentVectorTypeLoc>(clang::QualType)
clang::ElaboratedTypeLoc clang::TypeLocBuilder::push<clang::ElaboratedTypeLoc>(clang::QualType)
Line
Count
Source
93
919k
  template <class TyLocType> TyLocType push(QualType T) {
94
919k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
919k
    size_t LocalSize = Loc.getLocalDataSize();
96
919k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
919k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
919k
  }
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
955k
  template <class TyLocType> TyLocType push(QualType T) {
94
955k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
955k
    size_t LocalSize = Loc.getLocalDataSize();
96
955k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
955k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
955k
  }
clang::InjectedClassNameTypeLoc clang::TypeLocBuilder::push<clang::InjectedClassNameTypeLoc>(clang::QualType)
Line
Count
Source
93
1.15k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.15k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.15k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.15k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.15k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.15k
  }
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
391
  template <class TyLocType> TyLocType push(QualType T) {
94
391
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
391
    size_t LocalSize = Loc.getLocalDataSize();
96
391
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
391
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
391
  }
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
176k
  template <class TyLocType> TyLocType push(QualType T) {
94
176k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
176k
    size_t LocalSize = Loc.getLocalDataSize();
96
176k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
176k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
176k
  }
clang::ParenTypeLoc clang::TypeLocBuilder::push<clang::ParenTypeLoc>(clang::QualType)
Line
Count
Source
93
4.90k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.90k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.90k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.90k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.90k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.90k
  }
Unexecuted instantiation: clang::PipeTypeLoc clang::TypeLocBuilder::push<clang::PipeTypeLoc>(clang::QualType)
clang::PointerTypeLoc clang::TypeLocBuilder::push<clang::PointerTypeLoc>(clang::QualType)
Line
Count
Source
93
324k
  template <class TyLocType> TyLocType push(QualType T) {
94
324k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
324k
    size_t LocalSize = Loc.getLocalDataSize();
96
324k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
324k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
324k
  }
clang::LValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::LValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
657k
  template <class TyLocType> TyLocType push(QualType T) {
94
657k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
657k
    size_t LocalSize = Loc.getLocalDataSize();
96
657k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
657k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
657k
  }
clang::RValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::RValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
221k
  template <class TyLocType> TyLocType push(QualType T) {
94
221k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
221k
    size_t LocalSize = Loc.getLocalDataSize();
96
221k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
221k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
221k
  }
clang::SubstTemplateTypeParmPackTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmPackTypeLoc>(clang::QualType)
Line
Count
Source
93
49.1k
  template <class TyLocType> TyLocType push(QualType T) {
94
49.1k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
49.1k
    size_t LocalSize = Loc.getLocalDataSize();
96
49.1k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
49.1k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
49.1k
  }
clang::SubstTemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
4.31M
  template <class TyLocType> TyLocType push(QualType T) {
94
4.31M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.31M
    size_t LocalSize = Loc.getLocalDataSize();
96
4.31M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.31M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.31M
  }
clang::EnumTypeLoc clang::TypeLocBuilder::push<clang::EnumTypeLoc>(clang::QualType)
Line
Count
Source
93
4.88k
  template <class TyLocType> TyLocType push(QualType T) {
94
4.88k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.88k
    size_t LocalSize = Loc.getLocalDataSize();
96
4.88k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.88k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.88k
  }
clang::RecordTypeLoc clang::TypeLocBuilder::push<clang::RecordTypeLoc>(clang::QualType)
Line
Count
Source
93
150k
  template <class TyLocType> TyLocType push(QualType T) {
94
150k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
150k
    size_t LocalSize = Loc.getLocalDataSize();
96
150k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
150k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
150k
  }
clang::TemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::TemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
5.91M
  template <class TyLocType> TyLocType push(QualType T) {
94
5.91M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
5.91M
    size_t LocalSize = Loc.getLocalDataSize();
96
5.91M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
5.91M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
5.91M
  }
clang::TemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::TemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
1.54M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.54M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.54M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.54M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.54M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.54M
  }
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.31M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.31M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.31M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.31M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.31M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.31M
  }
clang::UnaryTransformTypeLoc clang::TypeLocBuilder::push<clang::UnaryTransformTypeLoc>(clang::QualType)
Line
Count
Source
93
903
  template <class TyLocType> TyLocType push(QualType T) {
94
903
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
903
    size_t LocalSize = Loc.getLocalDataSize();
96
903
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
903
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
903
  }
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.0M
  TypeSourceInfo *getTypeSourceInfo(ASTContext& Context, QualType T) {
102
14.0M
#ifndef NDEBUG
103
14.0M
    assert(T == LastTy && "type doesn't match last type pushed!");
104
14.0M
#endif
105
106
14.0M
    size_t FullDataSize = Capacity - Index;
107
14.0M
    TypeSourceInfo *DI = Context.CreateTypeSourceInfo(T, FullDataSize);
108
14.0M
    memcpy(DI->getTypeLoc().getOpaqueData(), &Buffer[Index], FullDataSize);
109
14.0M
    return DI;
110
14.0M
  }
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.55M
  TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) {
115
1.55M
#ifndef NDEBUG
116
1.55M
    assert(T == LastTy && "type doesn't match last type pushed!");
117
1.55M
#endif
118
119
1.55M
    size_t FullDataSize = Capacity - Index;
120
1.55M
    void *Mem = Context.Allocate(FullDataSize);
121
1.55M
    memcpy(Mem, &Buffer[Index], FullDataSize);
122
1.55M
    return TypeLoc(T, Mem);
123
1.55M
  }
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.9M
  TypeLoc getTemporaryTypeLoc(QualType T) {
139
18.9M
#ifndef NDEBUG
140
18.9M
    assert(LastTy == T && "type doesn't match last type pushed!");
141
18.9M
#endif
142
18.9M
    return TypeLoc(T, &Buffer[Index]);
143
18.9M
  }
144
};
145
146
}
147
148
#endif