Coverage Report

Created: 2020-09-19 12:23

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Serialization/ASTRecordReader.h
Line
Count
Source (jump to first uncovered line)
1
//===- ASTRecordReader.h - Helper classes for reading AST -------*- 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 classes that are useful in the implementation of
10
//  the ASTReader.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
15
#define LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
16
17
#include "clang/AST/ASTContext.h"
18
#include "clang/AST/AbstractBasicReader.h"
19
#include "clang/Lex/Token.h"
20
#include "clang/Serialization/ASTReader.h"
21
#include "llvm/ADT/APFloat.h"
22
#include "llvm/ADT/APInt.h"
23
#include "llvm/ADT/APSInt.h"
24
25
namespace clang {
26
class OMPTraitInfo;
27
class OMPChildren;
28
29
/// An object for streaming information from a record.
30
class ASTRecordReader
31
    : public serialization::DataStreamBasicReader<ASTRecordReader> {
32
  using ModuleFile = serialization::ModuleFile;
33
34
  ASTReader *Reader;
35
  ModuleFile *F;
36
  unsigned Idx = 0;
37
  ASTReader::RecordData Record;
38
39
  using RecordData = ASTReader::RecordData;
40
  using RecordDataImpl = ASTReader::RecordDataImpl;
41
42
public:
43
  /// Construct an ASTRecordReader that uses the default encoding scheme.
44
  ASTRecordReader(ASTReader &Reader, ModuleFile &F)
45
9.08M
    : DataStreamBasicReader(Reader.getContext()), Reader(&Reader), F(&F) {}
46
47
  /// Reads a record with id AbbrevID from Cursor, resetting the
48
  /// internal state.
49
  Expected<unsigned> readRecord(llvm::BitstreamCursor &Cursor,
50
                                unsigned AbbrevID);
51
52
  /// Is this a module file for a module (rather than a PCH or similar).
53
730
  bool isModule() const { return F->isModule(); }
54
55
  /// Retrieve the AST context that this AST reader supplements.
56
5.80M
  ASTContext &getContext() { return Reader->getContext(); }
57
58
  /// The current position in this record.
59
15.9M
  unsigned getIdx() const { return Idx; }
60
61
  /// The length of this record.
62
11.6M
  size_t size() const { return Record.size(); }
63
64
  /// An arbitrary index in this record.
65
4.16M
  const uint64_t &operator[](size_t N) { return Record[N]; }
66
67
  /// Returns the last value in this record.
68
312
  uint64_t back() { return Record.back(); }
69
70
  /// Returns the current value in this record, and advances to the
71
  /// next value.
72
225M
  uint64_t readInt() { return Record[Idx++]; }
73
74
0
  ArrayRef<uint64_t> readIntArray(unsigned Len) {
75
0
    auto Array = llvm::makeArrayRef(Record).slice(Idx, Len);
76
0
    Idx += Len;
77
0
    return Array;
78
0
  }
79
80
  /// Returns the current value in this record, without advancing.
81
10.5k
  uint64_t peekInt() { return Record[Idx]; }
82
83
  /// Skips the specified number of values.
84
99.1k
  void skipInts(unsigned N) { Idx += N; }
85
86
  /// Retrieve the global submodule ID its local ID number.
87
  serialization::SubmoduleID
88
4.51M
  getGlobalSubmoduleID(unsigned LocalID) {
89
4.51M
    return Reader->getGlobalSubmoduleID(*F, LocalID);
90
4.51M
  }
91
92
  /// Retrieve the submodule that corresponds to a global submodule ID.
93
156
  Module *getSubmodule(serialization::SubmoduleID GlobalID) {
94
156
    return Reader->getSubmodule(GlobalID);
95
156
  }
96
97
  /// Read the record that describes the lexical contents of a DC.
98
31
  bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC) {
99
31
    return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor, Offset,
100
31
                                                 DC);
101
31
  }
102
103
  /// Read the record that describes the visible contents of a DC.
104
  bool readVisibleDeclContextStorage(uint64_t Offset,
105
0
                                     serialization::DeclID ID) {
106
0
    return Reader->ReadVisibleDeclContextStorage(*F, F->DeclsCursor, Offset,
107
0
                                                 ID);
108
0
  }
109
110
55.0k
  ExplicitSpecifier readExplicitSpec() {
111
55.0k
    uint64_t Kind = readInt();
112
55.0k
    bool HasExpr = Kind & 0x1;
113
55.0k
    Kind = Kind >> 1;
114
55.0k
    return ExplicitSpecifier(HasExpr ? 
readExpr()24
: nullptr,
115
55.0k
                             static_cast<ExplicitSpecKind>(Kind));
116
55.0k
  }
117
118
  /// Read information about an exception specification (inherited).
119
  //FunctionProtoType::ExceptionSpecInfo
120
  //readExceptionSpecInfo(SmallVectorImpl<QualType> &ExceptionStorage);
121
122
  /// Get the global offset corresponding to a local offset.
123
310k
  uint64_t getGlobalBitOffset(uint64_t LocalOffset) {
124
310k
    return Reader->getGlobalBitOffset(*F, LocalOffset);
125
310k
  }
126
127
  /// Reads a statement.
128
450k
  Stmt *readStmt() { return Reader->ReadStmt(*F); }
129
260k
  Stmt *readStmtRef() { return readStmt(); /* FIXME: readSubStmt? */ }
130
131
  /// Reads an expression.
132
361k
  Expr *readExpr() { return Reader->ReadExpr(*F); }
133
134
  /// Reads a sub-statement operand during statement reading.
135
167k
  Stmt *readSubStmt() { return Reader->ReadSubStmt(); }
136
137
  /// Reads a sub-expression operand during statement reading.
138
1.57M
  Expr *readSubExpr() { return Reader->ReadSubExpr(); }
139
140
  /// Reads a declaration with the given local ID in the given module.
141
  ///
142
  /// \returns The requested declaration, casted to the given return type.
143
  template<typename T>
144
148
  T *GetLocalDeclAs(uint32_t LocalID) {
145
148
    return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
146
148
  }
clang::FunctionDecl* clang::ASTRecordReader::GetLocalDeclAs<clang::FunctionDecl>(unsigned int)
Line
Count
Source
144
1
  T *GetLocalDeclAs(uint32_t LocalID) {
145
1
    return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
146
1
  }
clang::NamedDecl* clang::ASTRecordReader::GetLocalDeclAs<clang::NamedDecl>(unsigned int)
Line
Count
Source
144
147
  T *GetLocalDeclAs(uint32_t LocalID) {
145
147
    return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
146
147
  }
Unexecuted instantiation: clang::VarDecl* clang::ASTRecordReader::GetLocalDeclAs<clang::VarDecl>(unsigned int)
Unexecuted instantiation: clang::MSGuidDecl* clang::ASTRecordReader::GetLocalDeclAs<clang::MSGuidDecl>(unsigned int)
147
148
  /// Reads a TemplateArgumentLocInfo appropriate for the
149
  /// given TemplateArgument kind, advancing Idx.
150
  TemplateArgumentLocInfo
151
  readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind);
152
153
  /// Reads a TemplateArgumentLoc, advancing Idx.
154
  TemplateArgumentLoc readTemplateArgumentLoc();
155
156
  const ASTTemplateArgumentListInfo*
157
  readASTTemplateArgumentListInfo();
158
159
  /// Reads a declarator info from the given record, advancing Idx.
160
  TypeSourceInfo *readTypeSourceInfo();
161
162
  /// Reads the location information for a type.
163
  void readTypeLoc(TypeLoc TL);
164
165
166
  /// Map a local type ID within a given AST file to a global type ID.
167
2.88M
  serialization::TypeID getGlobalTypeID(unsigned LocalID) const {
168
2.88M
    return Reader->getGlobalTypeID(*F, LocalID);
169
2.88M
  }
170
171
358k
  Qualifiers readQualifiers() {
172
358k
    return Qualifiers::fromOpaqueValue(readInt());
173
358k
  }
174
175
  /// Read a type from the current position in the record.
176
12.8M
  QualType readType() {
177
12.8M
    return Reader->readType(*F, Record, Idx);
178
12.8M
  }
179
5.65M
  QualType readQualType() {
180
5.65M
    return readType();
181
5.65M
  }
182
183
  /// Reads a declaration ID from the given position in this record.
184
  ///
185
  /// \returns The declaration ID read from the record, adjusted to a global ID.
186
9.51M
  serialization::DeclID readDeclID() {
187
9.51M
    return Reader->ReadDeclID(*F, Record, Idx);
188
9.51M
  }
189
190
  /// Reads a declaration from the given position in a record in the
191
  /// given module, advancing Idx.
192
4.91M
  Decl *readDecl() {
193
4.91M
    return Reader->ReadDecl(*F, Record, Idx);
194
4.91M
  }
195
2.81M
  Decl *readDeclRef() {
196
2.81M
    return readDecl();
197
2.81M
  }
198
199
  /// Reads a declaration from the given position in the record,
200
  /// advancing Idx.
201
  ///
202
  /// \returns The declaration read from this location, casted to the given
203
  /// result type.
204
  template<typename T>
205
10.8M
  T *readDeclAs() {
206
10.8M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
10.8M
  }
clang::ParmVarDecl* clang::ASTRecordReader::readDeclAs<clang::ParmVarDecl>()
Line
Count
Source
205
1.23M
  T *readDeclAs() {
206
1.23M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
1.23M
  }
clang::NamedDecl* clang::ASTRecordReader::readDeclAs<clang::NamedDecl>()
Line
Count
Source
205
843k
  T *readDeclAs() {
206
843k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
843k
  }
clang::FieldDecl* clang::ASTRecordReader::readDeclAs<clang::FieldDecl>()
Line
Count
Source
205
16.9k
  T *readDeclAs() {
206
16.9k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
16.9k
  }
clang::IndirectFieldDecl* clang::ASTRecordReader::readDeclAs<clang::IndirectFieldDecl>()
Line
Count
Source
205
6
  T *readDeclAs() {
206
6
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
6
  }
clang::NamespaceDecl* clang::ASTRecordReader::readDeclAs<clang::NamespaceDecl>()
Line
Count
Source
205
34.1k
  T *readDeclAs() {
206
34.1k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
34.1k
  }
clang::NamespaceAliasDecl* clang::ASTRecordReader::readDeclAs<clang::NamespaceAliasDecl>()
Line
Count
Source
205
5
  T *readDeclAs() {
206
5
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
5
  }
clang::CXXRecordDecl* clang::ASTRecordReader::readDeclAs<clang::CXXRecordDecl>()
Line
Count
Source
205
41.5k
  T *readDeclAs() {
206
41.5k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
41.5k
  }
clang::ValueDecl* clang::ASTRecordReader::readDeclAs<clang::ValueDecl>()
Line
Count
Source
205
496k
  T *readDeclAs() {
206
496k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
496k
  }
clang::DeclContext* clang::ASTRecordReader::readDeclAs<clang::DeclContext>()
Line
Count
Source
205
6.38M
  T *readDeclAs() {
206
6.38M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
6.38M
  }
clang::TypeAliasTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::TypeAliasTemplateDecl>()
Line
Count
Source
205
5.77k
  T *readDeclAs() {
206
5.77k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
5.77k
  }
clang::EnumDecl* clang::ASTRecordReader::readDeclAs<clang::EnumDecl>()
Line
Count
Source
205
3.17k
  T *readDeclAs() {
206
3.17k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
3.17k
  }
clang::FunctionTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::FunctionTemplateDecl>()
Line
Count
Source
205
315k
  T *readDeclAs() {
206
315k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
315k
  }
clang::FunctionDecl* clang::ASTRecordReader::readDeclAs<clang::FunctionDecl>()
Line
Count
Source
205
36.1k
  T *readDeclAs() {
206
36.1k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
36.1k
  }
clang::ImplicitParamDecl* clang::ASTRecordReader::readDeclAs<clang::ImplicitParamDecl>()
Line
Count
Source
205
162k
  T *readDeclAs() {
206
162k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
162k
  }
clang::ObjCMethodDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCMethodDecl>()
Line
Count
Source
205
7.68k
  T *readDeclAs() {
206
7.68k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
7.68k
  }
clang::ObjCTypeParamDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCTypeParamDecl>()
Line
Count
Source
205
28.0k
  T *readDeclAs() {
206
28.0k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
28.0k
  }
clang::ObjCProtocolDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCProtocolDecl>()
Line
Count
Source
205
9.27k
  T *readDeclAs() {
206
9.27k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
9.27k
  }
clang::ObjCInterfaceDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCInterfaceDecl>()
Line
Count
Source
205
17.5k
  T *readDeclAs() {
206
17.5k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
17.5k
  }
clang::ObjCIvarDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCIvarDecl>()
Line
Count
Source
205
3.80k
  T *readDeclAs() {
206
3.80k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
3.80k
  }
clang::ObjCPropertyDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCPropertyDecl>()
Line
Count
Source
205
16
  T *readDeclAs() {
206
16
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
16
  }
clang::VarTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::VarTemplateDecl>()
Line
Count
Source
205
397
  T *readDeclAs() {
206
397
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
397
  }
clang::VarDecl* clang::ASTRecordReader::readDeclAs<clang::VarDecl>()
Line
Count
Source
205
54.8k
  T *readDeclAs() {
206
54.8k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
54.8k
  }
clang::BindingDecl* clang::ASTRecordReader::readDeclAs<clang::BindingDecl>()
Line
Count
Source
205
12
  T *readDeclAs() {
206
12
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
12
  }
clang::UsingShadowDecl* clang::ASTRecordReader::readDeclAs<clang::UsingShadowDecl>()
Line
Count
Source
205
1.66k
  T *readDeclAs() {
206
1.66k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
1.66k
  }
clang::ConstructorUsingShadowDecl* clang::ASTRecordReader::readDeclAs<clang::ConstructorUsingShadowDecl>()
Line
Count
Source
205
138
  T *readDeclAs() {
206
138
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
138
  }
clang::ClassTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::ClassTemplateDecl>()
Line
Count
Source
205
886k
  T *readDeclAs() {
206
886k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
886k
  }
clang::CXXMethodDecl* clang::ASTRecordReader::readDeclAs<clang::CXXMethodDecl>()
Line
Count
Source
205
356
  T *readDeclAs() {
206
356
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
356
  }
clang::CXXConstructorDecl* clang::ASTRecordReader::readDeclAs<clang::CXXConstructorDecl>()
Line
Count
Source
205
9.53k
  T *readDeclAs() {
206
9.53k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
9.53k
  }
clang::RedeclarableTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::RedeclarableTemplateDecl>()
Line
Count
Source
205
173k
  T *readDeclAs() {
206
173k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
173k
  }
clang::ClassTemplatePartialSpecializationDecl* clang::ASTRecordReader::readDeclAs<clang::ClassTemplatePartialSpecializationDecl>()
Line
Count
Source
205
19.2k
  T *readDeclAs() {
206
19.2k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
19.2k
  }
clang::VarTemplatePartialSpecializationDecl* clang::ASTRecordReader::readDeclAs<clang::VarTemplatePartialSpecializationDecl>()
Line
Count
Source
205
25
  T *readDeclAs() {
206
25
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
25
  }
clang::ConceptDecl* clang::ASTRecordReader::readDeclAs<clang::ConceptDecl>()
Line
Count
Source
205
52
  T *readDeclAs() {
206
52
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
52
  }
clang::LabelDecl* clang::ASTRecordReader::readDeclAs<clang::LabelDecl>()
Line
Count
Source
205
35
  T *readDeclAs() {
206
35
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
35
  }
clang::CapturedDecl* clang::ASTRecordReader::readDeclAs<clang::CapturedDecl>()
Line
Count
Source
205
29.4k
  T *readDeclAs() {
206
29.4k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
29.4k
  }
clang::RecordDecl* clang::ASTRecordReader::readDeclAs<clang::RecordDecl>()
Line
Count
Source
205
29.4k
  T *readDeclAs() {
206
29.4k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
29.4k
  }
clang::RequiresExprBodyDecl* clang::ASTRecordReader::readDeclAs<clang::RequiresExprBodyDecl>()
Line
Count
Source
205
2
  T *readDeclAs() {
206
2
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
2
  }
clang::BlockDecl* clang::ASTRecordReader::readDeclAs<clang::BlockDecl>()
Line
Count
Source
205
26
  T *readDeclAs() {
206
26
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
26
  }
clang::NonTypeTemplateParmDecl* clang::ASTRecordReader::readDeclAs<clang::NonTypeTemplateParmDecl>()
Line
Count
Source
205
34.3k
  T *readDeclAs() {
206
34.3k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
34.3k
  }
clang::MSPropertyDecl* clang::ASTRecordReader::readDeclAs<clang::MSPropertyDecl>()
Line
Count
Source
205
22
  T *readDeclAs() {
206
22
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
22
  }
clang::MSGuidDecl* clang::ASTRecordReader::readDeclAs<clang::MSGuidDecl>()
Line
Count
Source
205
1
  T *readDeclAs() {
206
1
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
1
  }
208
209
6.37M
  IdentifierInfo *readIdentifier() {
210
6.37M
    return Reader->readIdentifier(*F, Record, Idx);
211
6.37M
  }
212
213
  /// Read a selector from the Record, advancing Idx.
214
37.1k
  Selector readSelector() {
215
37.1k
    return Reader->ReadSelector(*F, Record, Idx);
216
37.1k
  }
217
218
  /// Read a declaration name, advancing Idx.
219
  // DeclarationName readDeclarationName(); (inherited)
220
  DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name);
221
  DeclarationNameInfo readDeclarationNameInfo();
222
223
  void readQualifierInfo(QualifierInfo &Info);
224
225
  /// Return a nested name specifier, advancing Idx.
226
  // NestedNameSpecifier *readNestedNameSpecifier(); (inherited)
227
228
  NestedNameSpecifierLoc readNestedNameSpecifierLoc();
229
230
  /// Read a template name, advancing Idx.
231
  // TemplateName readTemplateName(); (inherited)
232
233
  /// Read a template argument, advancing Idx. (inherited)
234
  // TemplateArgument readTemplateArgument();
235
  using DataStreamBasicReader::readTemplateArgument;
236
1.57M
  TemplateArgument readTemplateArgument(bool Canonicalize) {
237
1.57M
    TemplateArgument Arg = readTemplateArgument();
238
1.57M
    if (Canonicalize) {
239
1.30M
      Arg = getContext().getCanonicalTemplateArgument(Arg);
240
1.30M
    }
241
1.57M
    return Arg;
242
1.57M
  }
243
244
  /// Read a template parameter list, advancing Idx.
245
  TemplateParameterList *readTemplateParameterList();
246
247
  /// Read a template argument array, advancing Idx.
248
  void readTemplateArgumentList(SmallVectorImpl<TemplateArgument> &TemplArgs,
249
                                bool Canonicalize = false);
250
251
  /// Read a UnresolvedSet structure, advancing Idx.
252
  void readUnresolvedSet(LazyASTUnresolvedSet &Set);
253
254
  /// Read a C++ base specifier, advancing Idx.
255
  CXXBaseSpecifier readCXXBaseSpecifier();
256
257
  /// Read a CXXCtorInitializer array, advancing Idx.
258
  CXXCtorInitializer **readCXXCtorInitializers();
259
260
1.77k
  CXXTemporary *readCXXTemporary() {
261
1.77k
    return Reader->ReadCXXTemporary(*F, Record, Idx);
262
1.77k
  }
263
264
  /// Read an OMPTraitInfo object, advancing Idx.
265
  OMPTraitInfo *readOMPTraitInfo();
266
267
  /// Read an OpenMP clause, advancing Idx.
268
  OMPClause *readOMPClause();
269
270
  /// Read an OpenMP children, advancing Idx.
271
  void readOMPChildren(OMPChildren *Data);
272
273
  /// Read a source location, advancing Idx.
274
17.9M
  SourceLocation readSourceLocation() {
275
17.9M
    return Reader->ReadSourceLocation(*F, Record, Idx);
276
17.9M
  }
277
278
  /// Read a source range, advancing Idx.
279
3.15M
  SourceRange readSourceRange() {
280
3.15M
    return Reader->ReadSourceRange(*F, Record, Idx);
281
3.15M
  }
282
283
  /// Read an arbitrary constant value, advancing Idx.
284
  APValue readAPValue();
285
286
  /// Read an integral value, advancing Idx.
287
  // llvm::APInt readAPInt(); (inherited)
288
289
  /// Read a signed integral value, advancing Idx.
290
  // llvm::APSInt readAPSInt(); (inherited)
291
292
  /// Read a floating-point value, advancing Idx.
293
  llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem);
294
295
  /// Read a boolean value, advancing Idx.
296
7.11M
  bool readBool() { return readInt() != 0; }
297
298
  /// Read a 32-bit unsigned value; required to satisfy BasicReader.
299
14.5M
  uint32_t readUInt32() {
300
14.5M
    return uint32_t(readInt());
301
14.5M
  }
302
303
  /// Read a 64-bit unsigned value; required to satisfy BasicReader.
304
424k
  uint64_t readUInt64() {
305
424k
    return readInt();
306
424k
  }
307
308
  /// Read a string, advancing Idx.
309
150k
  std::string readString() {
310
150k
    return Reader->ReadString(Record, Idx);
311
150k
  }
312
313
  /// Read a path, advancing Idx.
314
0
  std::string readPath() {
315
0
    return Reader->ReadPath(*F, Record, Idx);
316
0
  }
317
318
  /// Read a version tuple, advancing Idx.
319
216k
  VersionTuple readVersionTuple() {
320
216k
    return ASTReader::ReadVersionTuple(Record, Idx);
321
216k
  }
322
323
  /// Reads one attribute from the current stream position, advancing Idx.
324
  Attr *readAttr();
325
326
  /// Reads attributes from the current stream position, advancing Idx.
327
  void readAttributes(AttrVec &Attrs);
328
329
  /// Reads a token out of a record, advancing Idx.
330
0
  Token readToken() {
331
0
    return Reader->ReadToken(*F, Record, Idx);
332
0
  }
333
334
280
  void recordSwitchCaseID(SwitchCase *SC, unsigned ID) {
335
280
    Reader->RecordSwitchCaseID(SC, ID);
336
280
  }
337
338
  /// Retrieve the switch-case statement with the given ID.
339
280
  SwitchCase *getSwitchCaseWithID(unsigned ID) {
340
280
    return Reader->getSwitchCaseWithID(ID);
341
280
  }
342
};
343
344
/// Helper class that saves the current stream position and
345
/// then restores it when destroyed.
346
struct SavedStreamPosition {
347
  explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
348
17.7M
      : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
349
350
17.7M
  ~SavedStreamPosition() {
351
17.7M
    if (llvm::Error Err = Cursor.JumpToBit(Offset))
352
0
      llvm::report_fatal_error(
353
0
          "Cursor should always be able to go back, failed: " +
354
0
          toString(std::move(Err)));
355
17.7M
  }
356
357
private:
358
  llvm::BitstreamCursor &Cursor;
359
  uint64_t Offset;
360
};
361
362
0
inline void PCHValidator::Error(const char *Msg) {
363
0
  Reader.Error(Msg);
364
0
}
365
366
} // namespace clang
367
368
#endif