Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/AST/AbstractBasicReader.h
Line
Count
Source (jump to first uncovered line)
1
//==--- AbstractBasiceReader.h - Abstract basic value deserialization -----===//
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
#ifndef LLVM_CLANG_AST_ABSTRACTBASICREADER_H
10
#define LLVM_CLANG_AST_ABSTRACTBASICREADER_H
11
12
#include "clang/AST/DeclTemplate.h"
13
14
namespace clang {
15
namespace serialization {
16
17
template <class T>
18
1.40k
inline T makeNullableFromOptional(const Optional<T> &value) {
19
1.40k
  return (value ? 
*value1.03k
:
T()365
);
20
1.40k
}
clang::QualType clang::serialization::makeNullableFromOptional<clang::QualType>(llvm::Optional<clang::QualType> const&)
Line
Count
Source
18
1.38k
inline T makeNullableFromOptional(const Optional<T> &value) {
19
1.38k
  return (value ? 
*value1.02k
:
T()365
);
20
1.38k
}
clang::TemplateName clang::serialization::makeNullableFromOptional<clang::TemplateName>(llvm::Optional<clang::TemplateName> const&)
Line
Count
Source
18
18
inline T makeNullableFromOptional(const Optional<T> &value) {
19
18
  return (value ? *value : 
T()0
);
20
18
}
21
22
template <class T>
23
2.52M
inline T *makePointerFromOptional(Optional<T *> value) {
24
2.52M
  return value.value_or(nullptr);
25
2.52M
}
clang::ConceptDecl* clang::serialization::makePointerFromOptional<clang::ConceptDecl>(llvm::Optional<clang::ConceptDecl*>)
Line
Count
Source
23
1.38k
inline T *makePointerFromOptional(Optional<T *> value) {
24
1.38k
  return value.value_or(nullptr);
25
1.38k
}
clang::TagDecl* clang::serialization::makePointerFromOptional<clang::TagDecl>(llvm::Optional<clang::TagDecl*>)
Line
Count
Source
23
138k
inline T *makePointerFromOptional(Optional<T *> value) {
24
138k
  return value.value_or(nullptr);
25
138k
}
clang::TemplateTypeParmDecl* clang::serialization::makePointerFromOptional<clang::TemplateTypeParmDecl>(llvm::Optional<clang::TemplateTypeParmDecl*>)
Line
Count
Source
23
2.38M
inline T *makePointerFromOptional(Optional<T *> value) {
24
2.38M
  return value.value_or(nullptr);
25
2.38M
}
26
27
// PropertyReader is a class concept that requires the following method:
28
//   BasicReader find(llvm::StringRef propertyName);
29
// where BasicReader is some class conforming to the BasicReader concept.
30
// An abstract AST-node reader is created with a PropertyReader and
31
// performs a sequence of calls like so:
32
//   propertyReader.find(propertyName).read##TypeName()
33
// to read the properties of the node it is deserializing.
34
35
// BasicReader is a class concept that requires methods like:
36
//   ValueType read##TypeName();
37
// where TypeName is the name of a PropertyType node from PropertiesBase.td
38
// and ValueType is the corresponding C++ type name.  The read method may
39
// require one or more buffer arguments.
40
//
41
// In addition to the concrete type names, BasicReader is expected to
42
// implement these methods:
43
//
44
//   template <class EnumType>
45
//   void writeEnum(T value);
46
//
47
//     Reads an enum value from the current property.  EnumType will always
48
//     be an enum type.  Only necessary if the BasicReader doesn't provide
49
//     type-specific readers for all the enum types.
50
//
51
//   template <class ValueType>
52
//   Optional<ValueType> writeOptional();
53
//
54
//     Reads an optional value from the current property.
55
//
56
//   template <class ValueType>
57
//   ArrayRef<ValueType> readArray(llvm::SmallVectorImpl<ValueType> &buffer);
58
//
59
//     Reads an array of values from the current property.
60
//
61
//   PropertyReader readObject();
62
//
63
//     Reads an object from the current property; the returned property
64
//     reader will be subjected to a sequence of property reads and then
65
//     discarded before any other properties are reader from the "outer"
66
//     property reader (which need not be the same type).  The sub-reader
67
//     will be used as if with the following code:
68
//
69
//       {
70
//         auto &&widget = W.find("widget").readObject();
71
//         auto kind = widget.find("kind").readWidgetKind();
72
//         auto declaration = widget.find("declaration").readDeclRef();
73
//         return Widget(kind, declaration);
74
//       }
75
76
// ReadDispatcher does type-based forwarding to one of the read methods
77
// on the BasicReader passed in:
78
//
79
// template <class ValueType>
80
// struct ReadDispatcher {
81
//   template <class BasicReader, class... BufferTypes>
82
//   static ValueType read(BasicReader &R, BufferTypes &&...);
83
// };
84
85
// BasicReaderBase provides convenience implementations of the read methods
86
// for EnumPropertyType and SubclassPropertyType types that just defer to
87
// the "underlying" implementations (for UInt32 and the base class,
88
// respectively).
89
//
90
// template <class Impl>
91
// class BasicReaderBase {
92
// protected:
93
//   BasicReaderBase(ASTContext &ctx);
94
//   Impl &asImpl();
95
// public:
96
//   ASTContext &getASTContext();
97
//   ...
98
// };
99
100
// The actual classes are auto-generated; see ClangASTPropertiesEmitter.cpp.
101
#include "clang/AST/AbstractBasicReader.inc"
102
103
/// DataStreamBasicReader provides convenience implementations for many
104
/// BasicReader methods based on the assumption that the
105
/// ultimate reader implementation is based on a variable-length stream
106
/// of unstructured data (like Clang's module files).  It is designed
107
/// to pair with DataStreamBasicWriter.
108
///
109
/// This class can also act as a PropertyReader, implementing find("...")
110
/// by simply forwarding to itself.
111
///
112
/// Unimplemented methods:
113
///   readBool
114
///   readUInt32
115
///   readUInt64
116
///   readIdentifier
117
///   readSelector
118
///   readSourceLocation
119
///   readQualType
120
///   readStmtRef
121
///   readDeclRef
122
template <class Impl>
123
class DataStreamBasicReader : public BasicReaderBase<Impl> {
124
protected:
125
  using BasicReaderBase<Impl>::asImpl;
126
22.4M
  DataStreamBasicReader(ASTContext &ctx) : BasicReaderBase<Impl>(ctx) {}
127
128
public:
129
  using BasicReaderBase<Impl>::getASTContext;
130
131
  /// Implement property-find by ignoring it.  We rely on properties being
132
  /// serialized and deserialized in a reliable order instead.
133
86.6M
  Impl &find(const char *propertyName) {
134
86.6M
    return asImpl();
135
86.6M
  }
136
137
  template <class T>
138
26.6M
  T readEnum() {
139
26.6M
    return T(asImpl().readUInt32());
140
26.6M
  }
clang::TemplateArgument::ArgKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::TemplateArgument::ArgKind>()
Line
Count
Source
138
6.83M
  T readEnum() {
139
6.83M
    return T(asImpl().readUInt32());
140
6.83M
  }
clang::TemplateName::NameKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::TemplateName::NameKind>()
Line
Count
Source
138
2.27M
  T readEnum() {
139
2.27M
    return T(asImpl().readUInt32());
140
2.27M
  }
clang::OverloadedOperatorKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OverloadedOperatorKind>()
Line
Count
Source
138
839k
  T readEnum() {
139
839k
    return T(asImpl().readUInt32());
140
839k
  }
clang::ArrayType::ArraySizeModifier clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::ArrayType::ArraySizeModifier>()
Line
Count
Source
138
27.0k
  T readEnum() {
139
27.0k
    return T(asImpl().readUInt32());
140
27.0k
  }
clang::attr::Kind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::attr::Kind>()
Line
Count
Source
138
7.31k
  T readEnum() {
139
7.31k
    return T(asImpl().readUInt32());
140
7.31k
  }
Unexecuted instantiation: clang::BuiltinType::Kind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::BuiltinType::Kind>()
clang::AutoTypeKeyword clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::AutoTypeKeyword>()
Line
Count
Source
138
1.38k
  T readEnum() {
139
1.38k
    return T(asImpl().readUInt32());
140
1.38k
  }
clang::ElaboratedTypeKeyword clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::ElaboratedTypeKeyword>()
Line
Count
Source
138
615k
  T readEnum() {
139
615k
    return T(asImpl().readUInt32());
140
615k
  }
clang::VectorType::VectorKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::VectorType::VectorKind>()
Line
Count
Source
138
557
  T readEnum() {
139
557
    return T(asImpl().readUInt32());
140
557
  }
clang::CallingConv clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::CallingConv>()
Line
Count
Source
138
1.04M
  T readEnum() {
139
1.04M
    return T(asImpl().readUInt32());
140
1.04M
  }
clang::RefQualifierKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::RefQualifierKind>()
Line
Count
Source
138
1.03M
  T readEnum() {
139
1.03M
    return T(asImpl().readUInt32());
140
1.03M
  }
clang::UnaryTransformType::UTTKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::UnaryTransformType::UTTKind>()
Line
Count
Source
138
215
  T readEnum() {
139
215
    return T(asImpl().readUInt32());
140
215
  }
clang::DeclarationName::NameKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::DeclarationName::NameKind>()
Line
Count
Source
138
11.6M
  T readEnum() {
139
11.6M
    return T(asImpl().readUInt32());
140
11.6M
  }
clang::NestedNameSpecifier::SpecifierKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::NestedNameSpecifier::SpecifierKind>()
Line
Count
Source
138
2.31M
  T readEnum() {
139
2.31M
    return T(asImpl().readUInt32());
140
2.31M
  }
clang::OpenMPReductionClauseModifier clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OpenMPReductionClauseModifier>()
Line
Count
Source
138
1.00k
  T readEnum() {
139
1.00k
    return T(asImpl().readUInt32());
140
1.00k
  }
clang::OpenMPDependClauseKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OpenMPDependClauseKind>()
Line
Count
Source
138
8
  T readEnum() {
139
8
    return T(asImpl().readUInt32());
140
8
  }
clang::OpenMPLastprivateModifier clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OpenMPLastprivateModifier>()
Line
Count
Source
138
430
  T readEnum() {
139
430
    return T(asImpl().readUInt32());
140
430
  }
clang::OpenMPDeviceClauseModifier clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OpenMPDeviceClauseModifier>()
Line
Count
Source
138
357
  T readEnum() {
139
357
    return T(asImpl().readUInt32());
140
357
  }
clang::OpenMPOrderClauseKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OpenMPOrderClauseKind>()
Line
Count
Source
138
61
  T readEnum() {
139
61
    return T(asImpl().readUInt32());
140
61
  }
clang::OpenMPBindClauseKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OpenMPBindClauseKind>()
Line
Count
Source
138
24
  T readEnum() {
139
24
    return T(asImpl().readUInt32());
140
24
  }
llvm::omp::TraitSet clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<llvm::omp::TraitSet>()
Line
Count
Source
138
735
  T readEnum() {
139
735
    return T(asImpl().readUInt32());
140
735
  }
llvm::omp::TraitSelector clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<llvm::omp::TraitSelector>()
Line
Count
Source
138
767
  T readEnum() {
139
767
    return T(asImpl().readUInt32());
140
767
  }
llvm::omp::TraitProperty clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<llvm::omp::TraitProperty>()
Line
Count
Source
138
1.16k
  T readEnum() {
139
1.16k
    return T(asImpl().readUInt32());
140
1.16k
  }
clang::APValue::ValueKind clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::APValue::ValueKind>()
Line
Count
Source
138
63
  T readEnum() {
139
63
    return T(asImpl().readUInt32());
140
63
  }
Unexecuted instantiation: clang::OMPDeclareTargetDeclAttr::MapTypeTy clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OMPDeclareTargetDeclAttr::MapTypeTy>()
Unexecuted instantiation: clang::OMPDeclareTargetDeclAttr::DevTypeTy clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<clang::OMPDeclareTargetDeclAttr::DevTypeTy>()
llvm::omp::Directive clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readEnum<llvm::omp::Directive>()
Line
Count
Source
138
244
  T readEnum() {
139
244
    return T(asImpl().readUInt32());
140
244
  }
141
142
  // Implement object reading by forwarding to this, collapsing the
143
  // structure into a single data stream.
144
20.8M
  Impl &readObject() { return asImpl(); }
145
146
  template <class T>
147
4.43M
  llvm::ArrayRef<T> readArray(llvm::SmallVectorImpl<T> &buffer) {
148
4.43M
    assert(buffer.empty());
149
150
0
    uint32_t size = asImpl().readUInt32();
151
4.43M
    buffer.reserve(size);
152
153
10.1M
    for (uint32_t i = 0; i != size; 
++i5.72M
) {
154
5.72M
      buffer.push_back(ReadDispatcher<T>::read(asImpl()));
155
5.72M
    }
156
4.43M
    return buffer;
157
4.43M
  }
Unexecuted instantiation: llvm::ArrayRef<clang::NamedDecl*> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readArray<clang::NamedDecl*>(llvm::SmallVectorImpl<clang::NamedDecl*>&)
llvm::ArrayRef<clang::TemplateArgument> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readArray<clang::TemplateArgument>(llvm::SmallVectorImpl<clang::TemplateArgument>&)
Line
Count
Source
147
2.33M
  llvm::ArrayRef<T> readArray(llvm::SmallVectorImpl<T> &buffer) {
148
2.33M
    assert(buffer.empty());
149
150
0
    uint32_t size = asImpl().readUInt32();
151
2.33M
    buffer.reserve(size);
152
153
6.44M
    for (uint32_t i = 0; i != size; 
++i4.11M
) {
154
4.11M
      buffer.push_back(ReadDispatcher<T>::read(asImpl()));
155
4.11M
    }
156
2.33M
    return buffer;
157
2.33M
  }
llvm::ArrayRef<clang::QualType> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readArray<clang::QualType>(llvm::SmallVectorImpl<clang::QualType>&)
Line
Count
Source
147
1.04M
  llvm::ArrayRef<T> readArray(llvm::SmallVectorImpl<T> &buffer) {
148
1.04M
    assert(buffer.empty());
149
150
0
    uint32_t size = asImpl().readUInt32();
151
1.04M
    buffer.reserve(size);
152
153
2.65M
    for (uint32_t i = 0; i != size; 
++i1.60M
) {
154
1.60M
      buffer.push_back(ReadDispatcher<T>::read(asImpl()));
155
1.60M
    }
156
1.04M
    return buffer;
157
1.04M
  }
llvm::ArrayRef<clang::FunctionType::ExtParameterInfo> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readArray<clang::FunctionType::ExtParameterInfo>(llvm::SmallVectorImpl<clang::FunctionType::ExtParameterInfo>&)
Line
Count
Source
147
1.03M
  llvm::ArrayRef<T> readArray(llvm::SmallVectorImpl<T> &buffer) {
148
1.03M
    assert(buffer.empty());
149
150
0
    uint32_t size = asImpl().readUInt32();
151
1.03M
    buffer.reserve(size);
152
153
1.03M
    for (uint32_t i = 0; i != size; 
++i4
) {
154
4
      buffer.push_back(ReadDispatcher<T>::read(asImpl()));
155
4
    }
156
1.03M
    return buffer;
157
1.03M
  }
llvm::ArrayRef<clang::ObjCProtocolDecl*> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readArray<clang::ObjCProtocolDecl*>(llvm::SmallVectorImpl<clang::ObjCProtocolDecl*>&)
Line
Count
Source
147
23.4k
  llvm::ArrayRef<T> readArray(llvm::SmallVectorImpl<T> &buffer) {
148
23.4k
    assert(buffer.empty());
149
150
0
    uint32_t size = asImpl().readUInt32();
151
23.4k
    buffer.reserve(size);
152
153
23.8k
    for (uint32_t i = 0; i != size; 
++i352
) {
154
352
      buffer.push_back(ReadDispatcher<T>::read(asImpl()));
155
352
    }
156
23.4k
    return buffer;
157
23.4k
  }
llvm::ArrayRef<clang::APValue> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readArray<clang::APValue>(llvm::SmallVectorImpl<clang::APValue>&)
Line
Count
Source
147
13
  llvm::ArrayRef<T> readArray(llvm::SmallVectorImpl<T> &buffer) {
148
13
    assert(buffer.empty());
149
150
0
    uint32_t size = asImpl().readUInt32();
151
13
    buffer.reserve(size);
152
153
47
    for (uint32_t i = 0; i != size; 
++i34
) {
154
34
      buffer.push_back(ReadDispatcher<T>::read(asImpl()));
155
34
    }
156
13
    return buffer;
157
13
  }
llvm::ArrayRef<clang::CXXRecordDecl*> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readArray<clang::CXXRecordDecl*>(llvm::SmallVectorImpl<clang::CXXRecordDecl*>&)
Line
Count
Source
147
4
  llvm::ArrayRef<T> readArray(llvm::SmallVectorImpl<T> &buffer) {
148
4
    assert(buffer.empty());
149
150
0
    uint32_t size = asImpl().readUInt32();
151
4
    buffer.reserve(size);
152
153
4
    for (uint32_t i = 0; i != size; 
++i0
) {
154
0
      buffer.push_back(ReadDispatcher<T>::read(asImpl()));
155
0
    }
156
4
    return buffer;
157
4
  }
158
159
  template <class T, class... Args>
160
5.79M
  llvm::Optional<T> readOptional(Args &&...args) {
161
5.79M
    return UnpackOptionalValue<T>::unpack(
162
5.79M
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
5.79M
  }
llvm::Optional<clang::IdentifierInfo*> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readOptional<clang::IdentifierInfo*>()
Line
Count
Source
160
20
  llvm::Optional<T> readOptional(Args &&...args) {
161
20
    return UnpackOptionalValue<T>::unpack(
162
20
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
20
  }
llvm::Optional<unsigned int> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readOptional<unsigned int>()
Line
Count
Source
160
65.4k
  llvm::Optional<T> readOptional(Args &&...args) {
161
65.4k
    return UnpackOptionalValue<T>::unpack(
162
65.4k
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
65.4k
  }
llvm::Optional<clang::QualType> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readOptional<clang::QualType>()
Line
Count
Source
160
3.20M
  llvm::Optional<T> readOptional(Args &&...args) {
161
3.20M
    return UnpackOptionalValue<T>::unpack(
162
3.20M
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
3.20M
  }
llvm::Optional<clang::ConceptDecl*> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readOptional<clang::ConceptDecl*>()
Line
Count
Source
160
1.38k
  llvm::Optional<T> readOptional(Args &&...args) {
161
1.38k
    return UnpackOptionalValue<T>::unpack(
162
1.38k
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
1.38k
  }
llvm::Optional<clang::TemplateName> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readOptional<clang::TemplateName>()
Line
Count
Source
160
18
  llvm::Optional<T> readOptional(Args &&...args) {
161
18
    return UnpackOptionalValue<T>::unpack(
162
18
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
18
  }
llvm::Optional<clang::TagDecl*> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readOptional<clang::TagDecl*>()
Line
Count
Source
160
138k
  llvm::Optional<T> readOptional(Args &&...args) {
161
138k
    return UnpackOptionalValue<T>::unpack(
162
138k
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
138k
  }
llvm::Optional<clang::TemplateTypeParmDecl*> clang::serialization::DataStreamBasicReader<clang::ASTRecordReader>::readOptional<clang::TemplateTypeParmDecl*>()
Line
Count
Source
160
2.38M
  llvm::Optional<T> readOptional(Args &&...args) {
161
2.38M
    return UnpackOptionalValue<T>::unpack(
162
2.38M
             ReadDispatcher<T>::read(asImpl(), std::forward<Args>(args)...));
163
2.38M
  }
164
165
392k
  llvm::APSInt readAPSInt() {
166
392k
    bool isUnsigned = asImpl().readBool();
167
392k
    llvm::APInt value = asImpl().readAPInt();
168
392k
    return llvm::APSInt(std::move(value), isUnsigned);
169
392k
  }
170
171
914k
  llvm::APInt readAPInt() {
172
914k
    unsigned bitWidth = asImpl().readUInt32();
173
914k
    unsigned numWords = llvm::APInt::getNumWords(bitWidth);
174
914k
    llvm::SmallVector<uint64_t, 4> data;
175
1.82M
    for (uint32_t i = 0; i != numWords; 
++i914k
)
176
914k
      data.push_back(asImpl().readUInt64());
177
914k
    return llvm::APInt(bitWidth, numWords, &data[0]);
178
914k
  }
179
180
0
  llvm::FixedPointSemantics readFixedPointSemantics() {
181
0
    unsigned width = asImpl().readUInt32();
182
0
    unsigned scale = asImpl().readUInt32();
183
0
    unsigned tmp = asImpl().readUInt32();
184
0
    bool isSigned = tmp & 0x1;
185
0
    bool isSaturated = tmp & 0x2;
186
0
    bool hasUnsignedPadding = tmp & 0x4;
187
0
    return llvm::FixedPointSemantics(width, scale, isSigned, isSaturated,
188
0
                                     hasUnsignedPadding);
189
0
  }
190
191
  APValue::LValuePathSerializationHelper readLValuePathSerializationHelper(
192
12
      SmallVectorImpl<APValue::LValuePathEntry> &path) {
193
12
    auto elemTy = asImpl().readQualType();
194
12
    unsigned pathLength = asImpl().readUInt32();
195
12
    for (unsigned i = 0; i < pathLength; 
++i0
) {
196
0
      if (elemTy->template getAs<RecordType>()) {
197
0
        unsigned int_ = asImpl().readUInt32();
198
0
        Decl *decl = asImpl().template readDeclAs<Decl>();
199
0
        if (auto *recordDecl = dyn_cast<CXXRecordDecl>(decl))
200
0
          elemTy = getASTContext().getRecordType(recordDecl);
201
0
        else
202
0
          elemTy = cast<ValueDecl>(decl)->getType();
203
0
        path.push_back(
204
0
            APValue::LValuePathEntry(APValue::BaseOrMemberType(decl, int_)));
205
0
      } else {
206
0
        elemTy = getASTContext().getAsArrayType(elemTy)->getElementType();
207
0
        path.push_back(
208
0
            APValue::LValuePathEntry::ArrayIndex(asImpl().readUInt32()));
209
0
      }
210
0
    }
211
12
    return APValue::LValuePathSerializationHelper(path, elemTy);
212
12
  }
213
214
  Qualifiers readQualifiers() {
215
    static_assert(sizeof(Qualifiers().getAsOpaqueValue()) <= sizeof(uint32_t),
216
                  "update this if the value size changes");
217
    uint32_t value = asImpl().readUInt32();
218
    return Qualifiers::fromOpaqueValue(value);
219
  }
220
221
  FunctionProtoType::ExceptionSpecInfo
222
1.03M
  readExceptionSpecInfo(llvm::SmallVectorImpl<QualType> &buffer) {
223
1.03M
    FunctionProtoType::ExceptionSpecInfo esi;
224
1.03M
    esi.Type = ExceptionSpecificationType(asImpl().readUInt32());
225
1.03M
    if (esi.Type == EST_Dynamic) {
226
4
      esi.Exceptions = asImpl().template readArray<QualType>(buffer);
227
1.03M
    } else if (isComputedNoexcept(esi.Type)) {
228
76.4k
      esi.NoexceptExpr = asImpl().readExprRef();
229
963k
    } else if (esi.Type == EST_Uninstantiated) {
230
9.94k
      esi.SourceDecl = asImpl().readFunctionDeclRef();
231
9.94k
      esi.SourceTemplate = asImpl().readFunctionDeclRef();
232
953k
    } else if (esi.Type == EST_Unevaluated) {
233
33.9k
      esi.SourceDecl = asImpl().readFunctionDeclRef();
234
33.9k
    }
235
1.03M
    return esi;
236
1.03M
  }
237
238
4
  FunctionProtoType::ExtParameterInfo readExtParameterInfo() {
239
4
    static_assert(sizeof(FunctionProtoType::ExtParameterInfo().getOpaqueValue())
240
4
                    <= sizeof(uint32_t),
241
4
                  "opaque value doesn't fit into uint32_t");
242
4
    uint32_t value = asImpl().readUInt32();
243
4
    return FunctionProtoType::ExtParameterInfo::getFromOpaqueValue(value);
244
4
  }
245
246
615k
  NestedNameSpecifier *readNestedNameSpecifier() {
247
615k
    auto &ctx = getASTContext();
248
249
    // We build this up iteratively.
250
615k
    NestedNameSpecifier *cur = nullptr;
251
252
615k
    uint32_t depth = asImpl().readUInt32();
253
1.22M
    for (uint32_t i = 0; i != depth; 
++i608k
) {
254
608k
      auto kind = asImpl().readNestedNameSpecifierKind();
255
608k
      switch (kind) {
256
2.46k
      case NestedNameSpecifier::Identifier:
257
2.46k
        cur = NestedNameSpecifier::Create(ctx, cur,
258
2.46k
                                          asImpl().readIdentifier());
259
2.46k
        continue;
260
261
12.9k
      case NestedNameSpecifier::Namespace:
262
12.9k
        cur = NestedNameSpecifier::Create(ctx, cur,
263
12.9k
                                          asImpl().readNamespaceDeclRef());
264
12.9k
        continue;
265
266
4
      case NestedNameSpecifier::NamespaceAlias:
267
4
        cur = NestedNameSpecifier::Create(ctx, cur,
268
4
                                     asImpl().readNamespaceAliasDeclRef());
269
4
        continue;
270
271
591k
      case NestedNameSpecifier::TypeSpec:
272
592k
      case NestedNameSpecifier::TypeSpecWithTemplate:
273
592k
        cur = NestedNameSpecifier::Create(ctx, cur,
274
592k
                          kind == NestedNameSpecifier::TypeSpecWithTemplate,
275
592k
                          asImpl().readQualType().getTypePtr());
276
592k
        continue;
277
278
6
      case NestedNameSpecifier::Global:
279
6
        cur = NestedNameSpecifier::GlobalSpecifier(ctx);
280
6
        continue;
281
282
0
      case NestedNameSpecifier::Super:
283
0
        cur = NestedNameSpecifier::SuperSpecifier(ctx,
284
0
                                            asImpl().readCXXRecordDeclRef());
285
0
        continue;
286
608k
      }
287
0
      llvm_unreachable("bad nested name specifier kind");
288
0
    }
289
290
615k
    return cur;
291
615k
  }
292
};
293
294
} // end namespace serialization
295
} // end namespace clang
296
297
#endif