Coverage Report

Created: 2021-09-21 08:58

/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
16.4M
    : 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
967
  bool isModule() const { return F->isModule(); }
54
55
  /// Retrieve the AST context that this AST reader supplements.
56
10.9M
  ASTContext &getContext() { return Reader->getContext(); }
57
58
  /// The current position in this record.
59
35.8M
  unsigned getIdx() const { return Idx; }
60
61
  /// The length of this record.
62
22.9M
  size_t size() const { return Record.size(); }
63
64
  /// An arbitrary index in this record.
65
13.9M
  const uint64_t &operator[](size_t N) { return Record[N]; }
66
67
  /// Returns the last value in this record.
68
358
  uint64_t back() { return Record.back(); }
69
70
  /// Returns the current value in this record, and advances to the
71
  /// next value.
72
393M
  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
54.6k
  uint64_t peekInt() { return Record[Idx]; }
82
83
  /// Skips the specified number of values.
84
182k
  void skipInts(unsigned N) { Idx += N; }
85
86
  /// Retrieve the global submodule ID its local ID number.
87
  serialization::SubmoduleID
88
7.68M
  getGlobalSubmoduleID(unsigned LocalID) {
89
7.68M
    return Reader->getGlobalSubmoduleID(*F, LocalID);
90
7.68M
  }
91
92
  /// Retrieve the submodule that corresponds to a global submodule ID.
93
179
  Module *getSubmodule(serialization::SubmoduleID GlobalID) {
94
179
    return Reader->getSubmodule(GlobalID);
95
179
  }
96
97
  /// Read the record that describes the lexical contents of a DC.
98
32
  bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC) {
99
32
    return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor, Offset,
100
32
                                                 DC);
101
32
  }
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
118k
  ExplicitSpecifier readExplicitSpec() {
111
118k
    uint64_t Kind = readInt();
112
118k
    bool HasExpr = Kind & 0x1;
113
118k
    Kind = Kind >> 1;
114
118k
    return ExplicitSpecifier(HasExpr ? 
readExpr()24
:
nullptr118k
,
115
118k
                             static_cast<ExplicitSpecKind>(Kind));
116
118k
  }
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
483k
  uint64_t getGlobalBitOffset(uint64_t LocalOffset) {
124
483k
    return Reader->getGlobalBitOffset(*F, LocalOffset);
125
483k
  }
126
127
  /// Reads a statement.
128
819k
  Stmt *readStmt() { return Reader->ReadStmt(*F); }
129
612k
  Stmt *readStmtRef() { return readStmt(); /* FIXME: readSubStmt? */ }
130
131
  /// Reads an expression.
132
815k
  Expr *readExpr() { return Reader->ReadExpr(*F); }
133
134
  /// Reads a sub-statement operand during statement reading.
135
757k
  Stmt *readSubStmt() { return Reader->ReadSubStmt(); }
136
137
  /// Reads a sub-expression operand during statement reading.
138
4.83M
  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
625
  T *GetLocalDeclAs(uint32_t LocalID) {
145
625
    return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
146
625
  }
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
624
  T *GetLocalDeclAs(uint32_t LocalID) {
145
624
    return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
146
624
  }
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
4.51M
  serialization::TypeID getGlobalTypeID(unsigned LocalID) const {
168
4.51M
    return Reader->getGlobalTypeID(*F, LocalID);
169
4.51M
  }
170
171
665k
  Qualifiers readQualifiers() {
172
665k
    return Qualifiers::fromOpaqueValue(readInt());
173
665k
  }
174
175
  /// Read a type from the current position in the record.
176
26.5M
  QualType readType() {
177
26.5M
    return Reader->readType(*F, Record, Idx);
178
26.5M
  }
179
10.5M
  QualType readQualType() {
180
10.5M
    return readType();
181
10.5M
  }
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
15.4M
  serialization::DeclID readDeclID() {
187
15.4M
    return Reader->ReadDeclID(*F, Record, Idx);
188
15.4M
  }
189
190
  /// Reads a declaration from the given position in a record in the
191
  /// given module, advancing Idx.
192
8.56M
  Decl *readDecl() {
193
8.56M
    return Reader->ReadDecl(*F, Record, Idx);
194
8.56M
  }
195
5.13M
  Decl *readDeclRef() {
196
5.13M
    return readDecl();
197
5.13M
  }
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
21.6M
  T *readDeclAs() {
206
21.6M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
21.6M
  }
clang::ParmVarDecl* clang::ASTRecordReader::readDeclAs<clang::ParmVarDecl>()
Line
Count
Source
205
2.25M
  T *readDeclAs() {
206
2.25M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
2.25M
  }
clang::NamedDecl* clang::ASTRecordReader::readDeclAs<clang::NamedDecl>()
Line
Count
Source
205
4.05M
  T *readDeclAs() {
206
4.05M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
4.05M
  }
clang::FieldDecl* clang::ASTRecordReader::readDeclAs<clang::FieldDecl>()
Line
Count
Source
205
45.0k
  T *readDeclAs() {
206
45.0k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
45.0k
  }
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
153k
  T *readDeclAs() {
206
153k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
153k
  }
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
284k
  T *readDeclAs() {
206
284k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
284k
  }
clang::ValueDecl* clang::ASTRecordReader::readDeclAs<clang::ValueDecl>()
Line
Count
Source
205
1.60M
  T *readDeclAs() {
206
1.60M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
1.60M
  }
clang::DeclContext* clang::ASTRecordReader::readDeclAs<clang::DeclContext>()
Line
Count
Source
205
10.5M
  T *readDeclAs() {
206
10.5M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
10.5M
  }
clang::TypeAliasTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::TypeAliasTemplateDecl>()
Line
Count
Source
205
38.4k
  T *readDeclAs() {
206
38.4k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
38.4k
  }
clang::EnumDecl* clang::ASTRecordReader::readDeclAs<clang::EnumDecl>()
Line
Count
Source
205
4.63k
  T *readDeclAs() {
206
4.63k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
4.63k
  }
clang::FunctionTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::FunctionTemplateDecl>()
Line
Count
Source
205
492k
  T *readDeclAs() {
206
492k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
492k
  }
clang::FunctionDecl* clang::ASTRecordReader::readDeclAs<clang::FunctionDecl>()
Line
Count
Source
205
95.6k
  T *readDeclAs() {
206
95.6k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
95.6k
  }
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
6.86k
  T *readDeclAs() {
206
6.86k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
6.86k
  }
clang::ObjCTypeParamDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCTypeParamDecl>()
Line
Count
Source
205
21.3k
  T *readDeclAs() {
206
21.3k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
21.3k
  }
clang::ObjCProtocolDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCProtocolDecl>()
Line
Count
Source
205
7.35k
  T *readDeclAs() {
206
7.35k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
7.35k
  }
clang::ObjCInterfaceDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCInterfaceDecl>()
Line
Count
Source
205
13.8k
  T *readDeclAs() {
206
13.8k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
13.8k
  }
clang::ObjCIvarDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCIvarDecl>()
Line
Count
Source
205
3.38k
  T *readDeclAs() {
206
3.38k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
3.38k
  }
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
  }
Unexecuted instantiation: clang::Decl* clang::ASTRecordReader::readDeclAs<clang::Decl>()
clang::VarTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::VarTemplateDecl>()
Line
Count
Source
205
399
  T *readDeclAs() {
206
399
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
399
  }
clang::VarDecl* clang::ASTRecordReader::readDeclAs<clang::VarDecl>()
Line
Count
Source
205
93.9k
  T *readDeclAs() {
206
93.9k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
93.9k
  }
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
12.7k
  T *readDeclAs() {
206
12.7k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
12.7k
  }
clang::UsingEnumDecl* clang::ASTRecordReader::readDeclAs<clang::UsingEnumDecl>()
Line
Count
Source
205
1
  T *readDeclAs() {
206
1
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
1
  }
clang::ConstructorUsingShadowDecl* clang::ASTRecordReader::readDeclAs<clang::ConstructorUsingShadowDecl>()
Line
Count
Source
205
152
  T *readDeclAs() {
206
152
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
152
  }
clang::ClassTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::ClassTemplateDecl>()
Line
Count
Source
205
1.24M
  T *readDeclAs() {
206
1.24M
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
1.24M
  }
clang::CXXConstructorDecl* clang::ASTRecordReader::readDeclAs<clang::CXXConstructorDecl>()
Line
Count
Source
205
20.2k
  T *readDeclAs() {
206
20.2k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
20.2k
  }
clang::CXXMethodDecl* clang::ASTRecordReader::readDeclAs<clang::CXXMethodDecl>()
Line
Count
Source
205
1.22k
  T *readDeclAs() {
206
1.22k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
1.22k
  }
clang::RedeclarableTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::RedeclarableTemplateDecl>()
Line
Count
Source
205
366k
  T *readDeclAs() {
206
366k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
366k
  }
clang::ClassTemplatePartialSpecializationDecl* clang::ASTRecordReader::readDeclAs<clang::ClassTemplatePartialSpecializationDecl>()
Line
Count
Source
205
29.0k
  T *readDeclAs() {
206
29.0k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
29.0k
  }
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
157
  T *readDeclAs() {
206
157
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
157
  }
clang::CapturedDecl* clang::ASTRecordReader::readDeclAs<clang::CapturedDecl>()
Line
Count
Source
205
31.5k
  T *readDeclAs() {
206
31.5k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
31.5k
  }
clang::RecordDecl* clang::ASTRecordReader::readDeclAs<clang::RecordDecl>()
Line
Count
Source
205
31.5k
  T *readDeclAs() {
206
31.5k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
31.5k
  }
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
99.7k
  T *readDeclAs() {
206
99.7k
    return Reader->ReadDeclAs<T>(*F, Record, Idx);
207
99.7k
  }
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
11.0M
  IdentifierInfo *readIdentifier() {
210
11.0M
    return Reader->readIdentifier(*F, Record, Idx);
211
11.0M
  }
212
213
  /// Read a selector from the Record, advancing Idx.
214
32.6k
  Selector readSelector() {
215
32.6k
    return Reader->ReadSelector(*F, Record, Idx);
216
32.6k
  }
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
2.11M
  TemplateArgument readTemplateArgument(bool Canonicalize) {
237
2.11M
    TemplateArgument Arg = readTemplateArgument();
238
2.11M
    if (Canonicalize) {
239
1.75M
      Arg = getContext().getCanonicalTemplateArgument(Arg);
240
1.75M
    }
241
2.11M
    return Arg;
242
2.11M
  }
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
2.29k
  CXXTemporary *readCXXTemporary() {
261
2.29k
    return Reader->ReadCXXTemporary(*F, Record, Idx);
262
2.29k
  }
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
37.2M
  SourceLocation readSourceLocation() {
275
37.2M
    return Reader->ReadSourceLocation(*F, Record, Idx);
276
37.2M
  }
277
278
  /// Read a source range, advancing Idx.
279
5.44M
  SourceRange readSourceRange() {
280
5.44M
    return Reader->ReadSourceRange(*F, Record, Idx);
281
5.44M
  }
282
283
  /// Read an arbitrary constant value, advancing Idx.
284
  // APValue readAPValue(); (inherited)
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
13.3M
  bool readBool() { return readInt() != 0; }
297
298
  /// Read a 32-bit unsigned value; required to satisfy BasicReader.
299
28.0M
  uint32_t readUInt32() {
300
28.0M
    return uint32_t(readInt());
301
28.0M
  }
302
303
  /// Read a 64-bit unsigned value; required to satisfy BasicReader.
304
689k
  uint64_t readUInt64() {
305
689k
    return readInt();
306
689k
  }
307
308
  /// Read a string, advancing Idx.
309
87.8k
  std::string readString() {
310
87.8k
    return Reader->ReadString(Record, Idx);
311
87.8k
  }
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
120k
  VersionTuple readVersionTuple() {
320
120k
    return ASTReader::ReadVersionTuple(Record, Idx);
321
120k
  }
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
1.97k
  void recordSwitchCaseID(SwitchCase *SC, unsigned ID) {
335
1.97k
    Reader->RecordSwitchCaseID(SC, ID);
336
1.97k
  }
337
338
  /// Retrieve the switch-case statement with the given ID.
339
1.97k
  SwitchCase *getSwitchCaseWithID(unsigned ID) {
340
1.97k
    return Reader->getSwitchCaseWithID(ID);
341
1.97k
  }
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
25.1M
      : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
349
350
25.1M
  ~SavedStreamPosition() {
351
25.1M
    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
25.1M
  }
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