Coverage Report

Created: 2020-02-15 09:57

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