Coverage Report

Created: 2020-02-25 14:32

/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
6.64M
      delete[] Buffer;
53
15.7M
  }
54
55
  /// Ensures that this buffer has at least as much capacity as described.
56
10.0M
  void reserve(size_t Requested) {
57
10.0M
    if (Requested > Capacity)
58
1.92M
      // For now, match the request exactly.
59
1.92M
      grow(Requested);
60
10.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.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.66M
  void TypeWasModifiedSafely(QualType T) {
86
1.66M
#ifndef NDEBUG
87
1.66M
    LastTy = T;
88
1.66M
#endif
89
1.66M
  }
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::InjectedClassNameTypeLoc clang::TypeLocBuilder::push<clang::InjectedClassNameTypeLoc>(clang::QualType)
Line
Count
Source
93
377
  template <class TyLocType> TyLocType push(QualType T) {
94
377
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
377
    size_t LocalSize = Loc.getLocalDataSize();
96
377
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
377
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
377
  }
clang::RecordTypeLoc clang::TypeLocBuilder::push<clang::RecordTypeLoc>(clang::QualType)
Line
Count
Source
93
152k
  template <class TyLocType> TyLocType push(QualType T) {
94
152k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
152k
    size_t LocalSize = Loc.getLocalDataSize();
96
152k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
152k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
152k
  }
clang::TypedefTypeLoc clang::TypeLocBuilder::push<clang::TypedefTypeLoc>(clang::QualType)
Line
Count
Source
93
1.27M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.27M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.27M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.27M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.27M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.27M
  }
clang::EnumTypeLoc clang::TypeLocBuilder::push<clang::EnumTypeLoc>(clang::QualType)
Line
Count
Source
93
5.31k
  template <class TyLocType> TyLocType push(QualType T) {
94
5.31k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
5.31k
    size_t LocalSize = Loc.getLocalDataSize();
96
5.31k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
5.31k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
5.31k
  }
clang::TemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::TemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
1.58M
  template <class TyLocType> TyLocType push(QualType T) {
94
1.58M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.58M
    size_t LocalSize = Loc.getLocalDataSize();
96
1.58M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.58M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.58M
  }
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::SubstTemplateTypeParmTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmTypeLoc>(clang::QualType)
Line
Count
Source
93
4.23M
  template <class TyLocType> TyLocType push(QualType T) {
94
4.23M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
4.23M
    size_t LocalSize = Loc.getLocalDataSize();
96
4.23M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
4.23M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
4.23M
  }
clang::SubstTemplateTypeParmPackTypeLoc clang::TypeLocBuilder::push<clang::SubstTemplateTypeParmPackTypeLoc>(clang::QualType)
Line
Count
Source
93
60.5k
  template <class TyLocType> TyLocType push(QualType T) {
94
60.5k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
60.5k
    size_t LocalSize = Loc.getLocalDataSize();
96
60.5k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
60.5k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
60.5k
  }
clang::DecltypeTypeLoc clang::TypeLocBuilder::push<clang::DecltypeTypeLoc>(clang::QualType)
Line
Count
Source
93
92.9k
  template <class TyLocType> TyLocType push(QualType T) {
94
92.9k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
92.9k
    size_t LocalSize = Loc.getLocalDataSize();
96
92.9k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
92.9k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
92.9k
  }
clang::DependentTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DependentTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
87.2k
  template <class TyLocType> TyLocType push(QualType T) {
94
87.2k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
87.2k
    size_t LocalSize = Loc.getLocalDataSize();
96
87.2k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
87.2k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
87.2k
  }
clang::TemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::TemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
5.92M
  template <class TyLocType> TyLocType push(QualType T) {
94
5.92M
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
5.92M
    size_t LocalSize = Loc.getLocalDataSize();
96
5.92M
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
5.92M
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
5.92M
  }
clang::DependentNameTypeLoc clang::TypeLocBuilder::push<clang::DependentNameTypeLoc>(clang::QualType)
Line
Count
Source
93
387k
  template <class TyLocType> TyLocType push(QualType T) {
94
387k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
387k
    size_t LocalSize = Loc.getLocalDataSize();
96
387k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
387k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
387k
  }
clang::ElaboratedTypeLoc clang::TypeLocBuilder::push<clang::ElaboratedTypeLoc>(clang::QualType)
Line
Count
Source
93
940k
  template <class TyLocType> TyLocType push(QualType T) {
94
940k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
940k
    size_t LocalSize = Loc.getLocalDataSize();
96
940k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
940k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
940k
  }
clang::ObjCObjectPointerTypeLoc clang::TypeLocBuilder::push<clang::ObjCObjectPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
83
  template <class TyLocType> TyLocType push(QualType T) {
94
83
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
83
    size_t LocalSize = Loc.getLocalDataSize();
96
83
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
83
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
83
  }
clang::DecayedTypeLoc clang::TypeLocBuilder::push<clang::DecayedTypeLoc>(clang::QualType)
Line
Count
Source
93
1.06k
  template <class TyLocType> TyLocType push(QualType T) {
94
1.06k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
1.06k
    size_t LocalSize = Loc.getLocalDataSize();
96
1.06k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
1.06k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
1.06k
  }
clang::ArrayTypeLoc clang::TypeLocBuilder::push<clang::ArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
6.88k
  template <class TyLocType> TyLocType push(QualType T) {
94
6.88k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
6.88k
    size_t LocalSize = Loc.getLocalDataSize();
96
6.88k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
6.88k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
6.88k
  }
clang::IncompleteArrayTypeLoc clang::TypeLocBuilder::push<clang::IncompleteArrayTypeLoc>(clang::QualType)
Line
Count
Source
93
3.48k
  template <class TyLocType> TyLocType push(QualType T) {
94
3.48k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
3.48k
    size_t LocalSize = Loc.getLocalDataSize();
96
3.48k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
3.48k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
3.48k
  }
clang::AtomicTypeLoc clang::TypeLocBuilder::push<clang::AtomicTypeLoc>(clang::QualType)
Line
Count
Source
93
522
  template <class TyLocType> TyLocType push(QualType T) {
94
522
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
522
    size_t LocalSize = Loc.getLocalDataSize();
96
522
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
522
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
522
  }
clang::AttributedTypeLoc clang::TypeLocBuilder::push<clang::AttributedTypeLoc>(clang::QualType)
Line
Count
Source
93
145
  template <class TyLocType> TyLocType push(QualType T) {
94
145
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
145
    size_t LocalSize = Loc.getLocalDataSize();
96
145
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
145
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
145
  }
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
375k
  template <class TyLocType> TyLocType push(QualType T) {
94
375k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
375k
    size_t LocalSize = Loc.getLocalDataSize();
96
375k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
375k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
375k
  }
Unexecuted instantiation: clang::ComplexTypeLoc clang::TypeLocBuilder::push<clang::ComplexTypeLoc>(clang::QualType)
clang::AutoTypeLoc clang::TypeLocBuilder::push<clang::AutoTypeLoc>(clang::QualType)
Line
Count
Source
93
25.9k
  template <class TyLocType> TyLocType push(QualType T) {
94
25.9k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
25.9k
    size_t LocalSize = Loc.getLocalDataSize();
96
25.9k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
25.9k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
25.9k
  }
clang::DeducedTemplateSpecializationTypeLoc clang::TypeLocBuilder::push<clang::DeducedTemplateSpecializationTypeLoc>(clang::QualType)
Line
Count
Source
93
271
  template <class TyLocType> TyLocType push(QualType T) {
94
271
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
271
    size_t LocalSize = Loc.getLocalDataSize();
96
271
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
271
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
271
  }
Unexecuted instantiation: clang::DependentAddressSpaceTypeLoc clang::TypeLocBuilder::push<clang::DependentAddressSpaceTypeLoc>(clang::QualType)
clang::DependentSizedExtVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedExtVectorTypeLoc>(clang::QualType)
Line
Count
Source
93
2
  template <class TyLocType> TyLocType push(QualType T) {
94
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
2
    size_t LocalSize = Loc.getLocalDataSize();
96
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
2
  }
clang::ExtVectorTypeLoc clang::TypeLocBuilder::push<clang::ExtVectorTypeLoc>(clang::QualType)
Line
Count
Source
93
15
  template <class TyLocType> TyLocType push(QualType T) {
94
15
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
15
    size_t LocalSize = Loc.getLocalDataSize();
96
15
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
15
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
15
  }
Unexecuted instantiation: clang::DependentVectorTypeLoc clang::TypeLocBuilder::push<clang::DependentVectorTypeLoc>(clang::QualType)
clang::VectorTypeLoc clang::TypeLocBuilder::push<clang::VectorTypeLoc>(clang::QualType)
Line
Count
Source
93
25
  template <class TyLocType> TyLocType push(QualType T) {
94
25
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
25
    size_t LocalSize = Loc.getLocalDataSize();
96
25
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
25
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
25
  }
Unexecuted instantiation: clang::FunctionNoProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionNoProtoTypeLoc>(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::FunctionProtoTypeLoc clang::TypeLocBuilder::push<clang::FunctionProtoTypeLoc>(clang::QualType)
Line
Count
Source
93
936k
  template <class TyLocType> TyLocType push(QualType T) {
94
936k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
936k
    size_t LocalSize = Loc.getLocalDataSize();
96
936k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
936k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
936k
  }
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::AdjustedTypeLoc clang::TypeLocBuilder::push<clang::AdjustedTypeLoc>(clang::QualType)
Line
Count
Source
93
2
  template <class TyLocType> TyLocType push(QualType T) {
94
2
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
2
    size_t LocalSize = Loc.getLocalDataSize();
96
2
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
2
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
2
  }
clang::MemberPointerTypeLoc clang::TypeLocBuilder::push<clang::MemberPointerTypeLoc>(clang::QualType)
Line
Count
Source
93
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
  }
Unexecuted instantiation: clang::ObjCTypeParamTypeLoc clang::TypeLocBuilder::push<clang::ObjCTypeParamTypeLoc>(clang::QualType)
clang::ParenTypeLoc clang::TypeLocBuilder::push<clang::ParenTypeLoc>(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::PipeTypeLoc clang::TypeLocBuilder::push<clang::PipeTypeLoc>(clang::QualType)
clang::PointerTypeLoc clang::TypeLocBuilder::push<clang::PointerTypeLoc>(clang::QualType)
Line
Count
Source
93
319k
  template <class TyLocType> TyLocType push(QualType T) {
94
319k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
319k
    size_t LocalSize = Loc.getLocalDataSize();
96
319k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
319k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
319k
  }
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
241k
  template <class TyLocType> TyLocType push(QualType T) {
94
241k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
241k
    size_t LocalSize = Loc.getLocalDataSize();
96
241k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
241k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
241k
  }
clang::TypeOfExprTypeLoc clang::TypeLocBuilder::push<clang::TypeOfExprTypeLoc>(clang::QualType)
Line
Count
Source
93
248
  template <class TyLocType> TyLocType push(QualType T) {
94
248
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
248
    size_t LocalSize = Loc.getLocalDataSize();
96
248
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
248
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
248
  }
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::UnaryTransformTypeLoc clang::TypeLocBuilder::push<clang::UnaryTransformTypeLoc>(clang::QualType)
Line
Count
Source
93
824
  template <class TyLocType> TyLocType push(QualType T) {
94
824
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
824
    size_t LocalSize = Loc.getLocalDataSize();
96
824
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
824
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
824
  }
clang::ReferenceTypeLoc clang::TypeLocBuilder::push<clang::ReferenceTypeLoc>(clang::QualType)
Line
Count
Source
93
104
  template <class TyLocType> TyLocType push(QualType T) {
94
104
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
104
    size_t LocalSize = Loc.getLocalDataSize();
96
104
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
104
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
104
  }
clang::QualifiedTypeLoc clang::TypeLocBuilder::push<clang::QualifiedTypeLoc>(clang::QualType)
Line
Count
Source
93
6.50k
  template <class TyLocType> TyLocType push(QualType T) {
94
6.50k
    TyLocType Loc = TypeLoc(T, nullptr).castAs<TyLocType>();
95
6.50k
    size_t LocalSize = Loc.getLocalDataSize();
96
6.50k
    unsigned LocalAlign = Loc.getLocalDataAlignment();
97
6.50k
    return pushImpl(T, LocalSize, LocalAlign).castAs<TyLocType>();
98
6.50k
  }
clang::ConstantArrayTypeLoc clang::TypeLocBuilder::push<clang::ConstantArrayTypeLoc>(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::DependentSizedArrayTypeLoc clang::TypeLocBuilder::push<clang::DependentSizedArrayTypeLoc>(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
  }
Unexecuted instantiation: clang::VariableArrayTypeLoc clang::TypeLocBuilder::push<clang::VariableArrayTypeLoc>(clang::QualType)
clang::ObjCInterfaceTypeLoc clang::TypeLocBuilder::push<clang::ObjCInterfaceTypeLoc>(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
  }
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.66M
  TypeLoc getTypeLocInContext(ASTContext &Context, QualType T) {
115
1.66M
#ifndef NDEBUG
116
1.66M
    assert(T == LastTy && "type doesn't match last type pushed!");
117
1.66M
#endif
118
1.66M
119
1.66M
    size_t FullDataSize = Capacity - Index;
120
1.66M
    void *Mem = Context.Allocate(FullDataSize);
121
1.66M
    memcpy(Mem, &Buffer[Index], FullDataSize);
122
1.66M
    return TypeLoc(T, Mem);
123
1.66M
  }
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.8M
  TypeLoc getTemporaryTypeLoc(QualType T) {
139
18.8M
#ifndef NDEBUG
140
18.8M
    assert(LastTy == T && "type doesn't match last type pushed!");
141
18.8M
#endif
142
18.8M
    return TypeLoc(T, &Buffer[Index]);
143
18.8M
  }
144
};
145
146
}
147
148
#endif