1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | #include "ASTCommon.h" |
14 | #include "clang/AST/DeclCXX.h" |
15 | #include "clang/AST/DeclContextInternals.h" |
16 | #include "clang/AST/DeclTemplate.h" |
17 | #include "clang/AST/DeclVisitor.h" |
18 | #include "clang/AST/Expr.h" |
19 | #include "clang/AST/OpenMPClause.h" |
20 | #include "clang/AST/PrettyDeclStackTrace.h" |
21 | #include "clang/Basic/SourceManager.h" |
22 | #include "clang/Serialization/ASTReader.h" |
23 | #include "clang/Serialization/ASTWriter.h" |
24 | #include "llvm/Bitcode/BitstreamWriter.h" |
25 | #include "llvm/Support/ErrorHandling.h" |
26 | using namespace clang; |
27 | using namespace serialization; |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | namespace clang { |
34 | class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> { |
35 | ASTWriter &Writer; |
36 | ASTContext &Context; |
37 | ASTRecordWriter Record; |
38 | |
39 | serialization::DeclCode Code; |
40 | unsigned AbbrevToUse; |
41 | |
42 | public: |
43 | ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, |
44 | ASTWriter::RecordDataImpl &Record) |
45 | : Writer(Writer), Context(Context), Record(Writer, Record), |
46 | Code((serialization::DeclCode)0), AbbrevToUse(0) {} |
47 | |
48 | uint64_t Emit(Decl *D) { |
49 | if (!Code) |
50 | llvm::report_fatal_error(StringRef("unexpected declaration kind '") + |
51 | D->getDeclKindName() + "'"); |
52 | return Record.Emit(Code, AbbrevToUse); |
53 | } |
54 | |
55 | void Visit(Decl *D); |
56 | |
57 | void VisitDecl(Decl *D); |
58 | void VisitPragmaCommentDecl(PragmaCommentDecl *D); |
59 | void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D); |
60 | void VisitTranslationUnitDecl(TranslationUnitDecl *D); |
61 | void VisitNamedDecl(NamedDecl *D); |
62 | void VisitLabelDecl(LabelDecl *LD); |
63 | void VisitNamespaceDecl(NamespaceDecl *D); |
64 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
65 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
66 | void VisitTypeDecl(TypeDecl *D); |
67 | void VisitTypedefNameDecl(TypedefNameDecl *D); |
68 | void VisitTypedefDecl(TypedefDecl *D); |
69 | void VisitTypeAliasDecl(TypeAliasDecl *D); |
70 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
71 | void VisitTagDecl(TagDecl *D); |
72 | void VisitEnumDecl(EnumDecl *D); |
73 | void VisitRecordDecl(RecordDecl *D); |
74 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
75 | void VisitClassTemplateSpecializationDecl( |
76 | ClassTemplateSpecializationDecl *D); |
77 | void VisitClassTemplatePartialSpecializationDecl( |
78 | ClassTemplatePartialSpecializationDecl *D); |
79 | void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D); |
80 | void VisitVarTemplatePartialSpecializationDecl( |
81 | VarTemplatePartialSpecializationDecl *D); |
82 | void VisitClassScopeFunctionSpecializationDecl( |
83 | ClassScopeFunctionSpecializationDecl *D); |
84 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
85 | void VisitValueDecl(ValueDecl *D); |
86 | void VisitEnumConstantDecl(EnumConstantDecl *D); |
87 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
88 | void VisitDeclaratorDecl(DeclaratorDecl *D); |
89 | void VisitFunctionDecl(FunctionDecl *D); |
90 | void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D); |
91 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
92 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
93 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
94 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
95 | void VisitFieldDecl(FieldDecl *D); |
96 | void VisitMSPropertyDecl(MSPropertyDecl *D); |
97 | void VisitIndirectFieldDecl(IndirectFieldDecl *D); |
98 | void VisitVarDecl(VarDecl *D); |
99 | void VisitImplicitParamDecl(ImplicitParamDecl *D); |
100 | void VisitParmVarDecl(ParmVarDecl *D); |
101 | void VisitDecompositionDecl(DecompositionDecl *D); |
102 | void VisitBindingDecl(BindingDecl *D); |
103 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
104 | void VisitTemplateDecl(TemplateDecl *D); |
105 | void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); |
106 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
107 | void VisitVarTemplateDecl(VarTemplateDecl *D); |
108 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
109 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
110 | void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D); |
111 | void VisitUsingDecl(UsingDecl *D); |
112 | void VisitUsingPackDecl(UsingPackDecl *D); |
113 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
114 | void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D); |
115 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
116 | void VisitExportDecl(ExportDecl *D); |
117 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *D); |
118 | void VisitImportDecl(ImportDecl *D); |
119 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
120 | void VisitFriendDecl(FriendDecl *D); |
121 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
122 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
123 | void VisitBlockDecl(BlockDecl *D); |
124 | void VisitCapturedDecl(CapturedDecl *D); |
125 | void VisitEmptyDecl(EmptyDecl *D); |
126 | |
127 | void VisitDeclContext(DeclContext *DC); |
128 | template <typename T> void VisitRedeclarable(Redeclarable<T> *D); |
129 | |
130 | |
131 | |
132 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
133 | void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D); |
134 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
135 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
136 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
137 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
138 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
139 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
140 | void VisitObjCImplDecl(ObjCImplDecl *D); |
141 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
142 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
143 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
144 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
145 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
146 | void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); |
147 | void VisitOMPAllocateDecl(OMPAllocateDecl *D); |
148 | void VisitOMPRequiresDecl(OMPRequiresDecl *D); |
149 | void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); |
150 | void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D); |
151 | void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); |
152 | |
153 | |
154 | void AddObjCTypeParamList(ObjCTypeParamList *typeParams) { |
155 | |
156 | if (!typeParams) { |
157 | Record.push_back(0); |
158 | return; |
159 | } |
160 | |
161 | Record.push_back(typeParams->size()); |
162 | for (auto typeParam : *typeParams) { |
163 | Record.AddDeclRef(typeParam); |
164 | } |
165 | Record.AddSourceLocation(typeParams->getLAngleLoc()); |
166 | Record.AddSourceLocation(typeParams->getRAngleLoc()); |
167 | } |
168 | |
169 | |
170 | |
171 | |
172 | void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) { |
173 | llvm::MapVector<ModuleFile*, const Decl*> Firsts; |
174 | |
175 | for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) { |
176 | if (R->isFromASTFile()) |
177 | Firsts[Writer.Chain->getOwningModuleFile(R)] = R; |
178 | else if (IncludeLocal) |
179 | Firsts[nullptr] = R; |
180 | } |
181 | for (const auto &F : Firsts) |
182 | Record.AddDeclRef(F.second); |
183 | } |
184 | |
185 | |
186 | template <typename EntryType> |
187 | typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType * |
188 | getSpecializationDecl(EntryType &T) { |
189 | return RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::getDecl(&T); |
190 | } |
191 | |
192 | |
193 | template<typename T> |
194 | decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) { |
195 | return Common->PartialSpecializations; |
196 | } |
197 | ArrayRef<Decl> getPartialSpecializations(FunctionTemplateDecl::Common *) { |
198 | return None; |
199 | } |
200 | |
201 | template<typename DeclTy> |
202 | void AddTemplateSpecializations(DeclTy *D) { |
203 | auto *Common = D->getCommonPtr(); |
204 | |
205 | |
206 | |
207 | |
208 | if (Writer.Chain != Writer.Context->getExternalSource() && |
209 | Common->LazySpecializations) { |
210 | D->LoadLazySpecializations(); |
211 | LazySpecializations", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 211, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Common->LazySpecializations); |
212 | } |
213 | |
214 | ArrayRef<DeclID> LazySpecializations; |
215 | if (auto *LS = Common->LazySpecializations) |
216 | LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]); |
217 | |
218 | |
219 | unsigned I = Record.size(); |
220 | Record.push_back(0); |
221 | |
222 | |
223 | |
224 | llvm::SmallVector<const Decl*, 16> Specs; |
225 | for (auto &Entry : Common->Specializations) |
226 | Specs.push_back(getSpecializationDecl(Entry)); |
227 | for (auto &Entry : getPartialSpecializations(Common)) |
228 | Specs.push_back(getSpecializationDecl(Entry)); |
229 | |
230 | for (auto *D : Specs) { |
231 | (0) . __assert_fail ("D->isCanonicalDecl() && \"non-canonical decl in set\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 231, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(D->isCanonicalDecl() && "non-canonical decl in set"); |
232 | AddFirstDeclFromEachModule(D, ); |
233 | } |
234 | Record.append(LazySpecializations.begin(), LazySpecializations.end()); |
235 | |
236 | |
237 | Record[I] = Record.size() - I - 1; |
238 | } |
239 | |
240 | |
241 | |
242 | void RegisterTemplateSpecialization(const Decl *Template, |
243 | const Decl *Specialization) { |
244 | Template = Template->getCanonicalDecl(); |
245 | |
246 | |
247 | |
248 | |
249 | |
250 | if (!Template->isFromASTFile()) |
251 | return; |
252 | |
253 | |
254 | |
255 | if (Writer.getFirstLocalDecl(Specialization) != Specialization) |
256 | return; |
257 | |
258 | Writer.DeclUpdates[Template].push_back(ASTWriter::DeclUpdate( |
259 | UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, Specialization)); |
260 | } |
261 | }; |
262 | } |
263 | |
264 | void ASTDeclWriter::Visit(Decl *D) { |
265 | DeclVisitor<ASTDeclWriter>::Visit(D); |
266 | |
267 | |
268 | |
269 | |
270 | if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { |
271 | if (auto *TInfo = DD->getTypeSourceInfo()) |
272 | Record.AddTypeLoc(TInfo->getTypeLoc()); |
273 | } |
274 | |
275 | |
276 | |
277 | |
278 | if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
279 | Record.push_back(FD->doesThisDeclarationHaveABody()); |
280 | if (FD->doesThisDeclarationHaveABody()) |
281 | Record.AddFunctionDefinition(FD); |
282 | } |
283 | |
284 | |
285 | |
286 | |
287 | if (DeclContext *DC = dyn_cast<DeclContext>(D)) |
288 | VisitDeclContext(DC); |
289 | } |
290 | |
291 | void ASTDeclWriter::VisitDecl(Decl *D) { |
292 | Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext())); |
293 | if (D->getDeclContext() != D->getLexicalDeclContext()) |
294 | Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext())); |
295 | else |
296 | Record.push_back(0); |
297 | Record.push_back(D->isInvalidDecl()); |
298 | Record.push_back(D->hasAttrs()); |
299 | if (D->hasAttrs()) |
300 | Record.AddAttributes(D->getAttrs()); |
301 | Record.push_back(D->isImplicit()); |
302 | Record.push_back(D->isUsed(false)); |
303 | Record.push_back(D->isReferenced()); |
304 | Record.push_back(D->isTopLevelDeclInObjCContainer()); |
305 | Record.push_back(D->getAccess()); |
306 | Record.push_back(D->isModulePrivate()); |
307 | Record.push_back(Writer.getSubmoduleID(D->getOwningModule())); |
308 | |
309 | |
310 | |
311 | |
312 | |
313 | |
314 | |
315 | |
316 | |
317 | if (D->isOutOfLine()) { |
318 | auto *DC = D->getDeclContext(); |
319 | while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) { |
320 | if (!NS->isFromASTFile()) |
321 | break; |
322 | Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext()); |
323 | if (!NS->isInlineNamespace()) |
324 | break; |
325 | DC = NS->getParent(); |
326 | } |
327 | } |
328 | } |
329 | |
330 | void ASTDeclWriter::(PragmaCommentDecl *D) { |
331 | StringRef Arg = D->getArg(); |
332 | Record.push_back(Arg.size()); |
333 | VisitDecl(D); |
334 | Record.AddSourceLocation(D->getBeginLoc()); |
335 | Record.push_back(D->getCommentKind()); |
336 | Record.AddString(Arg); |
337 | Code = serialization::DECL_PRAGMA_COMMENT; |
338 | } |
339 | |
340 | void ASTDeclWriter::VisitPragmaDetectMismatchDecl( |
341 | PragmaDetectMismatchDecl *D) { |
342 | StringRef Name = D->getName(); |
343 | StringRef Value = D->getValue(); |
344 | Record.push_back(Name.size() + 1 + Value.size()); |
345 | VisitDecl(D); |
346 | Record.AddSourceLocation(D->getBeginLoc()); |
347 | Record.AddString(Name); |
348 | Record.AddString(Value); |
349 | Code = serialization::DECL_PRAGMA_DETECT_MISMATCH; |
350 | } |
351 | |
352 | void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { |
353 | llvm_unreachable("Translation units aren't directly serialized"); |
354 | } |
355 | |
356 | void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) { |
357 | VisitDecl(D); |
358 | Record.AddDeclarationName(D->getDeclName()); |
359 | Record.push_back(needsAnonymousDeclarationNumber(D) |
360 | ? Writer.getAnonymousDeclarationNumber(D) |
361 | : 0); |
362 | } |
363 | |
364 | void ASTDeclWriter::VisitTypeDecl(TypeDecl *D) { |
365 | VisitNamedDecl(D); |
366 | Record.AddSourceLocation(D->getBeginLoc()); |
367 | Record.AddTypeRef(QualType(D->getTypeForDecl(), 0)); |
368 | } |
369 | |
370 | void ASTDeclWriter::VisitTypedefNameDecl(TypedefNameDecl *D) { |
371 | VisitRedeclarable(D); |
372 | VisitTypeDecl(D); |
373 | Record.AddTypeSourceInfo(D->getTypeSourceInfo()); |
374 | Record.push_back(D->isModed()); |
375 | if (D->isModed()) |
376 | Record.AddTypeRef(D->getUnderlyingType()); |
377 | Record.AddDeclRef(D->getAnonDeclWithTypedefName(false)); |
378 | } |
379 | |
380 | void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) { |
381 | VisitTypedefNameDecl(D); |
382 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
383 | !D->hasAttrs() && |
384 | !D->isImplicit() && |
385 | D->getFirstDecl() == D->getMostRecentDecl() && |
386 | !D->isInvalidDecl() && |
387 | !D->isTopLevelDeclInObjCContainer() && |
388 | !D->isModulePrivate() && |
389 | !needsAnonymousDeclarationNumber(D) && |
390 | D->getDeclName().getNameKind() == DeclarationName::Identifier) |
391 | AbbrevToUse = Writer.getDeclTypedefAbbrev(); |
392 | |
393 | Code = serialization::DECL_TYPEDEF; |
394 | } |
395 | |
396 | void ASTDeclWriter::VisitTypeAliasDecl(TypeAliasDecl *D) { |
397 | VisitTypedefNameDecl(D); |
398 | Record.AddDeclRef(D->getDescribedAliasTemplate()); |
399 | Code = serialization::DECL_TYPEALIAS; |
400 | } |
401 | |
402 | void ASTDeclWriter::VisitTagDecl(TagDecl *D) { |
403 | VisitRedeclarable(D); |
404 | VisitTypeDecl(D); |
405 | Record.push_back(D->getIdentifierNamespace()); |
406 | Record.push_back((unsigned)D->getTagKind()); |
407 | if (!isa<CXXRecordDecl>(D)) |
408 | Record.push_back(D->isCompleteDefinition()); |
409 | Record.push_back(D->isEmbeddedInDeclarator()); |
410 | Record.push_back(D->isFreeStanding()); |
411 | Record.push_back(D->isCompleteDefinitionRequired()); |
412 | Record.AddSourceRange(D->getBraceRange()); |
413 | |
414 | if (D->hasExtInfo()) { |
415 | Record.push_back(1); |
416 | Record.AddQualifierInfo(*D->getExtInfo()); |
417 | } else if (auto *TD = D->getTypedefNameForAnonDecl()) { |
418 | Record.push_back(2); |
419 | Record.AddDeclRef(TD); |
420 | Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo()); |
421 | } else { |
422 | Record.push_back(0); |
423 | } |
424 | } |
425 | |
426 | void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) { |
427 | VisitTagDecl(D); |
428 | Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo()); |
429 | if (!D->getIntegerTypeSourceInfo()) |
430 | Record.AddTypeRef(D->getIntegerType()); |
431 | Record.AddTypeRef(D->getPromotionType()); |
432 | Record.push_back(D->getNumPositiveBits()); |
433 | Record.push_back(D->getNumNegativeBits()); |
434 | Record.push_back(D->isScoped()); |
435 | Record.push_back(D->isScopedUsingClassTag()); |
436 | Record.push_back(D->isFixed()); |
437 | Record.push_back(D->getODRHash()); |
438 | |
439 | if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) { |
440 | Record.AddDeclRef(MemberInfo->getInstantiatedFrom()); |
441 | Record.push_back(MemberInfo->getTemplateSpecializationKind()); |
442 | Record.AddSourceLocation(MemberInfo->getPointOfInstantiation()); |
443 | } else { |
444 | Record.AddDeclRef(nullptr); |
445 | } |
446 | |
447 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
448 | !D->hasAttrs() && |
449 | !D->isImplicit() && |
450 | !D->isUsed(false) && |
451 | !D->hasExtInfo() && |
452 | !D->getTypedefNameForAnonDecl() && |
453 | D->getFirstDecl() == D->getMostRecentDecl() && |
454 | !D->isInvalidDecl() && |
455 | !D->isReferenced() && |
456 | !D->isTopLevelDeclInObjCContainer() && |
457 | D->getAccess() == AS_none && |
458 | !D->isModulePrivate() && |
459 | !CXXRecordDecl::classofKind(D->getKind()) && |
460 | !D->getIntegerTypeSourceInfo() && |
461 | !D->getMemberSpecializationInfo() && |
462 | !needsAnonymousDeclarationNumber(D) && |
463 | D->getDeclName().getNameKind() == DeclarationName::Identifier) |
464 | AbbrevToUse = Writer.getDeclEnumAbbrev(); |
465 | |
466 | Code = serialization::DECL_ENUM; |
467 | } |
468 | |
469 | void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) { |
470 | VisitTagDecl(D); |
471 | Record.push_back(D->hasFlexibleArrayMember()); |
472 | Record.push_back(D->isAnonymousStructOrUnion()); |
473 | Record.push_back(D->hasObjectMember()); |
474 | Record.push_back(D->hasVolatileMember()); |
475 | Record.push_back(D->isNonTrivialToPrimitiveDefaultInitialize()); |
476 | Record.push_back(D->isNonTrivialToPrimitiveCopy()); |
477 | Record.push_back(D->isNonTrivialToPrimitiveDestroy()); |
478 | Record.push_back(D->isParamDestroyedInCallee()); |
479 | Record.push_back(D->getArgPassingRestrictions()); |
480 | |
481 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
482 | !D->hasAttrs() && |
483 | !D->isImplicit() && |
484 | !D->isUsed(false) && |
485 | !D->hasExtInfo() && |
486 | !D->getTypedefNameForAnonDecl() && |
487 | D->getFirstDecl() == D->getMostRecentDecl() && |
488 | !D->isInvalidDecl() && |
489 | !D->isReferenced() && |
490 | !D->isTopLevelDeclInObjCContainer() && |
491 | D->getAccess() == AS_none && |
492 | !D->isModulePrivate() && |
493 | !CXXRecordDecl::classofKind(D->getKind()) && |
494 | !needsAnonymousDeclarationNumber(D) && |
495 | D->getDeclName().getNameKind() == DeclarationName::Identifier) |
496 | AbbrevToUse = Writer.getDeclRecordAbbrev(); |
497 | |
498 | Code = serialization::DECL_RECORD; |
499 | } |
500 | |
501 | void ASTDeclWriter::VisitValueDecl(ValueDecl *D) { |
502 | VisitNamedDecl(D); |
503 | Record.AddTypeRef(D->getType()); |
504 | } |
505 | |
506 | void ASTDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) { |
507 | VisitValueDecl(D); |
508 | Record.push_back(D->getInitExpr()? 1 : 0); |
509 | if (D->getInitExpr()) |
510 | Record.AddStmt(D->getInitExpr()); |
511 | Record.AddAPSInt(D->getInitVal()); |
512 | |
513 | Code = serialization::DECL_ENUM_CONSTANT; |
514 | } |
515 | |
516 | void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) { |
517 | VisitValueDecl(D); |
518 | Record.AddSourceLocation(D->getInnerLocStart()); |
519 | Record.push_back(D->hasExtInfo()); |
520 | if (D->hasExtInfo()) |
521 | Record.AddQualifierInfo(*D->getExtInfo()); |
522 | |
523 | Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType() |
524 | : QualType()); |
525 | } |
526 | |
527 | void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { |
528 | VisitRedeclarable(D); |
529 | VisitDeclaratorDecl(D); |
530 | Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName()); |
531 | Record.push_back(D->getIdentifierNamespace()); |
532 | |
533 | |
534 | |
535 | Record.push_back(static_cast<int>(D->getStorageClass())); |
536 | Record.push_back(D->isInlineSpecified()); |
537 | Record.push_back(D->isInlined()); |
538 | Record.push_back(D->isExplicitSpecified()); |
539 | Record.push_back(D->isVirtualAsWritten()); |
540 | Record.push_back(D->isPure()); |
541 | Record.push_back(D->hasInheritedPrototype()); |
542 | Record.push_back(D->hasWrittenPrototype()); |
543 | Record.push_back(D->isDeletedBit()); |
544 | Record.push_back(D->isTrivial()); |
545 | Record.push_back(D->isTrivialForCall()); |
546 | Record.push_back(D->isDefaulted()); |
547 | Record.push_back(D->isExplicitlyDefaulted()); |
548 | Record.push_back(D->hasImplicitReturnZero()); |
549 | Record.push_back(D->isConstexpr()); |
550 | Record.push_back(D->usesSEHTry()); |
551 | Record.push_back(D->hasSkippedBody()); |
552 | Record.push_back(D->isMultiVersion()); |
553 | Record.push_back(D->isLateTemplateParsed()); |
554 | Record.push_back(D->getLinkageInternal()); |
555 | Record.AddSourceLocation(D->getEndLoc()); |
556 | |
557 | Record.push_back(D->getODRHash()); |
558 | |
559 | Record.push_back(D->getTemplatedKind()); |
560 | switch (D->getTemplatedKind()) { |
561 | case FunctionDecl::TK_NonTemplate: |
562 | break; |
563 | case FunctionDecl::TK_FunctionTemplate: |
564 | Record.AddDeclRef(D->getDescribedFunctionTemplate()); |
565 | break; |
566 | case FunctionDecl::TK_MemberSpecialization: { |
567 | MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo(); |
568 | Record.AddDeclRef(MemberInfo->getInstantiatedFrom()); |
569 | Record.push_back(MemberInfo->getTemplateSpecializationKind()); |
570 | Record.AddSourceLocation(MemberInfo->getPointOfInstantiation()); |
571 | break; |
572 | } |
573 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
574 | FunctionTemplateSpecializationInfo * |
575 | FTSInfo = D->getTemplateSpecializationInfo(); |
576 | |
577 | RegisterTemplateSpecialization(FTSInfo->getTemplate(), D); |
578 | |
579 | Record.AddDeclRef(FTSInfo->getTemplate()); |
580 | Record.push_back(FTSInfo->getTemplateSpecializationKind()); |
581 | |
582 | |
583 | Record.AddTemplateArgumentList(FTSInfo->TemplateArguments); |
584 | |
585 | |
586 | Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr); |
587 | if (FTSInfo->TemplateArgumentsAsWritten) { |
588 | Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs); |
589 | for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs; |
590 | i!=e; ++i) |
591 | Record.AddTemplateArgumentLoc( |
592 | (*FTSInfo->TemplateArgumentsAsWritten)[i]); |
593 | Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc); |
594 | Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc); |
595 | } |
596 | |
597 | Record.AddSourceLocation(FTSInfo->getPointOfInstantiation()); |
598 | |
599 | if (D->isCanonicalDecl()) { |
600 | |
601 | |
602 | Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl()); |
603 | } |
604 | break; |
605 | } |
606 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
607 | DependentFunctionTemplateSpecializationInfo * |
608 | DFTSInfo = D->getDependentSpecializationInfo(); |
609 | |
610 | |
611 | Record.push_back(DFTSInfo->getNumTemplates()); |
612 | for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i) |
613 | Record.AddDeclRef(DFTSInfo->getTemplate(i)); |
614 | |
615 | |
616 | Record.push_back(DFTSInfo->getNumTemplateArgs()); |
617 | for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i) |
618 | Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i)); |
619 | Record.AddSourceLocation(DFTSInfo->getLAngleLoc()); |
620 | Record.AddSourceLocation(DFTSInfo->getRAngleLoc()); |
621 | break; |
622 | } |
623 | } |
624 | |
625 | Record.push_back(D->param_size()); |
626 | for (auto P : D->parameters()) |
627 | Record.AddDeclRef(P); |
628 | Code = serialization::DECL_FUNCTION; |
629 | } |
630 | |
631 | void ASTDeclWriter::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) { |
632 | VisitFunctionDecl(D); |
633 | Record.push_back(D->isCopyDeductionCandidate()); |
634 | Code = serialization::DECL_CXX_DEDUCTION_GUIDE; |
635 | } |
636 | |
637 | void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { |
638 | VisitNamedDecl(D); |
639 | |
640 | |
641 | bool HasBodyStuff = D->getBody() != nullptr || |
642 | D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr; |
643 | Record.push_back(HasBodyStuff); |
644 | if (HasBodyStuff) { |
645 | Record.AddStmt(D->getBody()); |
646 | Record.AddDeclRef(D->getSelfDecl()); |
647 | Record.AddDeclRef(D->getCmdDecl()); |
648 | } |
649 | Record.push_back(D->isInstanceMethod()); |
650 | Record.push_back(D->isVariadic()); |
651 | Record.push_back(D->isPropertyAccessor()); |
652 | Record.push_back(D->isDefined()); |
653 | Record.push_back(D->isOverriding()); |
654 | Record.push_back(D->hasSkippedBody()); |
655 | |
656 | Record.push_back(D->isRedeclaration()); |
657 | Record.push_back(D->hasRedeclaration()); |
658 | if (D->hasRedeclaration()) { |
659 | assert(Context.getObjCMethodRedeclaration(D)); |
660 | Record.AddDeclRef(Context.getObjCMethodRedeclaration(D)); |
661 | } |
662 | |
663 | |
664 | Record.push_back(D->getImplementationControl()); |
665 | |
666 | Record.push_back(D->getObjCDeclQualifier()); |
667 | Record.push_back(D->hasRelatedResultType()); |
668 | Record.AddTypeRef(D->getReturnType()); |
669 | Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo()); |
670 | Record.AddSourceLocation(D->getEndLoc()); |
671 | Record.push_back(D->param_size()); |
672 | for (const auto *P : D->parameters()) |
673 | Record.AddDeclRef(P); |
674 | |
675 | Record.push_back(D->getSelLocsKind()); |
676 | unsigned NumStoredSelLocs = D->getNumStoredSelLocs(); |
677 | SourceLocation *SelLocs = D->getStoredSelLocs(); |
678 | Record.push_back(NumStoredSelLocs); |
679 | for (unsigned i = 0; i != NumStoredSelLocs; ++i) |
680 | Record.AddSourceLocation(SelLocs[i]); |
681 | |
682 | Code = serialization::DECL_OBJC_METHOD; |
683 | } |
684 | |
685 | void ASTDeclWriter::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) { |
686 | VisitTypedefNameDecl(D); |
687 | Record.push_back(D->Variance); |
688 | Record.push_back(D->Index); |
689 | Record.AddSourceLocation(D->VarianceLoc); |
690 | Record.AddSourceLocation(D->ColonLoc); |
691 | |
692 | Code = serialization::DECL_OBJC_TYPE_PARAM; |
693 | } |
694 | |
695 | void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) { |
696 | VisitNamedDecl(D); |
697 | Record.AddSourceLocation(D->getAtStartLoc()); |
698 | Record.AddSourceRange(D->getAtEndRange()); |
699 | |
700 | } |
701 | |
702 | void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { |
703 | VisitRedeclarable(D); |
704 | VisitObjCContainerDecl(D); |
705 | Record.AddTypeRef(QualType(D->getTypeForDecl(), 0)); |
706 | AddObjCTypeParamList(D->TypeParamList); |
707 | |
708 | Record.push_back(D->isThisDeclarationADefinition()); |
709 | if (D->isThisDeclarationADefinition()) { |
710 | |
711 | ObjCInterfaceDecl::DefinitionData &Data = D->data(); |
712 | |
713 | Record.AddTypeSourceInfo(D->getSuperClassTInfo()); |
714 | Record.AddSourceLocation(D->getEndOfDefinitionLoc()); |
715 | Record.push_back(Data.HasDesignatedInitializers); |
716 | |
717 | |
718 | Record.push_back(Data.ReferencedProtocols.size()); |
719 | for (const auto *P : D->protocols()) |
720 | Record.AddDeclRef(P); |
721 | for (const auto &PL : D->protocol_locs()) |
722 | Record.AddSourceLocation(PL); |
723 | |
724 | |
725 | Record.push_back(Data.AllReferencedProtocols.size()); |
726 | for (ObjCList<ObjCProtocolDecl>::iterator |
727 | P = Data.AllReferencedProtocols.begin(), |
728 | PEnd = Data.AllReferencedProtocols.end(); |
729 | P != PEnd; ++P) |
730 | Record.AddDeclRef(*P); |
731 | |
732 | |
733 | if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) { |
734 | |
735 | Writer.ObjCClassesWithCategories.insert(D); |
736 | |
737 | |
738 | for (; Cat; Cat = Cat->getNextClassCategoryRaw()) |
739 | (void)Writer.GetDeclRef(Cat); |
740 | } |
741 | } |
742 | |
743 | Code = serialization::DECL_OBJC_INTERFACE; |
744 | } |
745 | |
746 | void ASTDeclWriter::VisitObjCIvarDecl(ObjCIvarDecl *D) { |
747 | VisitFieldDecl(D); |
748 | |
749 | Record.push_back(D->getAccessControl()); |
750 | Record.push_back(D->getSynthesize()); |
751 | |
752 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
753 | !D->hasAttrs() && |
754 | !D->isImplicit() && |
755 | !D->isUsed(false) && |
756 | !D->isInvalidDecl() && |
757 | !D->isReferenced() && |
758 | !D->isModulePrivate() && |
759 | !D->getBitWidth() && |
760 | !D->hasExtInfo() && |
761 | D->getDeclName()) |
762 | AbbrevToUse = Writer.getDeclObjCIvarAbbrev(); |
763 | |
764 | Code = serialization::DECL_OBJC_IVAR; |
765 | } |
766 | |
767 | void ASTDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { |
768 | VisitRedeclarable(D); |
769 | VisitObjCContainerDecl(D); |
770 | |
771 | Record.push_back(D->isThisDeclarationADefinition()); |
772 | if (D->isThisDeclarationADefinition()) { |
773 | Record.push_back(D->protocol_size()); |
774 | for (const auto *I : D->protocols()) |
775 | Record.AddDeclRef(I); |
776 | for (const auto &PL : D->protocol_locs()) |
777 | Record.AddSourceLocation(PL); |
778 | } |
779 | |
780 | Code = serialization::DECL_OBJC_PROTOCOL; |
781 | } |
782 | |
783 | void ASTDeclWriter::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) { |
784 | VisitFieldDecl(D); |
785 | Code = serialization::DECL_OBJC_AT_DEFS_FIELD; |
786 | } |
787 | |
788 | void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { |
789 | VisitObjCContainerDecl(D); |
790 | Record.AddSourceLocation(D->getCategoryNameLoc()); |
791 | Record.AddSourceLocation(D->getIvarLBraceLoc()); |
792 | Record.AddSourceLocation(D->getIvarRBraceLoc()); |
793 | Record.AddDeclRef(D->getClassInterface()); |
794 | AddObjCTypeParamList(D->TypeParamList); |
795 | Record.push_back(D->protocol_size()); |
796 | for (const auto *I : D->protocols()) |
797 | Record.AddDeclRef(I); |
798 | for (const auto &PL : D->protocol_locs()) |
799 | Record.AddSourceLocation(PL); |
800 | Code = serialization::DECL_OBJC_CATEGORY; |
801 | } |
802 | |
803 | void ASTDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) { |
804 | VisitNamedDecl(D); |
805 | Record.AddDeclRef(D->getClassInterface()); |
806 | Code = serialization::DECL_OBJC_COMPATIBLE_ALIAS; |
807 | } |
808 | |
809 | void ASTDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
810 | VisitNamedDecl(D); |
811 | Record.AddSourceLocation(D->getAtLoc()); |
812 | Record.AddSourceLocation(D->getLParenLoc()); |
813 | Record.AddTypeRef(D->getType()); |
814 | Record.AddTypeSourceInfo(D->getTypeSourceInfo()); |
815 | |
816 | Record.push_back((unsigned)D->getPropertyAttributes()); |
817 | Record.push_back((unsigned)D->getPropertyAttributesAsWritten()); |
818 | |
819 | Record.push_back((unsigned)D->getPropertyImplementation()); |
820 | Record.AddDeclarationName(D->getGetterName()); |
821 | Record.AddSourceLocation(D->getGetterNameLoc()); |
822 | Record.AddDeclarationName(D->getSetterName()); |
823 | Record.AddSourceLocation(D->getSetterNameLoc()); |
824 | Record.AddDeclRef(D->getGetterMethodDecl()); |
825 | Record.AddDeclRef(D->getSetterMethodDecl()); |
826 | Record.AddDeclRef(D->getPropertyIvarDecl()); |
827 | Code = serialization::DECL_OBJC_PROPERTY; |
828 | } |
829 | |
830 | void ASTDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) { |
831 | VisitObjCContainerDecl(D); |
832 | Record.AddDeclRef(D->getClassInterface()); |
833 | |
834 | } |
835 | |
836 | void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
837 | VisitObjCImplDecl(D); |
838 | Record.AddSourceLocation(D->getCategoryNameLoc()); |
839 | Code = serialization::DECL_OBJC_CATEGORY_IMPL; |
840 | } |
841 | |
842 | void ASTDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
843 | VisitObjCImplDecl(D); |
844 | Record.AddDeclRef(D->getSuperClass()); |
845 | Record.AddSourceLocation(D->getSuperClassLoc()); |
846 | Record.AddSourceLocation(D->getIvarLBraceLoc()); |
847 | Record.AddSourceLocation(D->getIvarRBraceLoc()); |
848 | Record.push_back(D->hasNonZeroConstructors()); |
849 | Record.push_back(D->hasDestructors()); |
850 | Record.push_back(D->NumIvarInitializers); |
851 | if (D->NumIvarInitializers) |
852 | Record.AddCXXCtorInitializers( |
853 | llvm::makeArrayRef(D->init_begin(), D->init_end())); |
854 | Code = serialization::DECL_OBJC_IMPLEMENTATION; |
855 | } |
856 | |
857 | void ASTDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
858 | VisitDecl(D); |
859 | Record.AddSourceLocation(D->getBeginLoc()); |
860 | Record.AddDeclRef(D->getPropertyDecl()); |
861 | Record.AddDeclRef(D->getPropertyIvarDecl()); |
862 | Record.AddSourceLocation(D->getPropertyIvarDeclLoc()); |
863 | Record.AddStmt(D->getGetterCXXConstructor()); |
864 | Record.AddStmt(D->getSetterCXXAssignment()); |
865 | Code = serialization::DECL_OBJC_PROPERTY_IMPL; |
866 | } |
867 | |
868 | void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) { |
869 | VisitDeclaratorDecl(D); |
870 | Record.push_back(D->isMutable()); |
871 | |
872 | FieldDecl::InitStorageKind ISK = D->InitStorage.getInt(); |
873 | Record.push_back(ISK); |
874 | if (ISK == FieldDecl::ISK_CapturedVLAType) |
875 | Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0)); |
876 | else if (ISK) |
877 | Record.AddStmt(D->getInClassInitializer()); |
878 | |
879 | Record.AddStmt(D->getBitWidth()); |
880 | |
881 | if (!D->getDeclName()) |
882 | Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D)); |
883 | |
884 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
885 | !D->hasAttrs() && |
886 | !D->isImplicit() && |
887 | !D->isUsed(false) && |
888 | !D->isInvalidDecl() && |
889 | !D->isReferenced() && |
890 | !D->isTopLevelDeclInObjCContainer() && |
891 | !D->isModulePrivate() && |
892 | !D->getBitWidth() && |
893 | !D->hasInClassInitializer() && |
894 | !D->hasCapturedVLAType() && |
895 | !D->hasExtInfo() && |
896 | !ObjCIvarDecl::classofKind(D->getKind()) && |
897 | !ObjCAtDefsFieldDecl::classofKind(D->getKind()) && |
898 | D->getDeclName()) |
899 | AbbrevToUse = Writer.getDeclFieldAbbrev(); |
900 | |
901 | Code = serialization::DECL_FIELD; |
902 | } |
903 | |
904 | void ASTDeclWriter::VisitMSPropertyDecl(MSPropertyDecl *D) { |
905 | VisitDeclaratorDecl(D); |
906 | Record.AddIdentifierRef(D->getGetterId()); |
907 | Record.AddIdentifierRef(D->getSetterId()); |
908 | Code = serialization::DECL_MS_PROPERTY; |
909 | } |
910 | |
911 | void ASTDeclWriter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { |
912 | VisitValueDecl(D); |
913 | Record.push_back(D->getChainingSize()); |
914 | |
915 | for (const auto *P : D->chain()) |
916 | Record.AddDeclRef(P); |
917 | Code = serialization::DECL_INDIRECTFIELD; |
918 | } |
919 | |
920 | void ASTDeclWriter::VisitVarDecl(VarDecl *D) { |
921 | VisitRedeclarable(D); |
922 | VisitDeclaratorDecl(D); |
923 | Record.push_back(D->getStorageClass()); |
924 | Record.push_back(D->getTSCSpec()); |
925 | Record.push_back(D->getInitStyle()); |
926 | Record.push_back(D->isARCPseudoStrong()); |
927 | if (!isa<ParmVarDecl>(D)) { |
928 | Record.push_back(D->isThisDeclarationADemotedDefinition()); |
929 | Record.push_back(D->isExceptionVariable()); |
930 | Record.push_back(D->isNRVOVariable()); |
931 | Record.push_back(D->isCXXForRangeDecl()); |
932 | Record.push_back(D->isObjCForDecl()); |
933 | Record.push_back(D->isInline()); |
934 | Record.push_back(D->isInlineSpecified()); |
935 | Record.push_back(D->isConstexpr()); |
936 | Record.push_back(D->isInitCapture()); |
937 | Record.push_back(D->isPreviousDeclInSameBlockScope()); |
938 | if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D)) |
939 | Record.push_back(static_cast<unsigned>(IPD->getParameterKind())); |
940 | else |
941 | Record.push_back(0); |
942 | Record.push_back(D->isEscapingByref()); |
943 | } |
944 | Record.push_back(D->getLinkageInternal()); |
945 | |
946 | if (D->getInit()) { |
947 | Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2)); |
948 | Record.AddStmt(D->getInit()); |
949 | } else { |
950 | Record.push_back(0); |
951 | } |
952 | |
953 | if (D->hasAttr<BlocksAttr>() && D->getType()->getAsCXXRecordDecl()) { |
954 | ASTContext::BlockVarCopyInit Init = Writer.Context->getBlockVarCopyInit(D); |
955 | Record.AddStmt(Init.getCopyExpr()); |
956 | if (Init.getCopyExpr()) |
957 | Record.push_back(Init.canThrow()); |
958 | } |
959 | |
960 | if (D->getStorageDuration() == SD_Static) { |
961 | bool ModulesCodegen = false; |
962 | if (Writer.WritingModule && |
963 | !D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() && |
964 | !isa<VarTemplateSpecializationDecl>(D)) { |
965 | |
966 | |
967 | |
968 | |
969 | ModulesCodegen = |
970 | (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit && |
971 | Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal); |
972 | } |
973 | Record.push_back(ModulesCodegen); |
974 | if (ModulesCodegen) |
975 | Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D)); |
976 | } |
977 | |
978 | enum { |
979 | VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization |
980 | }; |
981 | if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) { |
982 | Record.push_back(VarTemplate); |
983 | Record.AddDeclRef(TemplD); |
984 | } else if (MemberSpecializationInfo *SpecInfo |
985 | = D->getMemberSpecializationInfo()) { |
986 | Record.push_back(StaticDataMemberSpecialization); |
987 | Record.AddDeclRef(SpecInfo->getInstantiatedFrom()); |
988 | Record.push_back(SpecInfo->getTemplateSpecializationKind()); |
989 | Record.AddSourceLocation(SpecInfo->getPointOfInstantiation()); |
990 | } else { |
991 | Record.push_back(VarNotTemplate); |
992 | } |
993 | |
994 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
995 | !D->hasAttrs() && |
996 | !D->isImplicit() && |
997 | !D->isUsed(false) && |
998 | !D->isInvalidDecl() && |
999 | !D->isReferenced() && |
1000 | !D->isTopLevelDeclInObjCContainer() && |
1001 | D->getAccess() == AS_none && |
1002 | !D->isModulePrivate() && |
1003 | !needsAnonymousDeclarationNumber(D) && |
1004 | D->getDeclName().getNameKind() == DeclarationName::Identifier && |
1005 | !D->hasExtInfo() && |
1006 | D->getFirstDecl() == D->getMostRecentDecl() && |
1007 | D->getKind() == Decl::Var && |
1008 | !D->isInline() && |
1009 | !D->isConstexpr() && |
1010 | !D->isInitCapture() && |
1011 | !D->isPreviousDeclInSameBlockScope() && |
1012 | !(D->hasAttr<BlocksAttr>() && D->getType()->getAsCXXRecordDecl()) && |
1013 | !D->isEscapingByref() && |
1014 | D->getStorageDuration() != SD_Static && |
1015 | !D->getMemberSpecializationInfo()) |
1016 | AbbrevToUse = Writer.getDeclVarAbbrev(); |
1017 | |
1018 | Code = serialization::DECL_VAR; |
1019 | } |
1020 | |
1021 | void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) { |
1022 | VisitVarDecl(D); |
1023 | Code = serialization::DECL_IMPLICIT_PARAM; |
1024 | } |
1025 | |
1026 | void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) { |
1027 | VisitVarDecl(D); |
1028 | Record.push_back(D->isObjCMethodParameter()); |
1029 | Record.push_back(D->getFunctionScopeDepth()); |
1030 | Record.push_back(D->getFunctionScopeIndex()); |
1031 | Record.push_back(D->getObjCDeclQualifier()); |
1032 | Record.push_back(D->isKNRPromoted()); |
1033 | Record.push_back(D->hasInheritedDefaultArg()); |
1034 | Record.push_back(D->hasUninstantiatedDefaultArg()); |
1035 | if (D->hasUninstantiatedDefaultArg()) |
1036 | Record.AddStmt(D->getUninstantiatedDefaultArg()); |
1037 | Code = serialization::DECL_PARM_VAR; |
1038 | |
1039 | isARCPseudoStrong()", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1039, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->isARCPseudoStrong()); |
1040 | |
1041 | |
1042 | |
1043 | |
1044 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
1045 | !D->hasAttrs() && |
1046 | !D->hasExtInfo() && |
1047 | !D->isImplicit() && |
1048 | !D->isUsed(false) && |
1049 | !D->isInvalidDecl() && |
1050 | !D->isReferenced() && |
1051 | D->getAccess() == AS_none && |
1052 | !D->isModulePrivate() && |
1053 | D->getStorageClass() == 0 && |
1054 | D->getInitStyle() == VarDecl::CInit && |
1055 | D->getFunctionScopeDepth() == 0 && |
1056 | D->getObjCDeclQualifier() == 0 && |
1057 | !D->isKNRPromoted() && |
1058 | !D->hasInheritedDefaultArg() && |
1059 | D->getInit() == nullptr && |
1060 | !D->hasUninstantiatedDefaultArg()) |
1061 | AbbrevToUse = Writer.getDeclParmVarAbbrev(); |
1062 | |
1063 | |
1064 | |
1065 | (0) . __assert_fail ("!D->getTSCSpec() && \"PARM_VAR_DECL can't use TLS\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1065, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS"); |
1066 | (0) . __assert_fail ("!D->isThisDeclarationADemotedDefinition() && \"PARM_VAR_DECL can't be demoted definition.\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1067, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->isThisDeclarationADemotedDefinition() |
1067 | (0) . __assert_fail ("!D->isThisDeclarationADemotedDefinition() && \"PARM_VAR_DECL can't be demoted definition.\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1067, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> && "PARM_VAR_DECL can't be demoted definition."); |
1068 | (0) . __assert_fail ("D->getAccess() == AS_none && \"PARM_VAR_DECL can't be public/private\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1068, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private"); |
1069 | (0) . __assert_fail ("!D->isExceptionVariable() && \"PARM_VAR_DECL can't be exception var\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1069, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var"); |
1070 | (0) . __assert_fail ("D->getPreviousDecl() == nullptr && \"PARM_VAR_DECL can't be redecl\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1070, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl"); |
1071 | (0) . __assert_fail ("!D->isStaticDataMember() && \"PARM_VAR_DECL can't be static data member\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1072, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->isStaticDataMember() && |
1072 | (0) . __assert_fail ("!D->isStaticDataMember() && \"PARM_VAR_DECL can't be static data member\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1072, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "PARM_VAR_DECL can't be static data member"); |
1073 | } |
1074 | |
1075 | void ASTDeclWriter::VisitDecompositionDecl(DecompositionDecl *D) { |
1076 | |
1077 | Record.push_back(D->bindings().size()); |
1078 | |
1079 | VisitVarDecl(D); |
1080 | for (auto *B : D->bindings()) |
1081 | Record.AddDeclRef(B); |
1082 | Code = serialization::DECL_DECOMPOSITION; |
1083 | } |
1084 | |
1085 | void ASTDeclWriter::VisitBindingDecl(BindingDecl *D) { |
1086 | VisitValueDecl(D); |
1087 | Record.AddStmt(D->getBinding()); |
1088 | Code = serialization::DECL_BINDING; |
1089 | } |
1090 | |
1091 | void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) { |
1092 | VisitDecl(D); |
1093 | Record.AddStmt(D->getAsmString()); |
1094 | Record.AddSourceLocation(D->getRParenLoc()); |
1095 | Code = serialization::DECL_FILE_SCOPE_ASM; |
1096 | } |
1097 | |
1098 | void ASTDeclWriter::VisitEmptyDecl(EmptyDecl *D) { |
1099 | VisitDecl(D); |
1100 | Code = serialization::DECL_EMPTY; |
1101 | } |
1102 | |
1103 | void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) { |
1104 | VisitDecl(D); |
1105 | Record.AddStmt(D->getBody()); |
1106 | Record.AddTypeSourceInfo(D->getSignatureAsWritten()); |
1107 | Record.push_back(D->param_size()); |
1108 | for (ParmVarDecl *P : D->parameters()) |
1109 | Record.AddDeclRef(P); |
1110 | Record.push_back(D->isVariadic()); |
1111 | Record.push_back(D->blockMissingReturnType()); |
1112 | Record.push_back(D->isConversionFromLambda()); |
1113 | Record.push_back(D->doesNotEscape()); |
1114 | Record.push_back(D->canAvoidCopyToHeap()); |
1115 | Record.push_back(D->capturesCXXThis()); |
1116 | Record.push_back(D->getNumCaptures()); |
1117 | for (const auto &capture : D->captures()) { |
1118 | Record.AddDeclRef(capture.getVariable()); |
1119 | |
1120 | unsigned flags = 0; |
1121 | if (capture.isByRef()) flags |= 1; |
1122 | if (capture.isNested()) flags |= 2; |
1123 | if (capture.hasCopyExpr()) flags |= 4; |
1124 | Record.push_back(flags); |
1125 | |
1126 | if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr()); |
1127 | } |
1128 | |
1129 | Code = serialization::DECL_BLOCK; |
1130 | } |
1131 | |
1132 | void ASTDeclWriter::VisitCapturedDecl(CapturedDecl *CD) { |
1133 | Record.push_back(CD->getNumParams()); |
1134 | VisitDecl(CD); |
1135 | Record.push_back(CD->getContextParamPosition()); |
1136 | Record.push_back(CD->isNothrow() ? 1 : 0); |
1137 | |
1138 | for (unsigned I = 0; I < CD->getNumParams(); ++I) |
1139 | Record.AddDeclRef(CD->getParam(I)); |
1140 | Code = serialization::DECL_CAPTURED; |
1141 | } |
1142 | |
1143 | void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
1144 | VisitDecl(D); |
1145 | Record.push_back(D->getLanguage()); |
1146 | Record.AddSourceLocation(D->getExternLoc()); |
1147 | Record.AddSourceLocation(D->getRBraceLoc()); |
1148 | Code = serialization::DECL_LINKAGE_SPEC; |
1149 | } |
1150 | |
1151 | void ASTDeclWriter::VisitExportDecl(ExportDecl *D) { |
1152 | VisitDecl(D); |
1153 | Record.AddSourceLocation(D->getRBraceLoc()); |
1154 | Code = serialization::DECL_EXPORT; |
1155 | } |
1156 | |
1157 | void ASTDeclWriter::VisitLabelDecl(LabelDecl *D) { |
1158 | VisitNamedDecl(D); |
1159 | Record.AddSourceLocation(D->getBeginLoc()); |
1160 | Code = serialization::DECL_LABEL; |
1161 | } |
1162 | |
1163 | |
1164 | void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) { |
1165 | VisitRedeclarable(D); |
1166 | VisitNamedDecl(D); |
1167 | Record.push_back(D->isInline()); |
1168 | Record.AddSourceLocation(D->getBeginLoc()); |
1169 | Record.AddSourceLocation(D->getRBraceLoc()); |
1170 | |
1171 | if (D->isOriginalNamespace()) |
1172 | Record.AddDeclRef(D->getAnonymousNamespace()); |
1173 | Code = serialization::DECL_NAMESPACE; |
1174 | |
1175 | if (Writer.hasChain() && D->isAnonymousNamespace() && |
1176 | D == D->getMostRecentDecl()) { |
1177 | |
1178 | |
1179 | |
1180 | |
1181 | Decl *Parent = cast<Decl>( |
1182 | D->getParent()->getRedeclContext()->getPrimaryContext()); |
1183 | if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) { |
1184 | Writer.DeclUpdates[Parent].push_back( |
1185 | ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D)); |
1186 | } |
1187 | } |
1188 | } |
1189 | |
1190 | void ASTDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
1191 | VisitRedeclarable(D); |
1192 | VisitNamedDecl(D); |
1193 | Record.AddSourceLocation(D->getNamespaceLoc()); |
1194 | Record.AddSourceLocation(D->getTargetNameLoc()); |
1195 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
1196 | Record.AddDeclRef(D->getNamespace()); |
1197 | Code = serialization::DECL_NAMESPACE_ALIAS; |
1198 | } |
1199 | |
1200 | void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) { |
1201 | VisitNamedDecl(D); |
1202 | Record.AddSourceLocation(D->getUsingLoc()); |
1203 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
1204 | Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName()); |
1205 | Record.AddDeclRef(D->FirstUsingShadow.getPointer()); |
1206 | Record.push_back(D->hasTypename()); |
1207 | Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D)); |
1208 | Code = serialization::DECL_USING; |
1209 | } |
1210 | |
1211 | void ASTDeclWriter::VisitUsingPackDecl(UsingPackDecl *D) { |
1212 | Record.push_back(D->NumExpansions); |
1213 | VisitNamedDecl(D); |
1214 | Record.AddDeclRef(D->getInstantiatedFromUsingDecl()); |
1215 | for (auto *E : D->expansions()) |
1216 | Record.AddDeclRef(E); |
1217 | Code = serialization::DECL_USING_PACK; |
1218 | } |
1219 | |
1220 | void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) { |
1221 | VisitRedeclarable(D); |
1222 | VisitNamedDecl(D); |
1223 | Record.AddDeclRef(D->getTargetDecl()); |
1224 | Record.push_back(D->getIdentifierNamespace()); |
1225 | Record.AddDeclRef(D->UsingOrNextShadow); |
1226 | Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D)); |
1227 | Code = serialization::DECL_USING_SHADOW; |
1228 | } |
1229 | |
1230 | void ASTDeclWriter::VisitConstructorUsingShadowDecl( |
1231 | ConstructorUsingShadowDecl *D) { |
1232 | VisitUsingShadowDecl(D); |
1233 | Record.AddDeclRef(D->NominatedBaseClassShadowDecl); |
1234 | Record.AddDeclRef(D->ConstructedBaseClassShadowDecl); |
1235 | Record.push_back(D->IsVirtual); |
1236 | Code = serialization::DECL_CONSTRUCTOR_USING_SHADOW; |
1237 | } |
1238 | |
1239 | void ASTDeclWriter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
1240 | VisitNamedDecl(D); |
1241 | Record.AddSourceLocation(D->getUsingLoc()); |
1242 | Record.AddSourceLocation(D->getNamespaceKeyLocation()); |
1243 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
1244 | Record.AddDeclRef(D->getNominatedNamespace()); |
1245 | Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor())); |
1246 | Code = serialization::DECL_USING_DIRECTIVE; |
1247 | } |
1248 | |
1249 | void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
1250 | VisitValueDecl(D); |
1251 | Record.AddSourceLocation(D->getUsingLoc()); |
1252 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
1253 | Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName()); |
1254 | Record.AddSourceLocation(D->getEllipsisLoc()); |
1255 | Code = serialization::DECL_UNRESOLVED_USING_VALUE; |
1256 | } |
1257 | |
1258 | void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl( |
1259 | UnresolvedUsingTypenameDecl *D) { |
1260 | VisitTypeDecl(D); |
1261 | Record.AddSourceLocation(D->getTypenameLoc()); |
1262 | Record.AddNestedNameSpecifierLoc(D->getQualifierLoc()); |
1263 | Record.AddSourceLocation(D->getEllipsisLoc()); |
1264 | Code = serialization::DECL_UNRESOLVED_USING_TYPENAME; |
1265 | } |
1266 | |
1267 | void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) { |
1268 | VisitRecordDecl(D); |
1269 | |
1270 | enum { |
1271 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
1272 | }; |
1273 | if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) { |
1274 | Record.push_back(CXXRecTemplate); |
1275 | Record.AddDeclRef(TemplD); |
1276 | } else if (MemberSpecializationInfo *MSInfo |
1277 | = D->getMemberSpecializationInfo()) { |
1278 | Record.push_back(CXXRecMemberSpecialization); |
1279 | Record.AddDeclRef(MSInfo->getInstantiatedFrom()); |
1280 | Record.push_back(MSInfo->getTemplateSpecializationKind()); |
1281 | Record.AddSourceLocation(MSInfo->getPointOfInstantiation()); |
1282 | } else { |
1283 | Record.push_back(CXXRecNotTemplate); |
1284 | } |
1285 | |
1286 | Record.push_back(D->isThisDeclarationADefinition()); |
1287 | if (D->isThisDeclarationADefinition()) |
1288 | Record.AddCXXDefinitionData(D); |
1289 | |
1290 | |
1291 | |
1292 | if (D->isCompleteDefinition()) |
1293 | Record.AddDeclRef(Context.getCurrentKeyFunction(D)); |
1294 | |
1295 | Code = serialization::DECL_CXX_RECORD; |
1296 | } |
1297 | |
1298 | void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) { |
1299 | VisitFunctionDecl(D); |
1300 | if (D->isCanonicalDecl()) { |
1301 | Record.push_back(D->size_overridden_methods()); |
1302 | for (const CXXMethodDecl *MD : D->overridden_methods()) |
1303 | Record.AddDeclRef(MD); |
1304 | } else { |
1305 | |
1306 | Record.push_back(0); |
1307 | } |
1308 | |
1309 | if (D->getDeclContext() == D->getLexicalDeclContext() && |
1310 | D->getFirstDecl() == D->getMostRecentDecl() && |
1311 | !D->isInvalidDecl() && |
1312 | !D->hasAttrs() && |
1313 | !D->isTopLevelDeclInObjCContainer() && |
1314 | D->getDeclName().getNameKind() == DeclarationName::Identifier && |
1315 | !D->hasExtInfo() && |
1316 | !D->hasInheritedPrototype() && |
1317 | D->hasWrittenPrototype()) |
1318 | AbbrevToUse = Writer.getDeclCXXMethodAbbrev(); |
1319 | |
1320 | Code = serialization::DECL_CXX_METHOD; |
1321 | } |
1322 | |
1323 | void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
1324 | if (auto Inherited = D->getInheritedConstructor()) { |
1325 | Record.AddDeclRef(Inherited.getShadowDecl()); |
1326 | Record.AddDeclRef(Inherited.getConstructor()); |
1327 | Code = serialization::DECL_CXX_INHERITED_CONSTRUCTOR; |
1328 | } else { |
1329 | Code = serialization::DECL_CXX_CONSTRUCTOR; |
1330 | } |
1331 | |
1332 | VisitCXXMethodDecl(D); |
1333 | |
1334 | Code = D->isInheritingConstructor() |
1335 | ? serialization::DECL_CXX_INHERITED_CONSTRUCTOR |
1336 | : serialization::DECL_CXX_CONSTRUCTOR; |
1337 | } |
1338 | |
1339 | void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
1340 | VisitCXXMethodDecl(D); |
1341 | |
1342 | Record.AddDeclRef(D->getOperatorDelete()); |
1343 | if (D->getOperatorDelete()) |
1344 | Record.AddStmt(D->getOperatorDeleteThisArg()); |
1345 | |
1346 | Code = serialization::DECL_CXX_DESTRUCTOR; |
1347 | } |
1348 | |
1349 | void ASTDeclWriter::VisitCXXConversionDecl(CXXConversionDecl *D) { |
1350 | VisitCXXMethodDecl(D); |
1351 | Code = serialization::DECL_CXX_CONVERSION; |
1352 | } |
1353 | |
1354 | void ASTDeclWriter::VisitImportDecl(ImportDecl *D) { |
1355 | VisitDecl(D); |
1356 | Record.push_back(Writer.getSubmoduleID(D->getImportedModule())); |
1357 | ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs(); |
1358 | Record.push_back(!IdentifierLocs.empty()); |
1359 | if (IdentifierLocs.empty()) { |
1360 | Record.AddSourceLocation(D->getEndLoc()); |
1361 | Record.push_back(1); |
1362 | } else { |
1363 | for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I) |
1364 | Record.AddSourceLocation(IdentifierLocs[I]); |
1365 | Record.push_back(IdentifierLocs.size()); |
1366 | } |
1367 | |
1368 | |
1369 | Code = serialization::DECL_IMPORT; |
1370 | } |
1371 | |
1372 | void ASTDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) { |
1373 | VisitDecl(D); |
1374 | Record.AddSourceLocation(D->getColonLoc()); |
1375 | Code = serialization::DECL_ACCESS_SPEC; |
1376 | } |
1377 | |
1378 | void ASTDeclWriter::VisitFriendDecl(FriendDecl *D) { |
1379 | |
1380 | |
1381 | Record.push_back(D->NumTPLists); |
1382 | VisitDecl(D); |
1383 | bool hasFriendDecl = D->Friend.is<NamedDecl*>(); |
1384 | Record.push_back(hasFriendDecl); |
1385 | if (hasFriendDecl) |
1386 | Record.AddDeclRef(D->getFriendDecl()); |
1387 | else |
1388 | Record.AddTypeSourceInfo(D->getFriendType()); |
1389 | for (unsigned i = 0; i < D->NumTPLists; ++i) |
1390 | Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i)); |
1391 | Record.AddDeclRef(D->getNextFriend()); |
1392 | Record.push_back(D->UnsupportedFriend); |
1393 | Record.AddSourceLocation(D->FriendLoc); |
1394 | Code = serialization::DECL_FRIEND; |
1395 | } |
1396 | |
1397 | void ASTDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
1398 | VisitDecl(D); |
1399 | Record.push_back(D->getNumTemplateParameters()); |
1400 | for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i) |
1401 | Record.AddTemplateParameterList(D->getTemplateParameterList(i)); |
1402 | Record.push_back(D->getFriendDecl() != nullptr); |
1403 | if (D->getFriendDecl()) |
1404 | Record.AddDeclRef(D->getFriendDecl()); |
1405 | else |
1406 | Record.AddTypeSourceInfo(D->getFriendType()); |
1407 | Record.AddSourceLocation(D->getFriendLoc()); |
1408 | Code = serialization::DECL_FRIEND_TEMPLATE; |
1409 | } |
1410 | |
1411 | void ASTDeclWriter::VisitTemplateDecl(TemplateDecl *D) { |
1412 | VisitNamedDecl(D); |
1413 | |
1414 | Record.AddDeclRef(D->getTemplatedDecl()); |
1415 | Record.AddTemplateParameterList(D->getTemplateParameters()); |
1416 | } |
1417 | |
1418 | void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { |
1419 | VisitRedeclarable(D); |
1420 | |
1421 | |
1422 | |
1423 | if (D->isFirstDecl()) { |
1424 | |
1425 | Record.AddDeclRef(D->getInstantiatedFromMemberTemplate()); |
1426 | if (D->getInstantiatedFromMemberTemplate()) |
1427 | Record.push_back(D->isMemberSpecialization()); |
1428 | } |
1429 | |
1430 | VisitTemplateDecl(D); |
1431 | Record.push_back(D->getIdentifierNamespace()); |
1432 | } |
1433 | |
1434 | void ASTDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
1435 | VisitRedeclarableTemplateDecl(D); |
1436 | |
1437 | if (D->isFirstDecl()) |
1438 | AddTemplateSpecializations(D); |
1439 | Code = serialization::DECL_CLASS_TEMPLATE; |
1440 | } |
1441 | |
1442 | void ASTDeclWriter::VisitClassTemplateSpecializationDecl( |
1443 | ClassTemplateSpecializationDecl *D) { |
1444 | RegisterTemplateSpecialization(D->getSpecializedTemplate(), D); |
1445 | |
1446 | VisitCXXRecordDecl(D); |
1447 | |
1448 | llvm::PointerUnion<ClassTemplateDecl *, |
1449 | ClassTemplatePartialSpecializationDecl *> InstFrom |
1450 | = D->getSpecializedTemplateOrPartial(); |
1451 | if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) { |
1452 | Record.AddDeclRef(InstFromD); |
1453 | } else { |
1454 | Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>()); |
1455 | Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs()); |
1456 | } |
1457 | |
1458 | Record.AddTemplateArgumentList(&D->getTemplateArgs()); |
1459 | Record.AddSourceLocation(D->getPointOfInstantiation()); |
1460 | Record.push_back(D->getSpecializationKind()); |
1461 | Record.push_back(D->isCanonicalDecl()); |
1462 | |
1463 | if (D->isCanonicalDecl()) { |
1464 | |
1465 | Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl()); |
1466 | } |
1467 | |
1468 | |
1469 | Record.AddTypeSourceInfo(D->getTypeAsWritten()); |
1470 | if (D->getTypeAsWritten()) { |
1471 | Record.AddSourceLocation(D->getExternLoc()); |
1472 | Record.AddSourceLocation(D->getTemplateKeywordLoc()); |
1473 | } |
1474 | |
1475 | Code = serialization::DECL_CLASS_TEMPLATE_SPECIALIZATION; |
1476 | } |
1477 | |
1478 | void ASTDeclWriter::VisitClassTemplatePartialSpecializationDecl( |
1479 | ClassTemplatePartialSpecializationDecl *D) { |
1480 | VisitClassTemplateSpecializationDecl(D); |
1481 | |
1482 | Record.AddTemplateParameterList(D->getTemplateParameters()); |
1483 | Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten()); |
1484 | |
1485 | |
1486 | if (D->getPreviousDecl() == nullptr) { |
1487 | Record.AddDeclRef(D->getInstantiatedFromMember()); |
1488 | Record.push_back(D->isMemberSpecialization()); |
1489 | } |
1490 | |
1491 | Code = serialization::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION; |
1492 | } |
1493 | |
1494 | void ASTDeclWriter::VisitVarTemplateDecl(VarTemplateDecl *D) { |
1495 | VisitRedeclarableTemplateDecl(D); |
1496 | |
1497 | if (D->isFirstDecl()) |
1498 | AddTemplateSpecializations(D); |
1499 | Code = serialization::DECL_VAR_TEMPLATE; |
1500 | } |
1501 | |
1502 | void ASTDeclWriter::VisitVarTemplateSpecializationDecl( |
1503 | VarTemplateSpecializationDecl *D) { |
1504 | RegisterTemplateSpecialization(D->getSpecializedTemplate(), D); |
1505 | |
1506 | VisitVarDecl(D); |
1507 | |
1508 | llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *> |
1509 | InstFrom = D->getSpecializedTemplateOrPartial(); |
1510 | if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) { |
1511 | Record.AddDeclRef(InstFromD); |
1512 | } else { |
1513 | Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>()); |
1514 | Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs()); |
1515 | } |
1516 | |
1517 | |
1518 | Record.AddTypeSourceInfo(D->getTypeAsWritten()); |
1519 | if (D->getTypeAsWritten()) { |
1520 | Record.AddSourceLocation(D->getExternLoc()); |
1521 | Record.AddSourceLocation(D->getTemplateKeywordLoc()); |
1522 | } |
1523 | |
1524 | Record.AddTemplateArgumentList(&D->getTemplateArgs()); |
1525 | Record.AddSourceLocation(D->getPointOfInstantiation()); |
1526 | Record.push_back(D->getSpecializationKind()); |
1527 | Record.push_back(D->IsCompleteDefinition); |
1528 | Record.push_back(D->isCanonicalDecl()); |
1529 | |
1530 | if (D->isCanonicalDecl()) { |
1531 | |
1532 | Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl()); |
1533 | } |
1534 | |
1535 | Code = serialization::DECL_VAR_TEMPLATE_SPECIALIZATION; |
1536 | } |
1537 | |
1538 | void ASTDeclWriter::VisitVarTemplatePartialSpecializationDecl( |
1539 | VarTemplatePartialSpecializationDecl *D) { |
1540 | VisitVarTemplateSpecializationDecl(D); |
1541 | |
1542 | Record.AddTemplateParameterList(D->getTemplateParameters()); |
1543 | Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten()); |
1544 | |
1545 | |
1546 | if (D->getPreviousDecl() == nullptr) { |
1547 | Record.AddDeclRef(D->getInstantiatedFromMember()); |
1548 | Record.push_back(D->isMemberSpecialization()); |
1549 | } |
1550 | |
1551 | Code = serialization::DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION; |
1552 | } |
1553 | |
1554 | void ASTDeclWriter::VisitClassScopeFunctionSpecializationDecl( |
1555 | ClassScopeFunctionSpecializationDecl *D) { |
1556 | VisitDecl(D); |
1557 | Record.AddDeclRef(D->getSpecialization()); |
1558 | Code = serialization::DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION; |
1559 | } |
1560 | |
1561 | |
1562 | void ASTDeclWriter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
1563 | VisitRedeclarableTemplateDecl(D); |
1564 | |
1565 | if (D->isFirstDecl()) |
1566 | AddTemplateSpecializations(D); |
1567 | Code = serialization::DECL_FUNCTION_TEMPLATE; |
1568 | } |
1569 | |
1570 | void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
1571 | VisitTypeDecl(D); |
1572 | |
1573 | Record.push_back(D->wasDeclaredWithTypename()); |
1574 | |
1575 | bool OwnsDefaultArg = D->hasDefaultArgument() && |
1576 | !D->defaultArgumentWasInherited(); |
1577 | Record.push_back(OwnsDefaultArg); |
1578 | if (OwnsDefaultArg) |
1579 | Record.AddTypeSourceInfo(D->getDefaultArgumentInfo()); |
1580 | |
1581 | Code = serialization::DECL_TEMPLATE_TYPE_PARM; |
1582 | } |
1583 | |
1584 | void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
1585 | |
1586 | |
1587 | |
1588 | if (D->isExpandedParameterPack()) |
1589 | Record.push_back(D->getNumExpansionTypes()); |
1590 | |
1591 | VisitDeclaratorDecl(D); |
1592 | |
1593 | Record.push_back(D->getDepth()); |
1594 | Record.push_back(D->getPosition()); |
1595 | |
1596 | if (D->isExpandedParameterPack()) { |
1597 | for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { |
1598 | Record.AddTypeRef(D->getExpansionType(I)); |
1599 | Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I)); |
1600 | } |
1601 | |
1602 | Code = serialization::DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK; |
1603 | } else { |
1604 | |
1605 | Record.push_back(D->isParameterPack()); |
1606 | bool OwnsDefaultArg = D->hasDefaultArgument() && |
1607 | !D->defaultArgumentWasInherited(); |
1608 | Record.push_back(OwnsDefaultArg); |
1609 | if (OwnsDefaultArg) |
1610 | Record.AddStmt(D->getDefaultArgument()); |
1611 | Code = serialization::DECL_NON_TYPE_TEMPLATE_PARM; |
1612 | } |
1613 | } |
1614 | |
1615 | void ASTDeclWriter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
1616 | |
1617 | |
1618 | |
1619 | if (D->isExpandedParameterPack()) |
1620 | Record.push_back(D->getNumExpansionTemplateParameters()); |
1621 | |
1622 | VisitTemplateDecl(D); |
1623 | |
1624 | Record.push_back(D->getDepth()); |
1625 | Record.push_back(D->getPosition()); |
1626 | |
1627 | if (D->isExpandedParameterPack()) { |
1628 | for (unsigned I = 0, N = D->getNumExpansionTemplateParameters(); |
1629 | I != N; ++I) |
1630 | Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I)); |
1631 | Code = serialization::DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK; |
1632 | } else { |
1633 | |
1634 | Record.push_back(D->isParameterPack()); |
1635 | bool OwnsDefaultArg = D->hasDefaultArgument() && |
1636 | !D->defaultArgumentWasInherited(); |
1637 | Record.push_back(OwnsDefaultArg); |
1638 | if (OwnsDefaultArg) |
1639 | Record.AddTemplateArgumentLoc(D->getDefaultArgument()); |
1640 | Code = serialization::DECL_TEMPLATE_TEMPLATE_PARM; |
1641 | } |
1642 | } |
1643 | |
1644 | void ASTDeclWriter::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { |
1645 | VisitRedeclarableTemplateDecl(D); |
1646 | Code = serialization::DECL_TYPE_ALIAS_TEMPLATE; |
1647 | } |
1648 | |
1649 | void ASTDeclWriter::VisitStaticAssertDecl(StaticAssertDecl *D) { |
1650 | VisitDecl(D); |
1651 | Record.AddStmt(D->getAssertExpr()); |
1652 | Record.push_back(D->isFailed()); |
1653 | Record.AddStmt(D->getMessage()); |
1654 | Record.AddSourceLocation(D->getRParenLoc()); |
1655 | Code = serialization::DECL_STATIC_ASSERT; |
1656 | } |
1657 | |
1658 | |
1659 | void ASTDeclWriter::VisitDeclContext(DeclContext *DC) { |
1660 | Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC)); |
1661 | Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC)); |
1662 | } |
1663 | |
1664 | const Decl *ASTWriter::getFirstLocalDecl(const Decl *D) { |
1665 | (0) . __assert_fail ("IsLocalDecl(D) && \"expected a local declaration\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1665, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(IsLocalDecl(D) && "expected a local declaration"); |
1666 | |
1667 | const Decl *Canon = D->getCanonicalDecl(); |
1668 | if (IsLocalDecl(Canon)) |
1669 | return Canon; |
1670 | |
1671 | const Decl *&CacheEntry = FirstLocalDeclCache[Canon]; |
1672 | if (CacheEntry) |
1673 | return CacheEntry; |
1674 | |
1675 | for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl()) |
1676 | if (IsLocalDecl(Redecl)) |
1677 | D = Redecl; |
1678 | return CacheEntry = D; |
1679 | } |
1680 | |
1681 | template <typename T> |
1682 | void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) { |
1683 | T *First = D->getFirstDecl(); |
1684 | T *MostRecent = First->getMostRecentDecl(); |
1685 | T *DAsT = static_cast<T *>(D); |
1686 | if (MostRecent != First) { |
1687 | (0) . __assert_fail ("isRedeclarableDeclKind(DAsT->getKind()) && \"Not considered redeclarable?\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1688, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isRedeclarableDeclKind(DAsT->getKind()) && |
1688 | (0) . __assert_fail ("isRedeclarableDeclKind(DAsT->getKind()) && \"Not considered redeclarable?\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 1688, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Not considered redeclarable?"); |
1689 | |
1690 | Record.AddDeclRef(First); |
1691 | |
1692 | |
1693 | |
1694 | const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT); |
1695 | if (DAsT == FirstLocal) { |
1696 | |
1697 | |
1698 | |
1699 | unsigned I = Record.size(); |
1700 | Record.push_back(0); |
1701 | if (Writer.Chain) |
1702 | AddFirstDeclFromEachModule(DAsT, ); |
1703 | |
1704 | Record[I] = Record.size() - I; |
1705 | |
1706 | |
1707 | |
1708 | ASTWriter::RecordData LocalRedecls; |
1709 | ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls); |
1710 | for (const Decl *Prev = FirstLocal->getMostRecentDecl(); |
1711 | Prev != FirstLocal; Prev = Prev->getPreviousDecl()) |
1712 | if (!Prev->isFromASTFile()) |
1713 | LocalRedeclWriter.AddDeclRef(Prev); |
1714 | |
1715 | |
1716 | |
1717 | if (LocalRedecls.empty()) |
1718 | Record.push_back(0); |
1719 | else |
1720 | Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS)); |
1721 | } else { |
1722 | Record.push_back(0); |
1723 | Record.AddDeclRef(FirstLocal); |
1724 | } |
1725 | |
1726 | |
1727 | |
1728 | |
1729 | |
1730 | |
1731 | |
1732 | (void)Writer.GetDeclRef(D->getPreviousDecl()); |
1733 | (void)Writer.GetDeclRef(MostRecent); |
1734 | } else { |
1735 | |
1736 | Record.push_back(0); |
1737 | } |
1738 | } |
1739 | |
1740 | void ASTDeclWriter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { |
1741 | Record.push_back(D->varlist_size()); |
1742 | VisitDecl(D); |
1743 | for (auto *I : D->varlists()) |
1744 | Record.AddStmt(I); |
1745 | Code = serialization::DECL_OMP_THREADPRIVATE; |
1746 | } |
1747 | |
1748 | void ASTDeclWriter::VisitOMPAllocateDecl(OMPAllocateDecl *D) { |
1749 | Record.push_back(D->varlist_size()); |
1750 | Record.push_back(D->clauselist_size()); |
1751 | VisitDecl(D); |
1752 | for (auto *I : D->varlists()) |
1753 | Record.AddStmt(I); |
1754 | OMPClauseWriter ClauseWriter(Record); |
1755 | for (OMPClause *C : D->clauselists()) |
1756 | ClauseWriter.writeClause(C); |
1757 | Code = serialization::DECL_OMP_ALLOCATE; |
1758 | } |
1759 | |
1760 | void ASTDeclWriter::VisitOMPRequiresDecl(OMPRequiresDecl *D) { |
1761 | Record.push_back(D->clauselist_size()); |
1762 | VisitDecl(D); |
1763 | OMPClauseWriter ClauseWriter(Record); |
1764 | for (OMPClause *C : D->clauselists()) |
1765 | ClauseWriter.writeClause(C); |
1766 | Code = serialization::DECL_OMP_REQUIRES; |
1767 | } |
1768 | |
1769 | void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { |
1770 | VisitValueDecl(D); |
1771 | Record.AddSourceLocation(D->getBeginLoc()); |
1772 | Record.AddStmt(D->getCombinerIn()); |
1773 | Record.AddStmt(D->getCombinerOut()); |
1774 | Record.AddStmt(D->getCombiner()); |
1775 | Record.AddStmt(D->getInitOrig()); |
1776 | Record.AddStmt(D->getInitPriv()); |
1777 | Record.AddStmt(D->getInitializer()); |
1778 | Record.push_back(D->getInitializerKind()); |
1779 | Record.AddDeclRef(D->getPrevDeclInScope()); |
1780 | Code = serialization::DECL_OMP_DECLARE_REDUCTION; |
1781 | } |
1782 | |
1783 | void ASTDeclWriter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) { |
1784 | Record.push_back(D->clauselist_size()); |
1785 | VisitValueDecl(D); |
1786 | Record.AddSourceLocation(D->getBeginLoc()); |
1787 | Record.AddStmt(D->getMapperVarRef()); |
1788 | Record.AddDeclarationName(D->getVarName()); |
1789 | Record.AddDeclRef(D->getPrevDeclInScope()); |
1790 | OMPClauseWriter ClauseWriter(Record); |
1791 | for (OMPClause *C : D->clauselists()) |
1792 | ClauseWriter.writeClause(C); |
1793 | Code = serialization::DECL_OMP_DECLARE_MAPPER; |
1794 | } |
1795 | |
1796 | void ASTDeclWriter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { |
1797 | VisitVarDecl(D); |
1798 | Code = serialization::DECL_OMP_CAPTUREDEXPR; |
1799 | } |
1800 | |
1801 | |
1802 | |
1803 | |
1804 | |
1805 | void ASTWriter::WriteDeclAbbrevs() { |
1806 | using namespace llvm; |
1807 | |
1808 | std::shared_ptr<BitCodeAbbrev> Abv; |
1809 | |
1810 | |
1811 | Abv = std::make_shared<BitCodeAbbrev>(); |
1812 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD)); |
1813 | |
1814 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1815 | Abv->Add(BitCodeAbbrevOp(0)); |
1816 | Abv->Add(BitCodeAbbrevOp(0)); |
1817 | Abv->Add(BitCodeAbbrevOp(0)); |
1818 | Abv->Add(BitCodeAbbrevOp(0)); |
1819 | Abv->Add(BitCodeAbbrevOp(0)); |
1820 | Abv->Add(BitCodeAbbrevOp(0)); |
1821 | Abv->Add(BitCodeAbbrevOp(0)); |
1822 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
1823 | Abv->Add(BitCodeAbbrevOp(0)); |
1824 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1825 | |
1826 | Abv->Add(BitCodeAbbrevOp(0)); |
1827 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1828 | Abv->Add(BitCodeAbbrevOp(0)); |
1829 | |
1830 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1831 | |
1832 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1833 | Abv->Add(BitCodeAbbrevOp(0)); |
1834 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1835 | |
1836 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1837 | Abv->Add(BitCodeAbbrevOp(0)); |
1838 | |
1839 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
1840 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1841 | DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
1842 | |
1843 | |
1844 | Abv = std::make_shared<BitCodeAbbrev>(); |
1845 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR)); |
1846 | |
1847 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1848 | Abv->Add(BitCodeAbbrevOp(0)); |
1849 | Abv->Add(BitCodeAbbrevOp(0)); |
1850 | Abv->Add(BitCodeAbbrevOp(0)); |
1851 | Abv->Add(BitCodeAbbrevOp(0)); |
1852 | Abv->Add(BitCodeAbbrevOp(0)); |
1853 | Abv->Add(BitCodeAbbrevOp(0)); |
1854 | Abv->Add(BitCodeAbbrevOp(0)); |
1855 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
1856 | Abv->Add(BitCodeAbbrevOp(0)); |
1857 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1858 | |
1859 | Abv->Add(BitCodeAbbrevOp(0)); |
1860 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1861 | Abv->Add(BitCodeAbbrevOp(0)); |
1862 | |
1863 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1864 | |
1865 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1866 | Abv->Add(BitCodeAbbrevOp(0)); |
1867 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1868 | |
1869 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1870 | Abv->Add(BitCodeAbbrevOp(0)); |
1871 | |
1872 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1873 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1874 | |
1875 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
1876 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1877 | DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
1878 | |
1879 | |
1880 | Abv = std::make_shared<BitCodeAbbrev>(); |
1881 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM)); |
1882 | |
1883 | Abv->Add(BitCodeAbbrevOp(0)); |
1884 | |
1885 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1886 | Abv->Add(BitCodeAbbrevOp(0)); |
1887 | Abv->Add(BitCodeAbbrevOp(0)); |
1888 | Abv->Add(BitCodeAbbrevOp(0)); |
1889 | Abv->Add(BitCodeAbbrevOp(0)); |
1890 | Abv->Add(BitCodeAbbrevOp(0)); |
1891 | Abv->Add(BitCodeAbbrevOp(0)); |
1892 | Abv->Add(BitCodeAbbrevOp(0)); |
1893 | Abv->Add(BitCodeAbbrevOp(AS_none)); |
1894 | Abv->Add(BitCodeAbbrevOp(0)); |
1895 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1896 | |
1897 | Abv->Add(BitCodeAbbrevOp(0)); |
1898 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1899 | Abv->Add(BitCodeAbbrevOp(0)); |
1900 | |
1901 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1902 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1903 | |
1904 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1905 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1906 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1907 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1908 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1909 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1910 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1911 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1912 | Abv->Add(BitCodeAbbrevOp(0)); |
1913 | |
1914 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1915 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1916 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1917 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1918 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1919 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1920 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1921 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1922 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); |
1923 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1924 | |
1925 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1926 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1927 | DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
1928 | |
1929 | |
1930 | Abv = std::make_shared<BitCodeAbbrev>(); |
1931 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD)); |
1932 | |
1933 | Abv->Add(BitCodeAbbrevOp(0)); |
1934 | |
1935 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1936 | Abv->Add(BitCodeAbbrevOp(0)); |
1937 | Abv->Add(BitCodeAbbrevOp(0)); |
1938 | Abv->Add(BitCodeAbbrevOp(0)); |
1939 | Abv->Add(BitCodeAbbrevOp(0)); |
1940 | Abv->Add(BitCodeAbbrevOp(0)); |
1941 | Abv->Add(BitCodeAbbrevOp(0)); |
1942 | Abv->Add(BitCodeAbbrevOp(0)); |
1943 | Abv->Add(BitCodeAbbrevOp(AS_none)); |
1944 | Abv->Add(BitCodeAbbrevOp(0)); |
1945 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1946 | |
1947 | Abv->Add(BitCodeAbbrevOp(0)); |
1948 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1949 | Abv->Add(BitCodeAbbrevOp(0)); |
1950 | |
1951 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1952 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1953 | |
1954 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1955 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1956 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1957 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1958 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1959 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1960 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1961 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1962 | Abv->Add(BitCodeAbbrevOp(0)); |
1963 | |
1964 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1965 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1966 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1967 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1968 | |
1969 | |
1970 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1971 | |
1972 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1973 | |
1974 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1975 | |
1976 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
1977 | |
1978 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
1979 | |
1980 | |
1981 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1982 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1983 | DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
1984 | |
1985 | |
1986 | Abv = std::make_shared<BitCodeAbbrev>(); |
1987 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR)); |
1988 | |
1989 | Abv->Add(BitCodeAbbrevOp(0)); |
1990 | |
1991 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
1992 | Abv->Add(BitCodeAbbrevOp(0)); |
1993 | Abv->Add(BitCodeAbbrevOp(0)); |
1994 | Abv->Add(BitCodeAbbrevOp(0)); |
1995 | Abv->Add(BitCodeAbbrevOp(0)); |
1996 | Abv->Add(BitCodeAbbrevOp(0)); |
1997 | Abv->Add(BitCodeAbbrevOp(0)); |
1998 | Abv->Add(BitCodeAbbrevOp(0)); |
1999 | Abv->Add(BitCodeAbbrevOp(AS_none)); |
2000 | Abv->Add(BitCodeAbbrevOp(0)); |
2001 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2002 | |
2003 | Abv->Add(BitCodeAbbrevOp(0)); |
2004 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2005 | Abv->Add(BitCodeAbbrevOp(0)); |
2006 | |
2007 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2008 | |
2009 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2010 | Abv->Add(BitCodeAbbrevOp(0)); |
2011 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2012 | |
2013 | Abv->Add(BitCodeAbbrevOp(0)); |
2014 | Abv->Add(BitCodeAbbrevOp(0)); |
2015 | Abv->Add(BitCodeAbbrevOp(0)); |
2016 | Abv->Add(BitCodeAbbrevOp(0)); |
2017 | Abv->Add(BitCodeAbbrevOp(0)); |
2018 | Abv->Add(BitCodeAbbrevOp(0)); |
2019 | Abv->Add(BitCodeAbbrevOp(0)); |
2020 | |
2021 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2022 | Abv->Add(BitCodeAbbrevOp(0)); |
2023 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2024 | Abv->Add(BitCodeAbbrevOp(0)); |
2025 | Abv->Add(BitCodeAbbrevOp(0)); |
2026 | Abv->Add(BitCodeAbbrevOp(0)); |
2027 | Abv->Add(BitCodeAbbrevOp(0)); |
2028 | |
2029 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
2030 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2031 | DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2032 | |
2033 | |
2034 | Abv = std::make_shared<BitCodeAbbrev>(); |
2035 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF)); |
2036 | |
2037 | Abv->Add(BitCodeAbbrevOp(0)); |
2038 | |
2039 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2040 | Abv->Add(BitCodeAbbrevOp(0)); |
2041 | Abv->Add(BitCodeAbbrevOp(0)); |
2042 | Abv->Add(BitCodeAbbrevOp(0)); |
2043 | Abv->Add(BitCodeAbbrevOp(0)); |
2044 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2045 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2046 | Abv->Add(BitCodeAbbrevOp(0)); |
2047 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
2048 | Abv->Add(BitCodeAbbrevOp(0)); |
2049 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2050 | |
2051 | Abv->Add(BitCodeAbbrevOp(0)); |
2052 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2053 | Abv->Add(BitCodeAbbrevOp(0)); |
2054 | |
2055 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2056 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2057 | |
2058 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
2059 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2060 | DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2061 | |
2062 | |
2063 | Abv = std::make_shared<BitCodeAbbrev>(); |
2064 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR)); |
2065 | |
2066 | Abv->Add(BitCodeAbbrevOp(0)); |
2067 | |
2068 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2069 | Abv->Add(BitCodeAbbrevOp(0)); |
2070 | Abv->Add(BitCodeAbbrevOp(0)); |
2071 | Abv->Add(BitCodeAbbrevOp(0)); |
2072 | Abv->Add(BitCodeAbbrevOp(0)); |
2073 | Abv->Add(BitCodeAbbrevOp(0)); |
2074 | Abv->Add(BitCodeAbbrevOp(0)); |
2075 | Abv->Add(BitCodeAbbrevOp(0)); |
2076 | Abv->Add(BitCodeAbbrevOp(AS_none)); |
2077 | Abv->Add(BitCodeAbbrevOp(0)); |
2078 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2079 | |
2080 | Abv->Add(BitCodeAbbrevOp(0)); |
2081 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2082 | Abv->Add(BitCodeAbbrevOp(0)); |
2083 | |
2084 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2085 | |
2086 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2087 | Abv->Add(BitCodeAbbrevOp(0)); |
2088 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2089 | |
2090 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2091 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
2092 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
2093 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2094 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2095 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2096 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2097 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2098 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2099 | Abv->Add(BitCodeAbbrevOp(0)); |
2100 | Abv->Add(BitCodeAbbrevOp(0)); |
2101 | Abv->Add(BitCodeAbbrevOp(0)); |
2102 | Abv->Add(BitCodeAbbrevOp(0)); |
2103 | Abv->Add(BitCodeAbbrevOp(0)); |
2104 | Abv->Add(BitCodeAbbrevOp(0)); |
2105 | Abv->Add(BitCodeAbbrevOp(0)); |
2106 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2107 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
2108 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
2109 | |
2110 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
2111 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2112 | DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2113 | |
2114 | |
2115 | Abv = std::make_shared<BitCodeAbbrev>(); |
2116 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CXX_METHOD)); |
2117 | |
2118 | Abv->Add(BitCodeAbbrevOp(0)); |
2119 | |
2120 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2121 | Abv->Add(BitCodeAbbrevOp(0)); |
2122 | Abv->Add(BitCodeAbbrevOp(0)); |
2123 | Abv->Add(BitCodeAbbrevOp(0)); |
2124 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2125 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2126 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2127 | Abv->Add(BitCodeAbbrevOp(0)); |
2128 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); |
2129 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2130 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2131 | |
2132 | Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); |
2133 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2134 | Abv->Add(BitCodeAbbrevOp(0)); |
2135 | |
2136 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2137 | |
2138 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2139 | Abv->Add(BitCodeAbbrevOp(0)); |
2140 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2141 | |
2142 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); |
2143 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2144 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2145 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2146 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2147 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2148 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2149 | Abv->Add(BitCodeAbbrevOp(0)); |
2150 | Abv->Add(BitCodeAbbrevOp(1)); |
2151 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2152 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2153 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2154 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2155 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2156 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2157 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2158 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2159 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2160 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2161 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2162 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2163 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2164 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); |
2165 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2166 | |
2167 | |
2168 | |
2169 | |
2170 | |
2171 | |
2172 | |
2173 | |
2174 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); |
2175 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2176 | DeclCXXMethodAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2177 | |
2178 | |
2179 | Abv = std::make_shared<BitCodeAbbrev>(); |
2180 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF)); |
2181 | |
2182 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2183 | |
2184 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2185 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2186 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2187 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2188 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2189 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2190 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2191 | |
2192 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2193 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2194 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2195 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2196 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, |
2197 | 1)); |
2198 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2199 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2200 | DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2201 | |
2202 | |
2203 | Abv = std::make_shared<BitCodeAbbrev>(); |
2204 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL)); |
2205 | |
2206 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2207 | |
2208 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2209 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2210 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2211 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2212 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2213 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2214 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2215 | |
2216 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2217 | Abv->Add(BitCodeAbbrevOp(32)); |
2218 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2219 | IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2220 | |
2221 | |
2222 | Abv = std::make_shared<BitCodeAbbrev>(); |
2223 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL)); |
2224 | |
2225 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2226 | |
2227 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2228 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2229 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2230 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2231 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2232 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2233 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2234 | |
2235 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2236 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2237 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2238 | CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2239 | |
2240 | |
2241 | Abv = std::make_shared<BitCodeAbbrev>(); |
2242 | Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST)); |
2243 | |
2244 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2245 | |
2246 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); |
2247 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2248 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2249 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2250 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2251 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2252 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); |
2253 | |
2254 | Abv->Add(BitCodeAbbrevOp(0)); |
2255 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 6)); |
2256 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); |
2257 | |
2258 | ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2259 | |
2260 | Abv = std::make_shared<BitCodeAbbrev>(); |
2261 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL)); |
2262 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); |
2263 | DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2264 | |
2265 | Abv = std::make_shared<BitCodeAbbrev>(); |
2266 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE)); |
2267 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); |
2268 | DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv)); |
2269 | } |
2270 | |
2271 | |
2272 | |
2273 | |
2274 | |
2275 | |
2276 | |
2277 | |
2278 | |
2279 | |
2280 | |
2281 | |
2282 | |
2283 | static bool isRequiredDecl(const Decl *D, ASTContext &Context, |
2284 | bool WritingModule) { |
2285 | |
2286 | |
2287 | |
2288 | |
2289 | |
2290 | if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D)) |
2291 | return true; |
2292 | |
2293 | if (WritingModule && isPartOfPerModuleInitializer(D)) { |
2294 | |
2295 | |
2296 | return false; |
2297 | } |
2298 | |
2299 | return Context.DeclMustBeEmitted(D); |
2300 | } |
2301 | |
2302 | void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { |
2303 | PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(), |
2304 | "serializing"); |
2305 | |
2306 | |
2307 | serialization::DeclID ID; |
2308 | (0) . __assert_fail ("!D->isFromASTFile() && \"should not be emitting imported decl\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 2308, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->isFromASTFile() && "should not be emitting imported decl"); |
2309 | serialization::DeclID &IDR = DeclIDs[D]; |
2310 | if (IDR == 0) |
2311 | IDR = NextDeclID++; |
2312 | |
2313 | ID = IDR; |
2314 | |
2315 | (0) . __assert_fail ("ID >= FirstDeclID && \"invalid decl ID\"", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 2315, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(ID >= FirstDeclID && "invalid decl ID"); |
2316 | |
2317 | RecordData Record; |
2318 | ASTDeclWriter W(*this, Context, Record); |
2319 | |
2320 | |
2321 | W.Visit(D); |
2322 | |
2323 | |
2324 | uint64_t Offset = W.Emit(D); |
2325 | |
2326 | |
2327 | SourceLocation Loc = D->getLocation(); |
2328 | unsigned Index = ID - FirstDeclID; |
2329 | if (DeclOffsets.size() == Index) |
2330 | DeclOffsets.push_back(DeclOffset(Loc, Offset)); |
2331 | else if (DeclOffsets.size() < Index) { |
2332 | |
2333 | DeclOffsets.resize(Index+1); |
2334 | DeclOffsets[Index].setLocation(Loc); |
2335 | DeclOffsets[Index].BitOffset = Offset; |
2336 | } else { |
2337 | llvm_unreachable("declarations should be emitted in ID order"); |
2338 | } |
2339 | |
2340 | SourceManager &SM = Context.getSourceManager(); |
2341 | if (Loc.isValid() && SM.isLocalSourceLocation(Loc)) |
2342 | associateDeclWithFile(D, ID); |
2343 | |
2344 | |
2345 | |
2346 | if (isRequiredDecl(D, Context, WritingModule)) |
2347 | EagerlyDeserializedDecls.push_back(ID); |
2348 | } |
2349 | |
2350 | void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) { |
2351 | |
2352 | Writer->ClearSwitchCaseIDs(); |
2353 | |
2354 | doesThisDeclarationHaveABody()", "/home/seafit/code_projects/clang_source/clang/lib/Serialization/ASTWriterDecl.cpp", 2354, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(FD->doesThisDeclarationHaveABody()); |
2355 | bool ModulesCodegen = false; |
2356 | if (Writer->WritingModule && !FD->isDependentContext()) { |
2357 | Optional<GVALinkage> Linkage; |
2358 | if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) { |
2359 | |
2360 | |
2361 | |
2362 | |
2363 | Linkage = Writer->Context->GetGVALinkageForFunction(FD); |
2364 | ModulesCodegen = *Linkage == GVA_StrongExternal; |
2365 | } |
2366 | if (Writer->Context->getLangOpts().ModulesCodegen) { |
2367 | |
2368 | |
2369 | if (!FD->hasAttr<AlwaysInlineAttr>()) { |
2370 | if (!Linkage) |
2371 | Linkage = Writer->Context->GetGVALinkageForFunction(FD); |
2372 | ModulesCodegen = *Linkage != GVA_Internal; |
2373 | } |
2374 | } |
2375 | } |
2376 | Record->push_back(ModulesCodegen); |
2377 | if (ModulesCodegen) |
2378 | Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD)); |
2379 | if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) { |
2380 | Record->push_back(CD->getNumCtorInitializers()); |
2381 | if (CD->getNumCtorInitializers()) |
2382 | AddCXXCtorInitializers( |
2383 | llvm::makeArrayRef(CD->init_begin(), CD->init_end())); |
2384 | } |
2385 | AddStmt(FD->getBody()); |
2386 | } |
2387 | |