/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 | 21.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 | 1.01k | bool isModule() const { return F->isModule(); } |
54 | | |
55 | | /// Retrieve the AST context that this AST reader supplements. |
56 | 15.1M | ASTContext &getContext() { return Reader->getContext(); } |
57 | | |
58 | | /// The current position in this record. |
59 | 55.0M | unsigned getIdx() const { return Idx; } |
60 | | |
61 | | /// The length of this record. |
62 | 31.9M | size_t size() const { return Record.size(); } |
63 | | |
64 | | /// An arbitrary index in this record. |
65 | 25.5M | const uint64_t &operator[](size_t N) { return Record[N]; } |
66 | | |
67 | | /// Returns the last value in this record. |
68 | 360 | uint64_t back() { return Record.back(); } |
69 | | |
70 | | /// Returns the current value in this record, and advances to the |
71 | | /// next value. |
72 | 464M | 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 | 109k | uint64_t peekInt() { return Record[Idx]; } |
82 | | |
83 | | /// Skips the specified number of values. |
84 | 275k | void skipInts(unsigned N) { Idx += N; } |
85 | | |
86 | | /// Retrieve the global submodule ID its local ID number. |
87 | | serialization::SubmoduleID |
88 | 9.33M | getGlobalSubmoduleID(unsigned LocalID) { |
89 | 9.33M | return Reader->getGlobalSubmoduleID(*F, LocalID); |
90 | 9.33M | } |
91 | | |
92 | | /// Retrieve the submodule that corresponds to a global submodule ID. |
93 | 180 | Module *getSubmodule(serialization::SubmoduleID GlobalID) { |
94 | 180 | return Reader->getSubmodule(GlobalID); |
95 | 180 | } |
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 | 200k | ExplicitSpecifier readExplicitSpec() { |
111 | 200k | uint64_t Kind = readInt(); |
112 | 200k | bool HasExpr = Kind & 0x1; |
113 | 200k | Kind = Kind >> 1; |
114 | 200k | return ExplicitSpecifier(HasExpr ? readExpr()24 : nullptr200k , |
115 | 200k | static_cast<ExplicitSpecKind>(Kind)); |
116 | 200k | } |
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 | 546k | uint64_t getGlobalBitOffset(uint64_t LocalOffset) { |
124 | 546k | return Reader->getGlobalBitOffset(*F, LocalOffset); |
125 | 546k | } |
126 | | |
127 | | /// Reads a statement. |
128 | 1.06M | Stmt *readStmt() { return Reader->ReadStmt(*F); } |
129 | 843k | Stmt *readStmtRef() { return readStmt(); /* FIXME: readSubStmt? */ } |
130 | | |
131 | | /// Reads an expression. |
132 | 1.26M | Expr *readExpr() { return Reader->ReadExpr(*F); } |
133 | | |
134 | | /// Reads a sub-statement operand during statement reading. |
135 | 1.55M | Stmt *readSubStmt() { return Reader->ReadSubStmt(); } |
136 | | |
137 | | /// Reads a sub-expression operand during statement reading. |
138 | 8.73M | 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 | 817 | T *GetLocalDeclAs(uint32_t LocalID) { |
145 | 817 | return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID)); |
146 | 817 | } 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 | 816 | T *GetLocalDeclAs(uint32_t LocalID) { | 145 | 816 | return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID)); | 146 | 816 | } |
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.75M | serialization::TypeID getGlobalTypeID(unsigned LocalID) const { |
168 | 4.75M | return Reader->getGlobalTypeID(*F, LocalID); |
169 | 4.75M | } |
170 | | |
171 | 1.02M | Qualifiers readQualifiers() { |
172 | 1.02M | return Qualifiers::fromOpaqueValue(readInt()); |
173 | 1.02M | } |
174 | | |
175 | | /// Read a type from the current position in the record. |
176 | 39.4M | QualType readType() { |
177 | 39.4M | return Reader->readType(*F, Record, Idx); |
178 | 39.4M | } |
179 | 14.2M | QualType readQualType() { |
180 | 14.2M | return readType(); |
181 | 14.2M | } |
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 | 19.1M | serialization::DeclID readDeclID() { |
187 | 19.1M | return Reader->ReadDeclID(*F, Record, Idx); |
188 | 19.1M | } |
189 | | |
190 | | /// Reads a declaration from the given position in a record in the |
191 | | /// given module, advancing Idx. |
192 | 9.92M | Decl *readDecl() { |
193 | 9.92M | return Reader->ReadDecl(*F, Record, Idx); |
194 | 9.92M | } |
195 | 6.68M | Decl *readDeclRef() { |
196 | 6.68M | return readDecl(); |
197 | 6.68M | } |
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 | 32.0M | T *readDeclAs() { |
206 | 32.0M | return Reader->ReadDeclAs<T>(*F, Record, Idx); |
207 | 32.0M | } clang::ParmVarDecl* clang::ASTRecordReader::readDeclAs<clang::ParmVarDecl>() Line | Count | Source | 205 | 3.50M | T *readDeclAs() { | 206 | 3.50M | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 3.50M | } |
clang::NamedDecl* clang::ASTRecordReader::readDeclAs<clang::NamedDecl>() Line | Count | Source | 205 | 9.44M | T *readDeclAs() { | 206 | 9.44M | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 9.44M | } |
clang::FieldDecl* clang::ASTRecordReader::readDeclAs<clang::FieldDecl>() Line | Count | Source | 205 | 86.3k | T *readDeclAs() { | 206 | 86.3k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 86.3k | } |
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 | 181k | T *readDeclAs() { | 206 | 181k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 181k | } |
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 | 570k | T *readDeclAs() { | 206 | 570k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 570k | } |
clang::ValueDecl* clang::ASTRecordReader::readDeclAs<clang::ValueDecl>() Line | Count | Source | 205 | 2.94M | T *readDeclAs() { | 206 | 2.94M | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 2.94M | } |
clang::DeclContext* clang::ASTRecordReader::readDeclAs<clang::DeclContext>() Line | Count | Source | 205 | 11.7M | T *readDeclAs() { | 206 | 11.7M | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 11.7M | } |
clang::TypeAliasTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::TypeAliasTemplateDecl>() Line | Count | Source | 205 | 65.6k | T *readDeclAs() { | 206 | 65.6k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 65.6k | } |
clang::EnumDecl* clang::ASTRecordReader::readDeclAs<clang::EnumDecl>() Line | Count | Source | 205 | 5.82k | T *readDeclAs() { | 206 | 5.82k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 5.82k | } |
clang::FunctionTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::FunctionTemplateDecl>() Line | Count | Source | 205 | 677k | T *readDeclAs() { | 206 | 677k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 677k | } |
clang::FunctionDecl* clang::ASTRecordReader::readDeclAs<clang::FunctionDecl>() Line | Count | Source | 205 | 232k | T *readDeclAs() { | 206 | 232k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 232k | } |
clang::ImplicitParamDecl* clang::ASTRecordReader::readDeclAs<clang::ImplicitParamDecl>() Line | Count | Source | 205 | 165k | T *readDeclAs() { | 206 | 165k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 165k | } |
clang::ObjCMethodDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCMethodDecl>() Line | Count | Source | 205 | 6.91k | T *readDeclAs() { | 206 | 6.91k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 6.91k | } |
clang::ObjCTypeParamDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCTypeParamDecl>() Line | Count | Source | 205 | 21.6k | T *readDeclAs() { | 206 | 21.6k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 21.6k | } |
clang::ObjCProtocolDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCProtocolDecl>() Line | Count | Source | 205 | 7.44k | T *readDeclAs() { | 206 | 7.44k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 7.44k | } |
clang::ObjCInterfaceDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCInterfaceDecl>() Line | Count | Source | 205 | 14.0k | T *readDeclAs() { | 206 | 14.0k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 14.0k | } |
clang::ObjCIvarDecl* clang::ASTRecordReader::readDeclAs<clang::ObjCIvarDecl>() Line | Count | Source | 205 | 3.41k | T *readDeclAs() { | 206 | 3.41k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 3.41k | } |
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 | 413 | T *readDeclAs() { | 206 | 413 | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 413 | } |
clang::VarDecl* clang::ASTRecordReader::readDeclAs<clang::VarDecl>() Line | Count | Source | 205 | 130k | T *readDeclAs() { | 206 | 130k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 130k | } |
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 | 63.8k | T *readDeclAs() { | 206 | 63.8k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 63.8k | } |
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.37M | T *readDeclAs() { | 206 | 1.37M | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 1.37M | } |
clang::CXXConstructorDecl* clang::ASTRecordReader::readDeclAs<clang::CXXConstructorDecl>() Line | Count | Source | 205 | 34.7k | T *readDeclAs() { | 206 | 34.7k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 34.7k | } |
clang::CXXMethodDecl* clang::ASTRecordReader::readDeclAs<clang::CXXMethodDecl>() Line | Count | Source | 205 | 1.85k | T *readDeclAs() { | 206 | 1.85k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 1.85k | } |
clang::RedeclarableTemplateDecl* clang::ASTRecordReader::readDeclAs<clang::RedeclarableTemplateDecl>() Line | Count | Source | 205 | 493k | T *readDeclAs() { | 206 | 493k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 493k | } |
clang::ClassTemplatePartialSpecializationDecl* clang::ASTRecordReader::readDeclAs<clang::ClassTemplatePartialSpecializationDecl>() Line | Count | Source | 205 | 31.4k | T *readDeclAs() { | 206 | 31.4k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 31.4k | } |
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 | 56 | T *readDeclAs() { | 206 | 56 | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 56 | } |
clang::LabelDecl* clang::ASTRecordReader::readDeclAs<clang::LabelDecl>() Line | Count | Source | 205 | 1.16k | T *readDeclAs() { | 206 | 1.16k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 1.16k | } |
clang::CapturedDecl* clang::ASTRecordReader::readDeclAs<clang::CapturedDecl>() Line | Count | Source | 205 | 32.1k | T *readDeclAs() { | 206 | 32.1k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 32.1k | } |
clang::RecordDecl* clang::ASTRecordReader::readDeclAs<clang::RecordDecl>() Line | Count | Source | 205 | 32.1k | T *readDeclAs() { | 206 | 32.1k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 32.1k | } |
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 | 145k | T *readDeclAs() { | 206 | 145k | return Reader->ReadDeclAs<T>(*F, Record, Idx); | 207 | 145k | } |
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 | 14.3M | IdentifierInfo *readIdentifier() { |
210 | 14.3M | return Reader->readIdentifier(*F, Record, Idx); |
211 | 14.3M | } |
212 | | |
213 | | /// Read a selector from the Record, advancing Idx. |
214 | 32.8k | Selector readSelector() { |
215 | 32.8k | return Reader->ReadSelector(*F, Record, Idx); |
216 | 32.8k | } |
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.32M | TemplateArgument readTemplateArgument(bool Canonicalize) { |
237 | 2.32M | TemplateArgument Arg = readTemplateArgument(); |
238 | 2.32M | if (Canonicalize) { |
239 | 1.94M | Arg = getContext().getCanonicalTemplateArgument(Arg); |
240 | 1.94M | } |
241 | 2.32M | return Arg; |
242 | 2.32M | } |
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 | 3.10k | CXXTemporary *readCXXTemporary() { |
261 | 3.10k | return Reader->ReadCXXTemporary(*F, Record, Idx); |
262 | 3.10k | } |
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 | 55.2M | SourceLocation readSourceLocation() { |
275 | 55.2M | return Reader->ReadSourceLocation(*F, Record, Idx); |
276 | 55.2M | } |
277 | | |
278 | | /// Read a source range, advancing Idx. |
279 | 6.40M | SourceRange readSourceRange() { |
280 | 6.40M | return Reader->ReadSourceRange(*F, Record, Idx); |
281 | 6.40M | } |
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 | 18.9M | bool readBool() { return readInt() != 0; } |
297 | | |
298 | | /// Read a 32-bit unsigned value; required to satisfy BasicReader. |
299 | 38.0M | uint32_t readUInt32() { |
300 | 38.0M | return uint32_t(readInt()); |
301 | 38.0M | } |
302 | | |
303 | | /// Read a 64-bit unsigned value; required to satisfy BasicReader. |
304 | 891k | uint64_t readUInt64() { |
305 | 891k | return readInt(); |
306 | 891k | } |
307 | | |
308 | | /// Read a string, advancing Idx. |
309 | 91.6k | std::string readString() { |
310 | 91.6k | return Reader->ReadString(Record, Idx); |
311 | 91.6k | } |
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 | 123k | VersionTuple readVersionTuple() { |
320 | 123k | return ASTReader::ReadVersionTuple(Record, Idx); |
321 | 123k | } |
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 | | /// Read an BTFTypeTagAttr object. |
330 | 2 | BTFTypeTagAttr *readBTFTypeTagAttr() { |
331 | 2 | return cast<BTFTypeTagAttr>(readAttr()); |
332 | 2 | } |
333 | | |
334 | | /// Reads a token out of a record, advancing Idx. |
335 | 0 | Token readToken() { |
336 | 0 | return Reader->ReadToken(*F, Record, Idx); |
337 | 0 | } |
338 | | |
339 | 15.3k | void recordSwitchCaseID(SwitchCase *SC, unsigned ID) { |
340 | 15.3k | Reader->RecordSwitchCaseID(SC, ID); |
341 | 15.3k | } |
342 | | |
343 | | /// Retrieve the switch-case statement with the given ID. |
344 | 15.3k | SwitchCase *getSwitchCaseWithID(unsigned ID) { |
345 | 15.3k | return Reader->getSwitchCaseWithID(ID); |
346 | 15.3k | } |
347 | | }; |
348 | | |
349 | | /// Helper class that saves the current stream position and |
350 | | /// then restores it when destroyed. |
351 | | struct SavedStreamPosition { |
352 | | explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor) |
353 | 30.9M | : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {} |
354 | | |
355 | 30.9M | ~SavedStreamPosition() { |
356 | 30.9M | if (llvm::Error Err = Cursor.JumpToBit(Offset)) |
357 | 0 | llvm::report_fatal_error( |
358 | 0 | llvm::Twine("Cursor should always be able to go back, failed: ") + |
359 | 0 | toString(std::move(Err))); |
360 | 30.9M | } |
361 | | |
362 | | private: |
363 | | llvm::BitstreamCursor &Cursor; |
364 | | uint64_t Offset; |
365 | | }; |
366 | | |
367 | 0 | inline void PCHValidator::Error(const char *Msg) { |
368 | 0 | Reader.Error(Msg); |
369 | 0 | } |
370 | | |
371 | | } // namespace clang |
372 | | |
373 | | #endif |