Coverage Report

Created: 2022-07-16 07:03

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