Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/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
  llvm::AlignedCharArray<BufferMaxAlignment, InlineCapacity> InlineBuffer;
43
  unsigned NumBytesAtAlign4, NumBytesAtAlign8;
44
45
 public:
46
  TypeLocBuilder()
47
    : Buffer(InlineBuffer.buffer), Capacity(InlineCapacity),
48
      Index(InlineCapacity), NumBytesAtAlign4(0), NumBytesAtAlign8(0)
49
20.1M
  {
50
20.1M
  }
51
52
20.1M
  ~TypeLocBuilder() {
53
20.1M
    if (Buffer != InlineBuffer.buffer)
54
7.59M
      delete[] Buffer;
55
20.1M
  }
56
57
  /// Ensures that this buffer has at least as much capacity as described.
58
12.8M
  void reserve(size_t Requested) {
59
12.8M
    if (Requested > Capacity)
60
2.20M
      // For now, match the request exactly.
61
2.20M
      grow(Requested);
62
12.8M
  }
63
64
  /// Pushes a copy of the given TypeLoc onto this builder.  The builder
65
  /// must be empty for this to work.
66
  void pushFullCopy(TypeLoc L);
67
68
  /// Pushes space for a typespec TypeLoc.  Invalidates any TypeLocs
69
  /// previously retrieved from this builder.
70
2.33M
  TypeSpecTypeLoc pushTypeSpec(QualType T) {
71
2.33M
    size_t LocalSize = TypeSpecTypeLoc::LocalDataSize;
72
2.33M
    unsigned LocalAlign = TypeSpecTypeLoc::LocalDataAlignment;
73
2.33M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TypeSpecTypeLoc>();
74
2.33M
  }
75
76
  /// Resets this builder to the newly-initialized state.
77
0
  void clear() {
78
0
#ifndef NDEBUG
79
0
    LastTy = QualType();
80
0
#endif
81
0
    Index = Capacity;
82
0
    NumBytesAtAlign4 = NumBytesAtAlign8 = 0;
83
0
  }
84
85
  /// Tell the TypeLocBuilder that the type it is storing has been
86
  /// modified in some safe way that doesn't affect type-location information.
87
2.63M
  void TypeWasModifiedSafely(QualType T) {
88
#ifndef NDEBUG
89
    LastTy = T;
90
#endif
91
  }
92
93
  /// Pushes space for a new TypeLoc of the given type.  Invalidates
94
  /// any TypeLocs previously retrieved from this builder.
95
23.0M
  template <class TyLocType> TyLocType push(QualType T) {
96
23.0M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
23.0M
    size_t LocalSize = Loc.getLocalDataSize();
98
23.0M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
23.0M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
23.0M
  }
clang::InjectedClassNameTypeLoc clang::TypeLocBuilder::push<clang::InjectedClassNameTypeLoc>(clang::QualType)
Line
Count
Source
95
202
  template <class TyLocType> TyLocType push(QualType T) {
96
202
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
202
    size_t LocalSize = Loc.getLocalDataSize();
98
202
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
202
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
202
  }
clang::RecordTypeLoc clang::TypeLocBuilder::push<clang::RecordTypeLoc>(clang::QualType)
Line
Count
Source
95
327k
  template <class TyLocType> TyLocType push(QualType T) {
96
327k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
327k
    size_t LocalSize = Loc.getLocalDataSize();
98
327k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
327k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
327k
  }
clang::TypedefTypeLoc clang::TypeLocBuilder::push<clang::TypedefTypeLoc>(clang::QualType)
Line
Count
Source
95
2.05M
  template <class TyLocType> TyLocType push(QualType T) {
96
2.05M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
2.05M
    size_t LocalSize = Loc.getLocalDataSize();
98
2.05M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
2.05M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
2.05M
  }
clang::EnumTypeLoc clang::TypeLocBuilder::push<clang::EnumTypeLoc>(clang::QualType)
Line
Count
Source
95
7.28k
  template <class TyLocType> TyLocType push(QualType T) {
96
7.28k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
7.28k
    size_t LocalSize = Loc.getLocalDataSize();
98
7.28k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
7.28k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
7.28k
  }
clang::TemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::TemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
95
1.89M
  template <class TyLocType> TyLocType push(QualType T) {
96
1.89M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
1.89M
    size_t LocalSize = Loc.getLocalDataSize();
98
1.89M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
1.89M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
1.89M
  }
clang::UnresolvedUsingTypeLoc clang::TypeLocBuilder::push<clang::UnresolvedUsingTypeLoc>(clang::QualType)
Line
Count
Source
95
1
  template <class TyLocType> TyLocType push(QualType T) {
96
1
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
1
    size_t LocalSize = Loc.getLocalDataSize();
98
1
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
1
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
1
  }
clang::SubstTemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
95
5.29M
  template <class TyLocType> TyLocType push(QualType T) {
96
5.29M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
5.29M
    size_t LocalSize = Loc.getLocalDataSize();
98
5.29M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
5.29M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
5.29M
  }
clang::SubstTemplateTypeParmPackTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmPackTypeLoc>(clang::QualType)
Line
Count
Source
95
41.4k
  template <class TyLocType> TyLocType push(QualType T) {
96
41.4k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
41.4k
    size_t LocalSize = Loc.getLocalDataSize();
98
41.4k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
41.4k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
41.4k
  }
clang::DecltypeTypeLoc clang::TypeLocBuilder::push<clang::DecltypeTypeLoc>(clang::QualType)
Line
Count
Source
95
104k
  template <class TyLocType> TyLocType push(QualType T) {
96
104k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
104k
    size_t LocalSize = Loc.getLocalDataSize();
98
104k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
104k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
104k
  }
clang::DependentTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DependentTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
95
38.2k
  template <class TyLocType> TyLocType push(QualType T) {
96
38.2k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
38.2k
    size_t LocalSize = Loc.getLocalDataSize();
98
38.2k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
38.2k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
38.2k
  }
clang::TemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::TemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
95
6.68M
  template <class TyLocType> TyLocType push(QualType T) {
96
6.68M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
6.68M
    size_t LocalSize = Loc.getLocalDataSize();
98
6.68M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
6.68M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
6.68M
  }
clang::DependentNameTypeLoc clang::TypeLocBuilder::push<clang::DependentNameTypeLoc>(clang::QualType)
Line
Count
Source
95
447k
  template <class TyLocType> TyLocType push(QualType T) {
96
447k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
447k
    size_t LocalSize = Loc.getLocalDataSize();
98
447k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
447k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
447k
  }
clang::ElaboratedTypeLoc clang::TypeLocBuilder::push<clang::ElaboratedTypeLoc>(clang::QualType)
Line
Count
Source
95
1.71M
  template <class TyLocType> TyLocType push(QualType T) {
96
1.71M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
1.71M
    size_t LocalSize = Loc.getLocalDataSize();
98
1.71M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
1.71M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
1.71M
  }
clang::ObjCObjectPointerTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectPointerTypeLoc>(clang::QualType)
Line
Count
Source
95
83
  template <class TyLocType> TyLocType push(QualType T) {
96
83
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
83
    size_t LocalSize = Loc.getLocalDataSize();
98
83
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
83
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
83
  }
clang::BuiltinTypeLoc clang::TypeLocBuilder::push<clang::BuiltinTypeLoc>(clang::QualType)
Line
Count
Source
95
677k
  template <class TyLocType> TyLocType push(QualType T) {
96
677k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
677k
    size_t LocalSize = Loc.getLocalDataSize();
98
677k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
677k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
677k
  }
Unexecuted instantiation: clang::ComplexTypeLoc clang::TypeLocBuilder::push<clang::ComplexTypeLoc>(clang::QualType)
clang::PointerTypeLoc clang::TypeLocBuilder::push<clang::PointerTypeLoc>(clang::QualType)
Line
Count
Source
95
648k
  template <class TyLocType> TyLocType push(QualType T) {
96
648k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
648k
    size_t LocalSize = Loc.getLocalDataSize();
98
648k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
648k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
648k
  }
clang::BlockPointerTypeLoc clang::TypeLocBuilder::push<clang::BlockPointerTypeLoc>(clang::QualType)
Line
Count
Source
95
14
  template <class TyLocType> TyLocType push(QualType T) {
96
14
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
14
    size_t LocalSize = Loc.getLocalDataSize();
98
14
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
14
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
14
  }
clang::LValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::LValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
95
1.03M
  template <class TyLocType> TyLocType push(QualType T) {
96
1.03M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
1.03M
    size_t LocalSize = Loc.getLocalDataSize();
98
1.03M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
1.03M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
1.03M
  }
clang::RValueReferenceTypeLoc clang::TypeLocBuilder::push<clang::RValueReferenceTypeLoc>(clang::QualType)
Line
Count
Source
95
289k
  template <class TyLocType> TyLocType push(QualType T) {
96
289k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
289k
    size_t LocalSize = Loc.getLocalDataSize();
98
289k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
289k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
289k
  }
clang::AdjustedTypeLoc clang::TypeLocBuilder::push<clang::AdjustedTypeLoc>(clang::QualType)
Line
Count
Source
95
2
  template <class TyLocType> TyLocType push(QualType T) {
96
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
2
    size_t LocalSize = Loc.getLocalDataSize();
98
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
2
  }
clang::MemberPointerTypeLoc clang::TypeLocBuilder::push<clang::MemberPointerTypeLoc>(clang::QualType)
Line
Count
Source
95
981
  template <class TyLocType> TyLocType push(QualType T) {
96
981
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
981
    size_t LocalSize = Loc.getLocalDataSize();
98
981
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
981
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
981
  }
clang::ArrayTypeLoc clang::TypeLocBuilder::push<clang::ArrayTypeLoc>(clang::QualType)
Line
Count
Source
95
20.2k
  template <class TyLocType> TyLocType push(QualType T) {
96
20.2k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
20.2k
    size_t LocalSize = Loc.getLocalDataSize();
98
20.2k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
20.2k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
20.2k
  }
clang::IncompleteArrayTypeLoc clang::TypeLocBuilder::push<clang::IncompleteArrayTypeLoc>(clang::QualType)
Line
Count
Source
95
3.30k
  template <class TyLocType> TyLocType push(QualType T) {
96
3.30k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
3.30k
    size_t LocalSize = Loc.getLocalDataSize();
98
3.30k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
3.30k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
3.30k
  }
clang::DependentSizedExtVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedExtVectorTypeLoc>(clang::QualType)
Line
Count
Source
95
2
  template <class TyLocType> TyLocType push(QualType T) {
96
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
2
    size_t LocalSize = Loc.getLocalDataSize();
98
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
2
  }
clang::ExtVectorTypeLoc clang::TypeLocBuilder::push<clang::ExtVectorTypeLoc>(clang::QualType)
Line
Count
Source
95
15
  template <class TyLocType> TyLocType push(QualType T) {
96
15
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
15
    size_t LocalSize = Loc.getLocalDataSize();
98
15
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
15
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
15
  }
Unexecuted instantiation: clang::DependentAddressSpaceTypeLoc clang::TypeLocBuilder::push<clang::DependentAddressSpaceTypeLoc>(clang::QualType)
clang::VectorTypeLoc clang::TypeLocBuilder::push<clang::VectorTypeLoc>(clang::QualType)
Line
Count
Source
95
15
  template <class TyLocType> TyLocType push(QualType T) {
96
15
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
15
    size_t LocalSize = Loc.getLocalDataSize();
98
15
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
15
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
15
  }
Unexecuted instantiation: clang::DependentVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentVectorTypeLoc>(clang::QualType)
clang::PackExpansionTypeLoc clang::TypeLocBuilder::push<clang::PackExpansionTypeLoc>(clang::QualType)
Line
Count
Source
95
166k
  template <class TyLocType> TyLocType push(QualType T) {
96
166k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
166k
    size_t LocalSize = Loc.getLocalDataSize();
98
166k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
166k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
166k
  }
clang::FunctionProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionProtoTypeLoc>(clang::QualType)
Line
Count
Source
95
1.56M
  template <class TyLocType> TyLocType push(QualType T) {
96
1.56M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
1.56M
    size_t LocalSize = Loc.getLocalDataSize();
98
1.56M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
1.56M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
1.56M
  }
Unexecuted instantiation: clang::FunctionNoProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionNoProtoTypeLoc>(clang::QualType)
clang::ParenTypeLoc clang::TypeLocBuilder::push<clang::ParenTypeLoc>(clang::QualType)
Line
Count
Source
95
6.86k
  template <class TyLocType> TyLocType push(QualType T) {
96
6.86k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
6.86k
    size_t LocalSize = Loc.getLocalDataSize();
98
6.86k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
6.86k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
6.86k
  }
clang::MacroQualifiedTypeLoc clang::TypeLocBuilder::push<clang::MacroQualifiedTypeLoc>(clang::QualType)
Line
Count
Source
95
23
  template <class TyLocType> TyLocType push(QualType T) {
96
23
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
23
    size_t LocalSize = Loc.getLocalDataSize();
98
23
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
23
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
23
  }
clang::DecayedTypeLoc clang::TypeLocBuilder::push<clang::DecayedTypeLoc>(clang::QualType)
Line
Count
Source
95
10
  template <class TyLocType> TyLocType push(QualType T) {
96
10
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
10
    size_t LocalSize = Loc.getLocalDataSize();
98
10
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
10
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
10
  }
clang::TypeOfExprTypeLoc clang::TypeLocBuilder::push<clang::TypeOfExprTypeLoc>(clang::QualType)
Line
Count
Source
95
248
  template <class TyLocType> TyLocType push(QualType T) {
96
248
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
248
    size_t LocalSize = Loc.getLocalDataSize();
98
248
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
248
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
248
  }
clang::TypeOfTypeLoc clang::TypeLocBuilder::push<clang::TypeOfTypeLoc>(clang::QualType)
Line
Count
Source
95
2
  template <class TyLocType> TyLocType push(QualType T) {
96
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
2
    size_t LocalSize = Loc.getLocalDataSize();
98
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
2
  }
clang::UnaryTransformTypeLoc clang::TypeLocBuilder::push<clang::UnaryTransformTypeLoc>(clang::QualType)
Line
Count
Source
95
604
  template <class TyLocType> TyLocType push(QualType T) {
96
604
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
604
    size_t LocalSize = Loc.getLocalDataSize();
98
604
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
604
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
604
  }
clang::AttributedTypeLoc clang::TypeLocBuilder::push<clang::AttributedTypeLoc>(clang::QualType)
Line
Count
Source
95
145
  template <class TyLocType> TyLocType push(QualType T) {
96
145
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
145
    size_t LocalSize = Loc.getLocalDataSize();
98
145
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
145
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
145
  }
clang::AutoTypeLoc clang::TypeLocBuilder::push<clang::AutoTypeLoc>(clang::QualType)
Line
Count
Source
95
32.3k
  template <class TyLocType> TyLocType push(QualType T) {
96
32.3k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
32.3k
    size_t LocalSize = Loc.getLocalDataSize();
98
32.3k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
32.3k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
32.3k
  }
clang::DeducedTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DeducedTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
95
226
  template <class TyLocType> TyLocType push(QualType T) {
96
226
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
226
    size_t LocalSize = Loc.getLocalDataSize();
98
226
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
226
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
226
  }
Unexecuted instantiation: clang::ObjCTypeParamTypeLoc clang::TypeLocBuilder::push<clang::ObjCTypeParamTypeLoc>(clang::QualType)
clang::ObjCObjectTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectTypeLoc>(clang::QualType)
Line
Count
Source
95
15
  template <class TyLocType> TyLocType push(QualType T) {
96
15
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
15
    size_t LocalSize = Loc.getLocalDataSize();
98
15
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
15
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
15
  }
Unexecuted instantiation: clang::PipeTypeLoc clang::TypeLocBuilder::push<clang::PipeTypeLoc>(clang::QualType)
clang::AtomicTypeLoc clang::TypeLocBuilder::push<clang::AtomicTypeLoc>(clang::QualType)
Line
Count
Source
95
332
  template <class TyLocType> TyLocType push(QualType T) {
96
332
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
332
    size_t LocalSize = Loc.getLocalDataSize();
98
332
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
332
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
332
  }
clang::ReferenceTypeLoc clang::TypeLocBuilder::push<clang::ReferenceTypeLoc>(clang::QualType)
Line
Count
Source
95
103
  template <class TyLocType> TyLocType push(QualType T) {
96
103
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
103
    size_t LocalSize = Loc.getLocalDataSize();
98
103
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
103
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
103
  }
clang::QualifiedTypeLoc clang::TypeLocBuilder::push<clang::QualifiedTypeLoc>(clang::QualType)
Line
Count
Source
95
4.84k
  template <class TyLocType> TyLocType push(QualType T) {
96
4.84k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
4.84k
    size_t LocalSize = Loc.getLocalDataSize();
98
4.84k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
4.84k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
4.84k
  }
clang::ConstantArrayTypeLoc clang::TypeLocBuilder::push<clang::ConstantArrayTypeLoc>(clang::QualType)
Line
Count
Source
95
2
  template <class TyLocType> TyLocType push(QualType T) {
96
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
2
    size_t LocalSize = Loc.getLocalDataSize();
98
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
2
  }
Unexecuted instantiation: clang::VariableArrayTypeLoc clang::TypeLocBuilder::push<clang::VariableArrayTypeLoc>(clang::QualType)
clang::DependentSizedArrayTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedArrayTypeLoc>(clang::QualType)
Line
Count
Source
95
8
  template <class TyLocType> TyLocType push(QualType T) {
96
8
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
8
    size_t LocalSize = Loc.getLocalDataSize();
98
8
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
8
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
8
  }
clang::ObjCInterfaceTypeLoc clang::TypeLocBuilder::push<clang::ObjCInterfaceTypeLoc>(clang::QualType)
Line
Count
Source
95
23
  template <class TyLocType> TyLocType push(QualType T) {
96
23
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
97
23
    size_t LocalSize = Loc.getLocalDataSize();
98
23
    unsigned LocalAlign = Loc.getLocalDataAlignment();
99
23
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
100
23
  }
101
102
  /// Creates a TypeSourceInfo for the given type.
103
17.7M
  TypeSourceInfo *getTypeSourceInfo(ASTContext& Context, QualType T) {
104
#ifndef NDEBUG
105
    assert(T == LastTy && "type doesn't match last type pushed!");
106
#endif
107
108
17.7M
    size_t FullDataSize = Capacity - Index;
109
17.7M
    TypeSourceInfo *DI = Context.CreateTypeSourceInfo(T, FullDataSize);
110
17.7M
    memcpy(DI->getTypeLoc().getOpaqueData(), &Buffer[Index], FullDataSize);
111
17.7M
    return DI;
112
17.7M
  }
113
114
  /// Copies the type-location information to the given AST context and
115
  /// returns a \c TypeLoc referring into the AST context.
116
2.06M
  TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) {
117
#ifndef NDEBUG
118
    assert(T == LastTy && "type doesn't match last type pushed!");
119
#endif
120
121
2.06M
    size_t FullDataSize = Capacity - Index;
122
2.06M
    void *Mem = Context.Allocate(FullDataSize);
123
2.06M
    memcpy(Mem, &Buffer[Index], FullDataSize);
124
2.06M
    return TypeLoc(T, Mem);
125
2.06M
  }
126
127
private:
128
129
  TypeLoc pushImpl(QualType T, size_t LocalSize, unsigned LocalAlignment);
130
131
  /// Grow to the given capacity.
132
  void grow(size_t NewCapacity);
133
134
  /// Retrieve a temporary TypeLoc that refers into this \c TypeLocBuilder
135
  /// object.
136
  ///
137
  /// The resulting \c TypeLoc should only be used so long as the
138
  /// \c TypeLocBuilder is active and has not had more type information
139
  /// pushed into it.
140
25.3M
  TypeLoc getTemporaryTypeLoc(QualType T) {
141
#ifndef NDEBUG
142
    assert(LastTy == T && "type doesn't match last type pushed!");
143
#endif
144
    return TypeLoc(T, &Buffer[Index]);
145
25.3M
  }
146
};
147
148
}
149
150
#endif