clang 22.0.0git
ASTWriterDecl.cpp
Go to the documentation of this file.
1//===--- ASTWriterDecl.cpp - Declaration Serialization --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements serialization for Declarations.
10//
11//===----------------------------------------------------------------------===//
12
13#include "ASTCommon.h"
14#include "clang/AST/Attr.h"
15#include "clang/AST/DeclCXX.h"
18#include "clang/AST/Expr.h"
24#include "llvm/Bitstream/BitstreamWriter.h"
25#include "llvm/Support/ErrorHandling.h"
26using namespace clang;
27using namespace serialization;
28
29//===----------------------------------------------------------------------===//
30// Utility functions
31//===----------------------------------------------------------------------===//
32
33namespace {
34
35// Helper function that returns true if the decl passed in the argument is
36// a defintion in dependent contxt.
37template <typename DT> bool isDefinitionInDependentContext(DT *D) {
38 return D->isDependentContext() && D->isThisDeclarationADefinition();
39}
40
41} // namespace
42
43//===----------------------------------------------------------------------===//
44// Declaration serialization
45//===----------------------------------------------------------------------===//
46
47namespace clang {
48 class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
49 ASTWriter &Writer;
51
53 unsigned AbbrevToUse;
54
55 bool GeneratingReducedBMI = false;
56
57 public:
59 ASTWriter::RecordDataImpl &Record, bool GeneratingReducedBMI)
60 : Writer(Writer), Record(Context, Writer, Record),
61 Code((serialization::DeclCode)0), AbbrevToUse(0),
62 GeneratingReducedBMI(GeneratingReducedBMI) {}
63
64 uint64_t Emit(Decl *D) {
65 if (!Code)
66 llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
67 D->getDeclKindName() + "'");
68 return Record.Emit(Code, AbbrevToUse);
69 }
70
71 void Visit(Decl *D);
72
73 void VisitDecl(Decl *D);
78 void VisitLabelDecl(LabelDecl *LD);
88 void VisitTagDecl(TagDecl *D);
116 void VisitVarDecl(VarDecl *D);
153 template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
155
156 // FIXME: Put in the same order is DeclNodes.td?
177
180
181 /// Add an Objective-C type parameter list to the given record.
183 // Empty type parameter list.
184 if (!typeParams) {
185 Record.push_back(0);
186 return;
187 }
188
189 Record.push_back(typeParams->size());
190 for (auto *typeParam : *typeParams) {
191 Record.AddDeclRef(typeParam);
192 }
193 Record.AddSourceLocation(typeParams->getLAngleLoc());
194 Record.AddSourceLocation(typeParams->getRAngleLoc());
195 }
196
197 /// Collect the first declaration from each module file that provides a
198 /// declaration of D.
200 const Decl *D, bool IncludeLocal,
201 llvm::MapVector<ModuleFile *, const Decl *> &Firsts) {
202
203 // FIXME: We can skip entries that we know are implied by others.
204 for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
205 if (R->isFromASTFile())
206 Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
207 else if (IncludeLocal)
208 Firsts[nullptr] = R;
209 }
210 }
211
212 /// Add to the record the first declaration from each module file that
213 /// provides a declaration of D. The intent is to provide a sufficient
214 /// set such that reloading this set will load all current redeclarations.
215 void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
216 llvm::MapVector<ModuleFile *, const Decl *> Firsts;
217 CollectFirstDeclFromEachModule(D, IncludeLocal, Firsts);
218
219 for (const auto &F : Firsts)
220 Record.AddDeclRef(F.second);
221 }
222
223 template <typename T> bool shouldSkipWritingSpecializations(T *Spec) {
224 // Now we will only avoid writing specializations if we're generating
225 // reduced BMI.
226 if (!GeneratingReducedBMI)
227 return false;
228
231
233 if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
234 Args = CTSD->getTemplateArgs().asArray();
235 else if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
236 Args = VTSD->getTemplateArgs().asArray();
237 else
238 Args = cast<FunctionDecl>(Spec)
239 ->getTemplateSpecializationArgs()
240 ->asArray();
241
242 // If there is any template argument is TULocal, we can avoid writing the
243 // specialization since the consumers of reduced BMI won't get the
244 // specialization anyway.
245 for (const TemplateArgument &TA : Args) {
246 switch (TA.getKind()) {
248 Linkage L = TA.getAsType()->getLinkage();
249 if (!isExternallyVisible(L))
250 return true;
251 break;
252 }
254 if (!TA.getAsDecl()->isExternallyVisible())
255 return true;
256 break;
257 default:
258 break;
259 }
260 }
261
262 return false;
263 }
264
265 /// Add to the record the first template specialization from each module
266 /// file that provides a declaration of D. We store the DeclId and an
267 /// ODRHash of the template arguments of D which should provide enough
268 /// information to load D only if the template instantiator needs it.
270 const Decl *D, llvm::SmallVectorImpl<const Decl *> &SpecsInMap,
271 llvm::SmallVectorImpl<const Decl *> &PartialSpecsInMap) {
272 assert((isa<ClassTemplateSpecializationDecl>(D) ||
273 isa<VarTemplateSpecializationDecl>(D) || isa<FunctionDecl>(D)) &&
274 "Must not be called with other decls");
275 llvm::MapVector<ModuleFile *, const Decl *> Firsts;
276 CollectFirstDeclFromEachModule(D, /*IncludeLocal*/ true, Firsts);
277
278 for (const auto &F : Firsts) {
280 continue;
281
284 PartialSpecsInMap.push_back(F.second);
285 else
286 SpecsInMap.push_back(F.second);
287 }
288 }
289
290 /// Get the specialization decl from an entry in the specialization list.
291 template <typename EntryType>
295 }
296
297 /// Get the list of partial specializations from a template's common ptr.
298 template<typename T>
299 decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
300 return Common->PartialSpecializations;
301 }
304 return {};
305 }
306
307 template<typename DeclTy>
309 auto *Common = D->getCommonPtr();
310
311 // If we have any lazy specializations, and the external AST source is
312 // our chained AST reader, we can just write out the DeclIDs. Otherwise,
313 // we need to resolve them to actual declarations.
314 if (Writer.Chain != Record.getASTContext().getExternalSource() &&
315 Writer.Chain && Writer.Chain->haveUnloadedSpecializations(D)) {
316 D->LoadLazySpecializations();
317 assert(!Writer.Chain->haveUnloadedSpecializations(D));
318 }
319
320 // AddFirstSpecializationDeclFromEachModule might trigger deserialization,
321 // invalidating *Specializations iterators.
323 for (auto &Entry : Common->Specializations)
324 AllSpecs.push_back(getSpecializationDecl(Entry));
325 for (auto &Entry : getPartialSpecializations(Common))
326 AllSpecs.push_back(getSpecializationDecl(Entry));
327
330 for (auto *D : AllSpecs) {
331 assert(D->isCanonicalDecl() && "non-canonical decl in set");
332 AddFirstSpecializationDeclFromEachModule(D, Specs, PartialSpecs);
333 }
334
335 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
336 D, Specs, /*IsPartial=*/false));
337
338 // Function Template Decl doesn't have partial decls.
339 if (isa<FunctionTemplateDecl>(D)) {
340 assert(PartialSpecs.empty());
341 return;
342 }
343
344 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
345 D, PartialSpecs, /*IsPartial=*/true));
346 }
347
348 /// Ensure that this template specialization is associated with the specified
349 /// template on reload.
351 const Decl *Specialization) {
352 Template = Template->getCanonicalDecl();
353
354 // If the canonical template is local, we'll write out this specialization
355 // when we emit it.
356 // FIXME: We can do the same thing if there is any local declaration of
357 // the template, to avoid emitting an update record.
358 if (!Template->isFromASTFile())
359 return;
360
361 // We only need to associate the first local declaration of the
362 // specialization. The other declarations will get pulled in by it.
364 return;
365
368 Writer.PartialSpecializationsUpdates[cast<NamedDecl>(Template)]
369 .push_back(cast<NamedDecl>(Specialization));
370 else
371 Writer.SpecializationsUpdates[cast<NamedDecl>(Template)].push_back(
372 cast<NamedDecl>(Specialization));
373 }
374 };
375}
376
377// When building a C++20 module interface unit or a partition unit, a
378// strong definition in the module interface is provided by the
379// compilation of that unit, not by its users. (Inline variables are still
380// emitted in module users.)
381static bool shouldVarGenerateHereOnly(const VarDecl *VD) {
382 if (VD->getStorageDuration() != SD_Static)
383 return false;
384
385 if (VD->getDescribedVarTemplate())
386 return false;
387
388 Module *M = VD->getOwningModule();
389 if (!M)
390 return false;
391
392 M = M->getTopLevelModule();
393 ASTContext &Ctx = VD->getASTContext();
394 if (!M->isInterfaceOrPartition() &&
395 (!VD->hasAttr<DLLExportAttr>() ||
396 !Ctx.getLangOpts().BuildingPCHWithObjectFile))
397 return false;
398
400}
401
403 if (FD->isDependentContext())
404 return false;
405
406 ASTContext &Ctx = FD->getASTContext();
407 auto Linkage = Ctx.GetGVALinkageForFunction(FD);
408 if (Ctx.getLangOpts().ModulesCodegen ||
409 (FD->hasAttr<DLLExportAttr>() &&
410 Ctx.getLangOpts().BuildingPCHWithObjectFile))
411 // Under -fmodules-codegen, codegen is performed for all non-internal,
412 // non-always_inline functions, unless they are available elsewhere.
413 if (!FD->hasAttr<AlwaysInlineAttr>() && Linkage != GVA_Internal &&
415 return true;
416
417 Module *M = FD->getOwningModule();
418 if (!M)
419 return false;
420
421 M = M->getTopLevelModule();
422 if (M->isInterfaceOrPartition())
424 return true;
425
426 return false;
427}
428
430 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
431 if (FD->isInlined() || FD->isConstexpr() || FD->isConsteval())
432 return false;
433
434 // If the function should be generated somewhere else, we shouldn't elide
435 // it.
437 return false;
438 }
439
440 if (auto *VD = dyn_cast<VarDecl>(D)) {
441 if (VD->getDeclContext()->isDependentContext())
442 return false;
443
444 // Constant initialized variable may not affect the ABI, but they
445 // may be used in constant evaluation in the frontend, so we have
446 // to remain them.
447 if (VD->hasConstantInitialization() || VD->isConstexpr())
448 return false;
449
450 // If the variable should be generated somewhere else, we shouldn't elide
451 // it.
453 return false;
454 }
455
456 return true;
457}
458
461
462 // Source locations require array (variable-length) abbreviations. The
463 // abbreviation infrastructure requires that arrays are encoded last, so
464 // we handle it here in the case of those classes derived from DeclaratorDecl
465 if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
466 if (auto *TInfo = DD->getTypeSourceInfo())
467 Record.AddTypeLoc(TInfo->getTypeLoc());
468 }
469
470 // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
471 // have been written. We want it last because we will not read it back when
472 // retrieving it from the AST, we'll just lazily set the offset.
473 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
474 if (!GeneratingReducedBMI || !CanElideDeclDef(FD)) {
475 Record.push_back(FD->doesThisDeclarationHaveABody());
476 if (FD->doesThisDeclarationHaveABody())
477 Record.AddFunctionDefinition(FD);
478 } else
479 Record.push_back(0);
480 }
481
482 // Similar to FunctionDecls, handle VarDecl's initializer here and write it
483 // after all other Stmts/Exprs. We will not read the initializer until after
484 // we have finished recursive deserialization, because it can recursively
485 // refer back to the variable.
486 if (auto *VD = dyn_cast<VarDecl>(D)) {
487 if (!GeneratingReducedBMI || !CanElideDeclDef(VD))
488 Record.AddVarDeclInit(VD);
489 else
490 Record.push_back(0);
491 }
492
493 // And similarly for FieldDecls. We already serialized whether there is a
494 // default member initializer.
495 if (auto *FD = dyn_cast<FieldDecl>(D)) {
496 if (FD->hasInClassInitializer()) {
497 if (Expr *Init = FD->getInClassInitializer()) {
498 Record.push_back(1);
499 Record.AddStmt(Init);
500 } else {
501 Record.push_back(0);
502 // Initializer has not been instantiated yet.
503 }
504 }
505 }
506
507 // If this declaration is also a DeclContext, write blocks for the
508 // declarations that lexically stored inside its context and those
509 // declarations that are visible from its context.
510 if (auto *DC = dyn_cast<DeclContext>(D))
512}
513
515 BitsPacker DeclBits;
516
517 // The order matters here. It will be better to put the bit with higher
518 // probability to be 0 in the end of the bits.
519 //
520 // Since we're using VBR6 format to store it.
521 // It will be pretty effient if all the higher bits are 0.
522 // For example, if we need to pack 8 bits into a value and the stored value
523 // is 0xf0, the actual stored value will be 0b000111'110000, which takes 12
524 // bits actually. However, if we changed the order to be 0x0f, then we can
525 // store it as 0b001111, which takes 6 bits only now.
526 DeclBits.addBits((uint64_t)D->getModuleOwnershipKind(), /*BitWidth=*/3);
528 DeclBits.addBit(D->isUsed(false));
529 DeclBits.addBits(D->getAccess(), /*BitWidth=*/2);
530 DeclBits.addBit(D->isImplicit());
531 DeclBits.addBit(D->getDeclContext() != D->getLexicalDeclContext());
532 DeclBits.addBit(D->hasAttrs());
534 DeclBits.addBit(D->isInvalidDecl());
535 Record.push_back(DeclBits);
536
537 Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
539 Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
540
541 if (D->hasAttrs())
542 Record.AddAttributes(D->getAttrs());
543
544 Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
545
546 // If this declaration injected a name into a context different from its
547 // lexical context, and that context is an imported namespace, we need to
548 // update its visible declarations to include this name.
549 //
550 // This happens when we instantiate a class with a friend declaration or a
551 // function with a local extern declaration, for instance.
552 //
553 // FIXME: Can we handle this in AddedVisibleDecl instead?
554 if (D->isOutOfLine()) {
555 auto *DC = D->getDeclContext();
556 while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
557 if (!NS->isFromASTFile())
558 break;
559 Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
560 if (!NS->isInlineNamespace())
561 break;
562 DC = NS->getParent();
563 }
564 }
565}
566
568 StringRef Arg = D->getArg();
569 Record.push_back(Arg.size());
570 VisitDecl(D);
571 Record.AddSourceLocation(D->getBeginLoc());
572 Record.push_back(D->getCommentKind());
573 Record.AddString(Arg);
575}
576
579 StringRef Name = D->getName();
580 StringRef Value = D->getValue();
581 Record.push_back(Name.size() + 1 + Value.size());
582 VisitDecl(D);
583 Record.AddSourceLocation(D->getBeginLoc());
584 Record.AddString(Name);
585 Record.AddString(Value);
587}
588
590 llvm_unreachable("Translation units aren't directly serialized");
591}
592
594 VisitDecl(D);
595 Record.AddDeclarationName(D->getDeclName());
598 : 0);
599}
600
603 Record.AddSourceLocation(D->getBeginLoc());
604 if (!isa<TagDecl, TypedefDecl, TypeAliasDecl>(D))
605 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
606}
607
611 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
612 Record.push_back(D->isModed());
613 if (D->isModed())
614 Record.AddTypeRef(D->getUnderlyingType());
615 Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
616}
617
621 !D->hasAttrs() &&
622 !D->isImplicit() &&
623 D->getFirstDecl() == D->getMostRecentDecl() &&
624 !D->isInvalidDecl() &&
626 !D->isModulePrivate() &&
628 D->getDeclName().getNameKind() == DeclarationName::Identifier)
629 AbbrevToUse = Writer.getDeclTypedefAbbrev();
630
632}
633
636 Record.AddDeclRef(D->getDescribedAliasTemplate());
638}
639
641 static_assert(DeclContext::NumTagDeclBits == 23,
642 "You need to update the serializer after you change the "
643 "TagDeclBits");
644
647 Record.push_back(D->getIdentifierNamespace());
648
649 BitsPacker TagDeclBits;
650 TagDeclBits.addBits(llvm::to_underlying(D->getTagKind()), /*BitWidth=*/3);
651 TagDeclBits.addBit(!isa<CXXRecordDecl>(D) ? D->isCompleteDefinition() : 0);
652 TagDeclBits.addBit(D->isEmbeddedInDeclarator());
653 TagDeclBits.addBit(D->isFreeStanding());
654 TagDeclBits.addBit(D->isCompleteDefinitionRequired());
655 TagDeclBits.addBits(
656 D->hasExtInfo() ? 1 : (D->getTypedefNameForAnonDecl() ? 2 : 0),
657 /*BitWidth=*/2);
658 Record.push_back(TagDeclBits);
659
660 Record.AddSourceRange(D->getBraceRange());
661
662 if (D->hasExtInfo()) {
663 Record.AddQualifierInfo(*D->getExtInfo());
664 } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
665 Record.AddDeclRef(TD);
666 Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
667 }
668}
669
671 static_assert(DeclContext::NumEnumDeclBits == 43,
672 "You need to update the serializer after you change the "
673 "EnumDeclBits");
674
676 Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
677 if (!D->getIntegerTypeSourceInfo())
678 Record.AddTypeRef(D->getIntegerType());
679 Record.AddTypeRef(D->getPromotionType());
680
681 BitsPacker EnumDeclBits;
682 EnumDeclBits.addBits(D->getNumPositiveBits(), /*BitWidth=*/8);
683 EnumDeclBits.addBits(D->getNumNegativeBits(), /*BitWidth=*/8);
684 EnumDeclBits.addBit(D->isScoped());
685 EnumDeclBits.addBit(D->isScopedUsingClassTag());
686 EnumDeclBits.addBit(D->isFixed());
687 Record.push_back(EnumDeclBits);
688
689 Record.push_back(D->getODRHash());
690
691 if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
692 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
693 Record.push_back(MemberInfo->getTemplateSpecializationKind());
694 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
695 } else {
696 Record.AddDeclRef(nullptr);
697 }
698
699 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
700 !D->isInvalidDecl() && !D->isImplicit() && !D->hasExtInfo() &&
701 !D->getTypedefNameForAnonDecl() &&
702 D->getFirstDecl() == D->getMostRecentDecl() &&
705 !D->getIntegerTypeSourceInfo() && !D->getMemberSpecializationInfo() &&
707 D->getDeclName().getNameKind() == DeclarationName::Identifier)
708 AbbrevToUse = Writer.getDeclEnumAbbrev();
709
711}
712
714 static_assert(DeclContext::NumRecordDeclBits == 64,
715 "You need to update the serializer after you change the "
716 "RecordDeclBits");
717
719
720 BitsPacker RecordDeclBits;
721 RecordDeclBits.addBit(D->hasFlexibleArrayMember());
722 RecordDeclBits.addBit(D->isAnonymousStructOrUnion());
723 RecordDeclBits.addBit(D->hasObjectMember());
724 RecordDeclBits.addBit(D->hasVolatileMember());
725 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDefaultInitialize());
726 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveCopy());
727 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDestroy());
728 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveDefaultInitializeCUnion());
729 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveDestructCUnion());
730 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveCopyCUnion());
731 RecordDeclBits.addBit(D->hasUninitializedExplicitInitFields());
732 RecordDeclBits.addBit(D->isParamDestroyedInCallee());
733 RecordDeclBits.addBits(llvm::to_underlying(D->getArgPassingRestrictions()), 2);
734 Record.push_back(RecordDeclBits);
735
736 // Only compute this for C/Objective-C, in C++ this is computed as part
737 // of CXXRecordDecl.
738 if (!isa<CXXRecordDecl>(D))
739 Record.push_back(D->getODRHash());
740
741 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
742 !D->isImplicit() && !D->isInvalidDecl() && !D->hasExtInfo() &&
743 !D->getTypedefNameForAnonDecl() &&
744 D->getFirstDecl() == D->getMostRecentDecl() &&
748 D->getDeclName().getNameKind() == DeclarationName::Identifier)
749 AbbrevToUse = Writer.getDeclRecordAbbrev();
750
752}
753
756 Record.AddTypeRef(D->getType());
757}
758
761 Record.push_back(D->getInitExpr()? 1 : 0);
762 if (D->getInitExpr())
763 Record.AddStmt(D->getInitExpr());
764 Record.AddAPSInt(D->getInitVal());
765
767}
768
771 Record.AddSourceLocation(D->getInnerLocStart());
772 Record.push_back(D->hasExtInfo());
773 if (D->hasExtInfo()) {
774 DeclaratorDecl::ExtInfo *Info = D->getExtInfo();
775 Record.AddQualifierInfo(*Info);
776 Record.AddStmt(
777 const_cast<Expr *>(Info->TrailingRequiresClause.ConstraintExpr));
778 Record.writeUnsignedOrNone(Info->TrailingRequiresClause.ArgPackSubstIndex);
779 }
780 // The location information is deferred until the end of the record.
781 Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType()
782 : QualType());
783}
784
786 static_assert(DeclContext::NumFunctionDeclBits == 45,
787 "You need to update the serializer after you change the "
788 "FunctionDeclBits");
789
791
792 Record.push_back(D->getTemplatedKind());
793 switch (D->getTemplatedKind()) {
795 break;
797 Record.AddDeclRef(D->getInstantiatedFromDecl());
798 break;
800 Record.AddDeclRef(D->getDescribedFunctionTemplate());
801 break;
803 MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo();
804 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
805 Record.push_back(MemberInfo->getTemplateSpecializationKind());
806 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
807 break;
808 }
811 FTSInfo = D->getTemplateSpecializationInfo();
812
814
815 Record.AddDeclRef(FTSInfo->getTemplate());
816 Record.push_back(FTSInfo->getTemplateSpecializationKind());
817
818 // Template arguments.
819 Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
820
821 // Template args as written.
822 Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
823 if (FTSInfo->TemplateArgumentsAsWritten)
824 Record.AddASTTemplateArgumentListInfo(
826
827 Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
828
829 if (MemberSpecializationInfo *MemberInfo =
830 FTSInfo->getMemberSpecializationInfo()) {
831 Record.push_back(1);
832 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
833 Record.push_back(MemberInfo->getTemplateSpecializationKind());
834 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
835 } else {
836 Record.push_back(0);
837 }
838
839 if (D->isCanonicalDecl()) {
840 // Write the template that contains the specializations set. We will
841 // add a FunctionTemplateSpecializationInfo to it when reading.
842 Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
843 }
844 break;
845 }
848 DFTSInfo = D->getDependentSpecializationInfo();
849
850 // Candidates.
851 Record.push_back(DFTSInfo->getCandidates().size());
852 for (FunctionTemplateDecl *FTD : DFTSInfo->getCandidates())
853 Record.AddDeclRef(FTD);
854
855 // Templates args.
856 Record.push_back(DFTSInfo->TemplateArgumentsAsWritten != nullptr);
857 if (DFTSInfo->TemplateArgumentsAsWritten)
858 Record.AddASTTemplateArgumentListInfo(
860 break;
861 }
862 }
863
865 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
866 Record.push_back(D->getIdentifierNamespace());
867
868 // The order matters here. It will be better to put the bit with higher
869 // probability to be 0 in the end of the bits. See the comments in VisitDecl
870 // for details.
871 BitsPacker FunctionDeclBits;
872 // FIXME: stable encoding
873 FunctionDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()), 3);
874 FunctionDeclBits.addBits((uint32_t)D->getStorageClass(), /*BitWidth=*/3);
875 FunctionDeclBits.addBit(D->isInlineSpecified());
876 FunctionDeclBits.addBit(D->isInlined());
877 FunctionDeclBits.addBit(D->hasSkippedBody());
878 FunctionDeclBits.addBit(D->isVirtualAsWritten());
879 FunctionDeclBits.addBit(D->isPureVirtual());
880 FunctionDeclBits.addBit(D->hasInheritedPrototype());
881 FunctionDeclBits.addBit(D->hasWrittenPrototype());
882 FunctionDeclBits.addBit(D->isDeletedBit());
883 FunctionDeclBits.addBit(D->isTrivial());
884 FunctionDeclBits.addBit(D->isTrivialForCall());
885 FunctionDeclBits.addBit(D->isDefaulted());
886 FunctionDeclBits.addBit(D->isExplicitlyDefaulted());
887 FunctionDeclBits.addBit(D->isIneligibleOrNotSelected());
888 FunctionDeclBits.addBits((uint64_t)(D->getConstexprKind()), /*BitWidth=*/2);
889 FunctionDeclBits.addBit(D->hasImplicitReturnZero());
890 FunctionDeclBits.addBit(D->isMultiVersion());
891 FunctionDeclBits.addBit(D->isLateTemplateParsed());
892 FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate());
893 FunctionDeclBits.addBit(D->FriendConstraintRefersToEnclosingTemplate());
894 FunctionDeclBits.addBit(D->usesSEHTry());
895 FunctionDeclBits.addBit(D->isDestroyingOperatorDelete());
896 FunctionDeclBits.addBit(D->isTypeAwareOperatorNewOrDelete());
897 Record.push_back(FunctionDeclBits);
898
899 Record.AddSourceLocation(D->getEndLoc());
900 if (D->isExplicitlyDefaulted())
901 Record.AddSourceLocation(D->getDefaultLoc());
902
903 Record.push_back(D->getODRHash());
904
905 if (D->isDefaulted() || D->isDeletedAsWritten()) {
906 if (auto *FDI = D->getDefalutedOrDeletedInfo()) {
907 // Store both that there is an DefaultedOrDeletedInfo and whether it
908 // contains a DeletedMessage.
909 StringLiteral *DeletedMessage = FDI->getDeletedMessage();
910 Record.push_back(1 | (DeletedMessage ? 2 : 0));
911 if (DeletedMessage)
912 Record.AddStmt(DeletedMessage);
913
914 Record.push_back(FDI->getUnqualifiedLookups().size());
915 for (DeclAccessPair P : FDI->getUnqualifiedLookups()) {
916 Record.AddDeclRef(P.getDecl());
917 Record.push_back(P.getAccess());
918 }
919 } else {
920 Record.push_back(0);
921 }
922 }
923
924 if (D->getFriendObjectKind()) {
925 // For a friend function defined inline within a class template, we have to
926 // force the definition to be the one inside the definition of the template
927 // class. Remember this relation to deserialize them together.
928 if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent());
929 RD && isDefinitionInDependentContext(RD)) {
930 Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
931 Writer.GetDeclRef(D));
932 }
933 }
934
935 Record.push_back(D->param_size());
936 for (auto *P : D->parameters())
937 Record.AddDeclRef(P);
939}
940
943 uint64_t Kind = static_cast<uint64_t>(ES.getKind());
944 Kind = Kind << 1 | static_cast<bool>(ES.getExpr());
945 Record.push_back(Kind);
946 if (ES.getExpr()) {
947 Record.AddStmt(ES.getExpr());
948 }
949}
950
952 addExplicitSpecifier(D->getExplicitSpecifier(), Record);
953 Record.AddDeclRef(D->Ctor);
955 Record.push_back(static_cast<unsigned char>(D->getDeductionCandidateKind()));
956 Record.AddDeclRef(D->getSourceDeductionGuide());
957 Record.push_back(
958 static_cast<unsigned char>(D->getSourceDeductionGuideKind()));
960}
961
963 static_assert(DeclContext::NumObjCMethodDeclBits == 37,
964 "You need to update the serializer after you change the "
965 "ObjCMethodDeclBits");
966
968 // FIXME: convert to LazyStmtPtr?
969 // Unlike C/C++, method bodies will never be in header files.
970 bool HasBodyStuff = D->getBody() != nullptr;
971 Record.push_back(HasBodyStuff);
972 if (HasBodyStuff) {
973 Record.AddStmt(D->getBody());
974 }
975 Record.AddDeclRef(D->getSelfDecl());
976 Record.AddDeclRef(D->getCmdDecl());
977 Record.push_back(D->isInstanceMethod());
978 Record.push_back(D->isVariadic());
979 Record.push_back(D->isPropertyAccessor());
980 Record.push_back(D->isSynthesizedAccessorStub());
981 Record.push_back(D->isDefined());
982 Record.push_back(D->isOverriding());
983 Record.push_back(D->hasSkippedBody());
984
985 Record.push_back(D->isRedeclaration());
986 Record.push_back(D->hasRedeclaration());
987 if (D->hasRedeclaration()) {
988 assert(Record.getASTContext().getObjCMethodRedeclaration(D));
989 Record.AddDeclRef(Record.getASTContext().getObjCMethodRedeclaration(D));
990 }
991
992 // FIXME: stable encoding for @required/@optional
993 Record.push_back(llvm::to_underlying(D->getImplementationControl()));
994 // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
995 Record.push_back(D->getObjCDeclQualifier());
996 Record.push_back(D->hasRelatedResultType());
997 Record.AddTypeRef(D->getReturnType());
998 Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
999 Record.AddSourceLocation(D->getEndLoc());
1000 Record.push_back(D->param_size());
1001 for (const auto *P : D->parameters())
1002 Record.AddDeclRef(P);
1003
1004 Record.push_back(D->getSelLocsKind());
1005 unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
1006 SourceLocation *SelLocs = D->getStoredSelLocs();
1007 Record.push_back(NumStoredSelLocs);
1008 for (unsigned i = 0; i != NumStoredSelLocs; ++i)
1009 Record.AddSourceLocation(SelLocs[i]);
1010
1012}
1013
1016 Record.push_back(D->Variance);
1017 Record.push_back(D->Index);
1018 Record.AddSourceLocation(D->VarianceLoc);
1019 Record.AddSourceLocation(D->ColonLoc);
1020
1022}
1023
1025 static_assert(DeclContext::NumObjCContainerDeclBits == 64,
1026 "You need to update the serializer after you change the "
1027 "ObjCContainerDeclBits");
1028
1030 Record.AddSourceLocation(D->getAtStartLoc());
1031 Record.AddSourceRange(D->getAtEndRange());
1032 // Abstract class (no need to define a stable serialization::DECL code).
1033}
1034
1038 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
1039 AddObjCTypeParamList(D->TypeParamList);
1040
1041 Record.push_back(D->isThisDeclarationADefinition());
1042 if (D->isThisDeclarationADefinition()) {
1043 // Write the DefinitionData
1044 ObjCInterfaceDecl::DefinitionData &Data = D->data();
1045
1046 Record.AddTypeSourceInfo(D->getSuperClassTInfo());
1047 Record.AddSourceLocation(D->getEndOfDefinitionLoc());
1048 Record.push_back(Data.HasDesignatedInitializers);
1049 Record.push_back(D->getODRHash());
1050
1051 // Write out the protocols that are directly referenced by the @interface.
1052 Record.push_back(Data.ReferencedProtocols.size());
1053 for (const auto *P : D->protocols())
1054 Record.AddDeclRef(P);
1055 for (const auto &PL : D->protocol_locs())
1056 Record.AddSourceLocation(PL);
1057
1058 // Write out the protocols that are transitively referenced.
1059 Record.push_back(Data.AllReferencedProtocols.size());
1061 P = Data.AllReferencedProtocols.begin(),
1062 PEnd = Data.AllReferencedProtocols.end();
1063 P != PEnd; ++P)
1064 Record.AddDeclRef(*P);
1065
1066
1067 if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
1068 // Ensure that we write out the set of categories for this class.
1069 Writer.ObjCClassesWithCategories.insert(D);
1070
1071 // Make sure that the categories get serialized.
1072 for (; Cat; Cat = Cat->getNextClassCategoryRaw())
1073 (void)Writer.GetDeclRef(Cat);
1074 }
1075 }
1076
1078}
1079
1082 // FIXME: stable encoding for @public/@private/@protected/@package
1083 Record.push_back(D->getAccessControl());
1084 Record.push_back(D->getSynthesize());
1085
1086 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1087 !D->hasAttrs() &&
1088 !D->isImplicit() &&
1089 !D->isUsed(false) &&
1090 !D->isInvalidDecl() &&
1091 !D->isReferenced() &&
1092 !D->isModulePrivate() &&
1093 !D->getBitWidth() &&
1094 !D->hasExtInfo() &&
1095 D->getDeclName())
1096 AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
1097
1099}
1100
1104
1105 Record.push_back(D->isThisDeclarationADefinition());
1106 if (D->isThisDeclarationADefinition()) {
1107 Record.push_back(D->protocol_size());
1108 for (const auto *I : D->protocols())
1109 Record.AddDeclRef(I);
1110 for (const auto &PL : D->protocol_locs())
1111 Record.AddSourceLocation(PL);
1112 Record.push_back(D->getODRHash());
1113 }
1114
1116}
1117
1121}
1122
1125 Record.AddSourceLocation(D->getCategoryNameLoc());
1126 Record.AddSourceLocation(D->getIvarLBraceLoc());
1127 Record.AddSourceLocation(D->getIvarRBraceLoc());
1128 Record.AddDeclRef(D->getClassInterface());
1129 AddObjCTypeParamList(D->TypeParamList);
1130 Record.push_back(D->protocol_size());
1131 for (const auto *I : D->protocols())
1132 Record.AddDeclRef(I);
1133 for (const auto &PL : D->protocol_locs())
1134 Record.AddSourceLocation(PL);
1136}
1137
1140 Record.AddDeclRef(D->getClassInterface());
1142}
1143
1146 Record.AddSourceLocation(D->getAtLoc());
1147 Record.AddSourceLocation(D->getLParenLoc());
1148 Record.AddTypeRef(D->getType());
1149 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
1150 // FIXME: stable encoding
1151 Record.push_back((unsigned)D->getPropertyAttributes());
1152 Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
1153 // FIXME: stable encoding
1154 Record.push_back((unsigned)D->getPropertyImplementation());
1155 Record.AddDeclarationName(D->getGetterName());
1156 Record.AddSourceLocation(D->getGetterNameLoc());
1157 Record.AddDeclarationName(D->getSetterName());
1158 Record.AddSourceLocation(D->getSetterNameLoc());
1159 Record.AddDeclRef(D->getGetterMethodDecl());
1160 Record.AddDeclRef(D->getSetterMethodDecl());
1161 Record.AddDeclRef(D->getPropertyIvarDecl());
1163}
1164
1167 Record.AddDeclRef(D->getClassInterface());
1168 // Abstract class (no need to define a stable serialization::DECL code).
1169}
1170
1173 Record.AddSourceLocation(D->getCategoryNameLoc());
1175}
1176
1179 Record.AddDeclRef(D->getSuperClass());
1180 Record.AddSourceLocation(D->getSuperClassLoc());
1181 Record.AddSourceLocation(D->getIvarLBraceLoc());
1182 Record.AddSourceLocation(D->getIvarRBraceLoc());
1183 Record.push_back(D->hasNonZeroConstructors());
1184 Record.push_back(D->hasDestructors());
1185 Record.push_back(D->NumIvarInitializers);
1186 if (D->NumIvarInitializers)
1187 Record.AddCXXCtorInitializers(
1188 llvm::ArrayRef(D->init_begin(), D->init_end()));
1190}
1191
1193 VisitDecl(D);
1194 Record.AddSourceLocation(D->getBeginLoc());
1195 Record.AddDeclRef(D->getPropertyDecl());
1196 Record.AddDeclRef(D->getPropertyIvarDecl());
1197 Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
1198 Record.AddDeclRef(D->getGetterMethodDecl());
1199 Record.AddDeclRef(D->getSetterMethodDecl());
1200 Record.AddStmt(D->getGetterCXXConstructor());
1201 Record.AddStmt(D->getSetterCXXAssignment());
1203}
1204
1207 Record.push_back(D->isMutable());
1208
1209 Record.push_back((D->StorageKind << 1) | D->BitField);
1210 if (D->StorageKind == FieldDecl::ISK_CapturedVLAType)
1211 Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
1212 else if (D->BitField)
1213 Record.AddStmt(D->getBitWidth());
1214
1215 if (!D->getDeclName() || D->isPlaceholderVar(Writer.getLangOpts()))
1216 Record.AddDeclRef(
1217 Record.getASTContext().getInstantiatedFromUnnamedFieldDecl(D));
1218
1219 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1220 !D->hasAttrs() &&
1221 !D->isImplicit() &&
1222 !D->isUsed(false) &&
1223 !D->isInvalidDecl() &&
1224 !D->isReferenced() &&
1226 !D->isModulePrivate() &&
1227 !D->getBitWidth() &&
1228 !D->hasInClassInitializer() &&
1229 !D->hasCapturedVLAType() &&
1230 !D->hasExtInfo() &&
1233 D->getDeclName())
1234 AbbrevToUse = Writer.getDeclFieldAbbrev();
1235
1237}
1238
1241 Record.AddIdentifierRef(D->getGetterId());
1242 Record.AddIdentifierRef(D->getSetterId());
1244}
1245
1248 MSGuidDecl::Parts Parts = D->getParts();
1249 Record.push_back(Parts.Part1);
1250 Record.push_back(Parts.Part2);
1251 Record.push_back(Parts.Part3);
1252 Record.append(std::begin(Parts.Part4And5), std::end(Parts.Part4And5));
1254}
1255
1259 Record.AddAPValue(D->getValue());
1261}
1262
1265 Record.AddAPValue(D->getValue());
1267}
1268
1271 Record.push_back(D->getChainingSize());
1272
1273 for (const auto *P : D->chain())
1274 Record.AddDeclRef(P);
1276}
1277
1281
1282 // The order matters here. It will be better to put the bit with higher
1283 // probability to be 0 in the end of the bits. See the comments in VisitDecl
1284 // for details.
1285 BitsPacker VarDeclBits;
1286 VarDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()),
1287 /*BitWidth=*/3);
1288
1289 bool ModulesCodegen = shouldVarGenerateHereOnly(D);
1290 VarDeclBits.addBit(ModulesCodegen);
1291
1292 VarDeclBits.addBits(D->getStorageClass(), /*BitWidth=*/3);
1293 VarDeclBits.addBits(D->getTSCSpec(), /*BitWidth=*/2);
1294 VarDeclBits.addBits(D->getInitStyle(), /*BitWidth=*/2);
1295 VarDeclBits.addBit(D->isARCPseudoStrong());
1296
1297 bool HasDeducedType = false;
1298 if (!isa<ParmVarDecl>(D)) {
1299 VarDeclBits.addBit(D->isThisDeclarationADemotedDefinition());
1300 VarDeclBits.addBit(D->isExceptionVariable());
1301 VarDeclBits.addBit(D->isNRVOVariable());
1302 VarDeclBits.addBit(D->isCXXForRangeDecl());
1303
1304 VarDeclBits.addBit(D->isInline());
1305 VarDeclBits.addBit(D->isInlineSpecified());
1306 VarDeclBits.addBit(D->isConstexpr());
1307 VarDeclBits.addBit(D->isInitCapture());
1308 VarDeclBits.addBit(D->isPreviousDeclInSameBlockScope());
1309
1310 VarDeclBits.addBit(D->isEscapingByref());
1311 HasDeducedType = D->getType()->getContainedDeducedType();
1312 VarDeclBits.addBit(HasDeducedType);
1313
1314 if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
1315 VarDeclBits.addBits(llvm::to_underlying(IPD->getParameterKind()),
1316 /*Width=*/3);
1317 else
1318 VarDeclBits.addBits(0, /*Width=*/3);
1319
1320 VarDeclBits.addBit(D->isObjCForDecl());
1321 VarDeclBits.addBit(D->isCXXForRangeImplicitVar());
1322 }
1323
1324 Record.push_back(VarDeclBits);
1325
1326 if (ModulesCodegen)
1327 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1328
1329 if (D->hasAttr<BlocksAttr>()) {
1330 BlockVarCopyInit Init = Record.getASTContext().getBlockVarCopyInit(D);
1331 Record.AddStmt(Init.getCopyExpr());
1332 if (Init.getCopyExpr())
1333 Record.push_back(Init.canThrow());
1334 }
1335
1336 enum {
1337 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1338 };
1339 if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
1340 Record.push_back(VarTemplate);
1341 Record.AddDeclRef(TemplD);
1342 } else if (MemberSpecializationInfo *SpecInfo
1343 = D->getMemberSpecializationInfo()) {
1344 Record.push_back(StaticDataMemberSpecialization);
1345 Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
1346 Record.push_back(SpecInfo->getTemplateSpecializationKind());
1347 Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
1348 } else {
1349 Record.push_back(VarNotTemplate);
1350 }
1351
1352 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1355 D->getDeclName().getNameKind() == DeclarationName::Identifier &&
1356 !D->hasExtInfo() && D->getFirstDecl() == D->getMostRecentDecl() &&
1357 D->getKind() == Decl::Var && !D->isInline() && !D->isConstexpr() &&
1358 !D->isInitCapture() && !D->isPreviousDeclInSameBlockScope() &&
1359 !D->hasInitWithSideEffects() && !D->isEscapingByref() &&
1360 !HasDeducedType && D->getStorageDuration() != SD_Static &&
1361 !D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
1362 !D->isObjCForDecl() && !isa<ImplicitParamDecl>(D) &&
1363 !D->isEscapingByref())
1364 AbbrevToUse = Writer.getDeclVarAbbrev();
1365
1367}
1368
1370 VisitVarDecl(D);
1372}
1373
1375 VisitVarDecl(D);
1376
1377 // See the implementation of `ParmVarDecl::getParameterIndex()`, which may
1378 // exceed the size of the normal bitfield. So it may be better to not pack
1379 // these bits.
1380 Record.push_back(D->getFunctionScopeIndex());
1381
1382 BitsPacker ParmVarDeclBits;
1383 ParmVarDeclBits.addBit(D->isObjCMethodParameter());
1384 ParmVarDeclBits.addBits(D->getFunctionScopeDepth(), /*BitsWidth=*/7);
1385 // FIXME: stable encoding
1386 ParmVarDeclBits.addBits(D->getObjCDeclQualifier(), /*BitsWidth=*/7);
1387 ParmVarDeclBits.addBit(D->isKNRPromoted());
1388 ParmVarDeclBits.addBit(D->hasInheritedDefaultArg());
1389 ParmVarDeclBits.addBit(D->hasUninstantiatedDefaultArg());
1390 ParmVarDeclBits.addBit(D->getExplicitObjectParamThisLoc().isValid());
1391 Record.push_back(ParmVarDeclBits);
1392
1393 if (D->hasUninstantiatedDefaultArg())
1394 Record.AddStmt(D->getUninstantiatedDefaultArg());
1395 if (D->getExplicitObjectParamThisLoc().isValid())
1396 Record.AddSourceLocation(D->getExplicitObjectParamThisLoc());
1398
1399 // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1400 // we dynamically check for the properties that we optimize for, but don't
1401 // know are true of all PARM_VAR_DECLs.
1402 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1403 !D->hasExtInfo() && D->getStorageClass() == 0 && !D->isInvalidDecl() &&
1405 D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1406 D->getInit() == nullptr) // No default expr.
1407 AbbrevToUse = Writer.getDeclParmVarAbbrev();
1408
1409 // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1410 // just us assuming it.
1411 assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1412 assert(!D->isThisDeclarationADemotedDefinition()
1413 && "PARM_VAR_DECL can't be demoted definition.");
1414 assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1415 assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1416 assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1417 assert(!D->isStaticDataMember() &&
1418 "PARM_VAR_DECL can't be static data member");
1419}
1420
1422 // Record the number of bindings first to simplify deserialization.
1423 Record.push_back(D->bindings().size());
1424
1425 VisitVarDecl(D);
1426 for (auto *B : D->bindings())
1427 Record.AddDeclRef(B);
1429}
1430
1433 Record.AddStmt(D->getBinding());
1435}
1436
1438 VisitDecl(D);
1439 Record.AddStmt(D->getAsmStringExpr());
1440 Record.AddSourceLocation(D->getRParenLoc());
1442}
1443
1445 VisitDecl(D);
1446 Record.AddStmt(D->getStmt());
1448}
1449
1451 VisitDecl(D);
1453}
1454
1457 VisitDecl(D);
1458 Record.AddDeclRef(D->getExtendingDecl());
1459 Record.AddStmt(D->getTemporaryExpr());
1460 Record.push_back(static_cast<bool>(D->getValue()));
1461 if (D->getValue())
1462 Record.AddAPValue(*D->getValue());
1463 Record.push_back(D->getManglingNumber());
1465}
1467 VisitDecl(D);
1468 Record.AddStmt(D->getBody());
1469 Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1470 Record.push_back(D->param_size());
1471 for (ParmVarDecl *P : D->parameters())
1472 Record.AddDeclRef(P);
1473 Record.push_back(D->isVariadic());
1474 Record.push_back(D->blockMissingReturnType());
1475 Record.push_back(D->isConversionFromLambda());
1476 Record.push_back(D->doesNotEscape());
1477 Record.push_back(D->canAvoidCopyToHeap());
1478 Record.push_back(D->capturesCXXThis());
1479 Record.push_back(D->getNumCaptures());
1480 for (const auto &capture : D->captures()) {
1481 Record.AddDeclRef(capture.getVariable());
1482
1483 unsigned flags = 0;
1484 if (capture.isByRef()) flags |= 1;
1485 if (capture.isNested()) flags |= 2;
1486 if (capture.hasCopyExpr()) flags |= 4;
1487 Record.push_back(flags);
1488
1489 if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1490 }
1491
1493}
1494
1496 Record.push_back(D->getNumParams());
1497 VisitDecl(D);
1498 for (unsigned I = 0; I < D->getNumParams(); ++I)
1499 Record.AddDeclRef(D->getParam(I));
1500 Record.push_back(D->isNothrow() ? 1 : 0);
1501 Record.AddStmt(D->getBody());
1503}
1504
1506 Record.push_back(CD->getNumParams());
1507 VisitDecl(CD);
1508 Record.push_back(CD->getContextParamPosition());
1509 Record.push_back(CD->isNothrow() ? 1 : 0);
1510 // Body is stored by VisitCapturedStmt.
1511 for (unsigned I = 0; I < CD->getNumParams(); ++I)
1512 Record.AddDeclRef(CD->getParam(I));
1514}
1515
1517 static_assert(DeclContext::NumLinkageSpecDeclBits == 17,
1518 "You need to update the serializer after you change the"
1519 "LinkageSpecDeclBits");
1520
1521 VisitDecl(D);
1522 Record.push_back(llvm::to_underlying(D->getLanguage()));
1523 Record.AddSourceLocation(D->getExternLoc());
1524 Record.AddSourceLocation(D->getRBraceLoc());
1526}
1527
1529 VisitDecl(D);
1530 Record.AddSourceLocation(D->getRBraceLoc());
1532}
1533
1536 Record.AddSourceLocation(D->getBeginLoc());
1538}
1539
1540
1544
1545 BitsPacker NamespaceDeclBits;
1546 NamespaceDeclBits.addBit(D->isInline());
1547 NamespaceDeclBits.addBit(D->isNested());
1548 Record.push_back(NamespaceDeclBits);
1549
1550 Record.AddSourceLocation(D->getBeginLoc());
1551 Record.AddSourceLocation(D->getRBraceLoc());
1552
1553 if (D->isFirstDecl())
1554 Record.AddDeclRef(D->getAnonymousNamespace());
1556
1557 if (Writer.hasChain() && D->isAnonymousNamespace() &&
1558 D == D->getMostRecentDecl()) {
1559 // This is a most recent reopening of the anonymous namespace. If its parent
1560 // is in a previous PCH (or is the TU), mark that parent for update, because
1561 // the original namespace always points to the latest re-opening of its
1562 // anonymous namespace.
1563 Decl *Parent = cast<Decl>(
1564 D->getParent()->getRedeclContext()->getPrimaryContext());
1565 if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1566 Writer.DeclUpdates[Parent].push_back(
1567 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, D));
1568 }
1569 }
1570}
1571
1575 Record.AddSourceLocation(D->getNamespaceLoc());
1576 Record.AddSourceLocation(D->getTargetNameLoc());
1577 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1578 Record.AddDeclRef(D->getNamespace());
1580}
1581
1584 Record.AddSourceLocation(D->getUsingLoc());
1585 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1586 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1587 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1588 Record.push_back(D->hasTypename());
1589 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingDecl(D));
1591}
1592
1595 Record.AddSourceLocation(D->getUsingLoc());
1596 Record.AddSourceLocation(D->getEnumLoc());
1597 Record.AddTypeSourceInfo(D->getEnumType());
1598 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1599 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingEnumDecl(D));
1601}
1602
1604 Record.push_back(D->NumExpansions);
1606 Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1607 for (auto *E : D->expansions())
1608 Record.AddDeclRef(E);
1610}
1611
1615 Record.AddDeclRef(D->getTargetDecl());
1616 Record.push_back(D->getIdentifierNamespace());
1617 Record.AddDeclRef(D->UsingOrNextShadow);
1618 Record.AddDeclRef(
1619 Record.getASTContext().getInstantiatedFromUsingShadowDecl(D));
1620
1621 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1622 D->getFirstDecl() == D->getMostRecentDecl() && !D->hasAttrs() &&
1624 D->getDeclName().getNameKind() == DeclarationName::Identifier)
1625 AbbrevToUse = Writer.getDeclUsingShadowAbbrev();
1626
1628}
1629
1633 Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1634 Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1635 Record.push_back(D->IsVirtual);
1637}
1638
1641 Record.AddSourceLocation(D->getUsingLoc());
1642 Record.AddSourceLocation(D->getNamespaceKeyLocation());
1643 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1644 Record.AddDeclRef(D->getNominatedNamespace());
1645 Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1647}
1648
1651 Record.AddSourceLocation(D->getUsingLoc());
1652 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1653 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1654 Record.AddSourceLocation(D->getEllipsisLoc());
1656}
1657
1661 Record.AddSourceLocation(D->getTypenameLoc());
1662 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1663 Record.AddSourceLocation(D->getEllipsisLoc());
1665}
1666
1671}
1672
1675
1676 enum {
1677 CXXRecNotTemplate = 0,
1678 CXXRecTemplate,
1679 CXXRecMemberSpecialization,
1680 CXXLambda
1681 };
1682 if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1683 Record.push_back(CXXRecTemplate);
1684 Record.AddDeclRef(TemplD);
1685 } else if (MemberSpecializationInfo *MSInfo
1686 = D->getMemberSpecializationInfo()) {
1687 Record.push_back(CXXRecMemberSpecialization);
1688 Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1689 Record.push_back(MSInfo->getTemplateSpecializationKind());
1690 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1691 } else if (D->isLambda()) {
1692 // For a lambda, we need some information early for merging.
1693 Record.push_back(CXXLambda);
1694 if (auto *Context = D->getLambdaContextDecl()) {
1695 Record.AddDeclRef(Context);
1696 Record.push_back(D->getLambdaIndexInContext());
1697 } else {
1698 Record.push_back(0);
1699 }
1700 // For lambdas inside template functions, remember the mapping to
1701 // deserialize them together.
1702 if (auto *FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
1703 FD && isDefinitionInDependentContext(FD)) {
1704 Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
1705 Writer.GetDeclRef(D->getLambdaCallOperator()));
1706 }
1707 } else {
1708 Record.push_back(CXXRecNotTemplate);
1709 }
1710
1711 Record.push_back(D->isThisDeclarationADefinition());
1712 if (D->isThisDeclarationADefinition())
1713 Record.AddCXXDefinitionData(D);
1714
1715 if (D->isCompleteDefinition() && D->isInNamedModule())
1716 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1717
1718 // Store (what we currently believe to be) the key function to avoid
1719 // deserializing every method so we can compute it.
1720 //
1721 // FIXME: Avoid adding the key function if the class is defined in
1722 // module purview since in that case the key function is meaningless.
1723 if (D->isCompleteDefinition())
1724 Record.AddDeclRef(Record.getASTContext().getCurrentKeyFunction(D));
1725
1727}
1728
1731 if (D->isCanonicalDecl()) {
1732 Record.push_back(D->size_overridden_methods());
1733 for (const CXXMethodDecl *MD : D->overridden_methods())
1734 Record.AddDeclRef(MD);
1735 } else {
1736 // We only need to record overridden methods once for the canonical decl.
1737 Record.push_back(0);
1738 }
1739
1740 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1741 D->getFirstDecl() == D->getMostRecentDecl() && !D->isInvalidDecl() &&
1743 D->getDeclName().getNameKind() == DeclarationName::Identifier &&
1744 !D->hasExtInfo() && !D->isExplicitlyDefaulted()) {
1745 if (D->getTemplatedKind() == FunctionDecl::TK_NonTemplate ||
1746 D->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate ||
1747 D->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization ||
1748 D->getTemplatedKind() == FunctionDecl::TK_DependentNonTemplate)
1749 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1750 else if (D->getTemplatedKind() ==
1753 D->getTemplateSpecializationInfo();
1754
1755 if (FTSInfo->TemplateArguments->size() == 1) {
1756 const TemplateArgument &TA = FTSInfo->TemplateArguments->get(0);
1757 if (TA.getKind() == TemplateArgument::Type &&
1758 !FTSInfo->TemplateArgumentsAsWritten &&
1759 !FTSInfo->getMemberSpecializationInfo())
1760 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1761 }
1762 } else if (D->getTemplatedKind() ==
1765 D->getDependentSpecializationInfo();
1766 if (!DFTSInfo->TemplateArgumentsAsWritten)
1767 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1768 }
1769 }
1770
1772}
1773
1775 static_assert(DeclContext::NumCXXConstructorDeclBits == 64,
1776 "You need to update the serializer after you change the "
1777 "CXXConstructorDeclBits");
1778
1779 Record.push_back(D->getTrailingAllocKind());
1780 addExplicitSpecifier(D->getExplicitSpecifierInternal(), Record);
1781 if (auto Inherited = D->getInheritedConstructor()) {
1782 Record.AddDeclRef(Inherited.getShadowDecl());
1783 Record.AddDeclRef(Inherited.getConstructor());
1784 }
1785
1788}
1789
1792
1793 Record.AddDeclRef(D->getOperatorDelete());
1794 if (D->getOperatorDelete())
1795 Record.AddStmt(D->getOperatorDeleteThisArg());
1796
1798}
1799
1801 addExplicitSpecifier(D->getExplicitSpecifier(), Record);
1804}
1805
1807 VisitDecl(D);
1808 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1809 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1810 Record.push_back(!IdentifierLocs.empty());
1811 if (IdentifierLocs.empty()) {
1812 Record.AddSourceLocation(D->getEndLoc());
1813 Record.push_back(1);
1814 } else {
1815 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1816 Record.AddSourceLocation(IdentifierLocs[I]);
1817 Record.push_back(IdentifierLocs.size());
1818 }
1819 // Note: the number of source locations must always be the last element in
1820 // the record.
1822}
1823
1825 VisitDecl(D);
1826 Record.AddSourceLocation(D->getColonLoc());
1828}
1829
1831 // Record the number of friend type template parameter lists here
1832 // so as to simplify memory allocation during deserialization.
1833 Record.push_back(D->NumTPLists);
1834 VisitDecl(D);
1835 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1836 Record.push_back(hasFriendDecl);
1837 if (hasFriendDecl)
1838 Record.AddDeclRef(D->getFriendDecl());
1839 else
1840 Record.AddTypeSourceInfo(D->getFriendType());
1841 for (unsigned i = 0; i < D->NumTPLists; ++i)
1842 Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1843 Record.AddDeclRef(D->getNextFriend());
1844 Record.push_back(D->UnsupportedFriend);
1845 Record.AddSourceLocation(D->FriendLoc);
1846 Record.AddSourceLocation(D->EllipsisLoc);
1848}
1849
1851 VisitDecl(D);
1852 Record.push_back(D->getNumTemplateParameters());
1853 for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1854 Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1855 Record.push_back(D->getFriendDecl() != nullptr);
1856 if (D->getFriendDecl())
1857 Record.AddDeclRef(D->getFriendDecl());
1858 else
1859 Record.AddTypeSourceInfo(D->getFriendType());
1860 Record.AddSourceLocation(D->getFriendLoc());
1862}
1863
1866
1867 Record.AddTemplateParameterList(D->getTemplateParameters());
1868 Record.AddDeclRef(D->getTemplatedDecl());
1869}
1870
1873 Record.AddStmt(D->getConstraintExpr());
1875}
1876
1879 Record.push_back(D->getTemplateArguments().size());
1880 VisitDecl(D);
1881 for (const TemplateArgument &Arg : D->getTemplateArguments())
1882 Record.AddTemplateArgument(Arg);
1884}
1885
1888}
1889
1892
1893 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1894 // getCommonPtr() can be used while this is still initializing.
1895 if (D->isFirstDecl()) {
1896 // This declaration owns the 'common' pointer, so serialize that data now.
1897 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1898 if (D->getInstantiatedFromMemberTemplate())
1899 Record.push_back(D->isMemberSpecialization());
1900 }
1901
1903 Record.push_back(D->getIdentifierNamespace());
1904}
1905
1908
1909 if (D->isFirstDecl())
1911
1912 // Force emitting the corresponding deduction guide in reduced BMI mode.
1913 // Otherwise, the deduction guide may be optimized out incorrectly.
1914 if (Writer.isGeneratingReducedBMI()) {
1915 auto Name =
1916 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1917 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1918 Writer.GetDeclRef(DG->getCanonicalDecl());
1919 }
1920
1922}
1923
1926 RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1927
1929
1930 llvm::PointerUnion<ClassTemplateDecl *,
1932 = D->getSpecializedTemplateOrPartial();
1933 if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1934 Record.AddDeclRef(InstFromD);
1935 } else {
1936 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1937 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1938 }
1939
1940 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1941 Record.AddSourceLocation(D->getPointOfInstantiation());
1942 Record.push_back(D->getSpecializationKind());
1943 Record.push_back(D->hasStrictPackMatch());
1944 Record.push_back(D->isCanonicalDecl());
1945
1946 if (D->isCanonicalDecl()) {
1947 // When reading, we'll add it to the folding set of the following template.
1948 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1949 }
1950
1952 D->getTemplateSpecializationKind() ==
1954 D->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDefinition;
1955 Record.push_back(ExplicitInstantiation);
1957 Record.AddSourceLocation(D->getExternKeywordLoc());
1958 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1959 }
1960
1961 const ASTTemplateArgumentListInfo *ArgsWritten =
1962 D->getTemplateArgsAsWritten();
1963 Record.push_back(!!ArgsWritten);
1964 if (ArgsWritten)
1965 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1966
1967 // Mention the implicitly generated C++ deduction guide to make sure the
1968 // deduction guide will be rewritten as expected.
1969 //
1970 // FIXME: Would it be more efficient to add a callback register function
1971 // in sema to register the deduction guide?
1972 if (Writer.isWritingStdCXXNamedModules()) {
1973 auto Name =
1974 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
1975 D->getSpecializedTemplate());
1976 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1977 Writer.GetDeclRef(DG->getCanonicalDecl());
1978 }
1979
1981}
1982
1985 Record.AddTemplateParameterList(D->getTemplateParameters());
1986
1988
1989 // These are read/set from/to the first declaration.
1990 if (D->getPreviousDecl() == nullptr) {
1991 Record.AddDeclRef(D->getInstantiatedFromMember());
1992 Record.push_back(D->isMemberSpecialization());
1993 }
1994
1996}
1997
2000
2001 if (D->isFirstDecl())
2004}
2005
2008 RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
2009
2010 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2011 InstFrom = D->getSpecializedTemplateOrPartial();
2012 if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
2013 Record.AddDeclRef(InstFromD);
2014 } else {
2015 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
2016 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
2017 }
2018
2020 D->getTemplateSpecializationKind() ==
2022 D->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDefinition;
2023 Record.push_back(ExplicitInstantiation);
2025 Record.AddSourceLocation(D->getExternKeywordLoc());
2026 Record.AddSourceLocation(D->getTemplateKeywordLoc());
2027 }
2028
2029 const ASTTemplateArgumentListInfo *ArgsWritten =
2030 D->getTemplateArgsAsWritten();
2031 Record.push_back(!!ArgsWritten);
2032 if (ArgsWritten)
2033 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
2034
2035 Record.AddTemplateArgumentList(&D->getTemplateArgs());
2036 Record.AddSourceLocation(D->getPointOfInstantiation());
2037 Record.push_back(D->getSpecializationKind());
2038 Record.push_back(D->IsCompleteDefinition);
2039
2040 VisitVarDecl(D);
2041
2042 Record.push_back(D->isCanonicalDecl());
2043
2044 if (D->isCanonicalDecl()) {
2045 // When reading, we'll add it to the folding set of the following template.
2046 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
2047 }
2048
2050}
2051
2054 Record.AddTemplateParameterList(D->getTemplateParameters());
2055
2057
2058 // These are read/set from/to the first declaration.
2059 if (D->getPreviousDecl() == nullptr) {
2060 Record.AddDeclRef(D->getInstantiatedFromMember());
2061 Record.push_back(D->isMemberSpecialization());
2062 }
2063
2065}
2066
2069
2070 if (D->isFirstDecl())
2073}
2074
2076 Record.push_back(D->hasTypeConstraint());
2078
2079 Record.push_back(D->wasDeclaredWithTypename());
2080
2081 const TypeConstraint *TC = D->getTypeConstraint();
2082 if (D->hasTypeConstraint())
2083 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
2084 if (TC) {
2085 auto *CR = TC->getConceptReference();
2086 Record.push_back(CR != nullptr);
2087 if (CR)
2088 Record.AddConceptReference(CR);
2090 Record.writeUnsignedOrNone(TC->getArgPackSubstIndex());
2091 Record.writeUnsignedOrNone(D->getNumExpansionParameters());
2092 }
2093
2094 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2095 !D->defaultArgumentWasInherited();
2096 Record.push_back(OwnsDefaultArg);
2097 if (OwnsDefaultArg)
2098 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2099
2100 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
2102 !D->isInvalidDecl() && !D->hasAttrs() &&
2104 D->getDeclName().getNameKind() == DeclarationName::Identifier)
2105 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
2106
2108}
2109
2111 // For an expanded parameter pack, record the number of expansion types here
2112 // so that it's easier for deserialization to allocate the right amount of
2113 // memory.
2114 Record.push_back(D->hasPlaceholderTypeConstraint());
2115 if (D->isExpandedParameterPack())
2116 Record.push_back(D->getNumExpansionTypes());
2117
2119 // TemplateParmPosition.
2120 Record.push_back(D->getDepth());
2121 Record.push_back(D->getPosition());
2122
2123 if (D->hasPlaceholderTypeConstraint())
2124 Record.AddStmt(D->getPlaceholderTypeConstraint());
2125
2126 if (D->isExpandedParameterPack()) {
2127 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2128 Record.AddTypeRef(D->getExpansionType(I));
2129 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2130 }
2131
2133 } else {
2134 // Rest of NonTypeTemplateParmDecl.
2135 Record.push_back(D->isParameterPack());
2136 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2137 !D->defaultArgumentWasInherited();
2138 Record.push_back(OwnsDefaultArg);
2139 if (OwnsDefaultArg)
2140 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2142 }
2143}
2144
2146 // For an expanded parameter pack, record the number of expansion types here
2147 // so that it's easier for deserialization to allocate the right amount of
2148 // memory.
2149 if (D->isExpandedParameterPack())
2150 Record.push_back(D->getNumExpansionTemplateParameters());
2151
2153 Record.push_back(D->templateParameterKind());
2154 Record.push_back(D->wasDeclaredWithTypename());
2155 // TemplateParmPosition.
2156 Record.push_back(D->getDepth());
2157 Record.push_back(D->getPosition());
2158
2159 if (D->isExpandedParameterPack()) {
2160 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2161 I != N; ++I)
2162 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2164 } else {
2165 // Rest of TemplateTemplateParmDecl.
2166 Record.push_back(D->isParameterPack());
2167 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2168 !D->defaultArgumentWasInherited();
2169 Record.push_back(OwnsDefaultArg);
2170 if (OwnsDefaultArg)
2171 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2173 }
2174}
2175
2179}
2180
2182 VisitDecl(D);
2183 Record.AddStmt(D->getAssertExpr());
2184 Record.push_back(D->isFailed());
2185 Record.AddStmt(D->getMessage());
2186 Record.AddSourceLocation(D->getRParenLoc());
2188}
2189
2190/// Emit the DeclContext part of a declaration context decl.
2192 static_assert(DeclContext::NumDeclContextBits == 13,
2193 "You need to update the serializer after you change the "
2194 "DeclContextBits");
2195 LookupBlockOffsets Offsets;
2196
2197 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2198 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2199 // In reduced BMI, delay writing lexical and visible block for namespace
2200 // in the global module fragment. See the comments of DelayedNamespace for
2201 // details.
2202 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2203 } else {
2204 Offsets.LexicalOffset =
2205 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2206 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC, Offsets);
2207 }
2208
2209 Record.AddLookupOffsets(Offsets);
2210}
2211
2213 assert(IsLocalDecl(D) && "expected a local declaration");
2214
2215 const Decl *Canon = D->getCanonicalDecl();
2216 if (IsLocalDecl(Canon))
2217 return Canon;
2218
2219 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2220 if (CacheEntry)
2221 return CacheEntry;
2222
2223 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2224 if (IsLocalDecl(Redecl))
2225 D = Redecl;
2226 return CacheEntry = D;
2227}
2228
2229template <typename T>
2231 T *First = D->getFirstDecl();
2232 T *MostRecent = First->getMostRecentDecl();
2233 T *DAsT = static_cast<T *>(D);
2234 if (MostRecent != First) {
2235 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2236 "Not considered redeclarable?");
2237
2238 Record.AddDeclRef(First);
2239
2240 // Write out a list of local redeclarations of this declaration if it's the
2241 // first local declaration in the chain.
2242 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2243 if (DAsT == FirstLocal) {
2244 // Emit a list of all imported first declarations so that we can be sure
2245 // that all redeclarations visible to this module are before D in the
2246 // redecl chain.
2247 unsigned I = Record.size();
2248 Record.push_back(0);
2249 if (Writer.Chain)
2250 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2251 // This is the number of imported first declarations + 1.
2252 Record[I] = Record.size() - I;
2253
2254 // Collect the set of local redeclarations of this declaration, from
2255 // newest to oldest.
2256 ASTWriter::RecordData LocalRedecls;
2257 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2258 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2259 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2260 if (!Prev->isFromASTFile())
2261 LocalRedeclWriter.AddDeclRef(Prev);
2262
2263 // If we have any redecls, write them now as a separate record preceding
2264 // the declaration itself.
2265 if (LocalRedecls.empty())
2266 Record.push_back(0);
2267 else
2268 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2269 } else {
2270 Record.push_back(0);
2271 Record.AddDeclRef(FirstLocal);
2272 }
2273
2274 // Make sure that we serialize both the previous and the most-recent
2275 // declarations, which (transitively) ensures that all declarations in the
2276 // chain get serialized.
2277 //
2278 // FIXME: This is not correct; when we reach an imported declaration we
2279 // won't emit its previous declaration.
2280 (void)Writer.GetDeclRef(D->getPreviousDecl());
2281 (void)Writer.GetDeclRef(MostRecent);
2282 } else {
2283 // We use the sentinel value 0 to indicate an only declaration.
2284 Record.push_back(0);
2285 }
2286}
2287
2291 Record.push_back(D->isCBuffer());
2292 Record.AddSourceLocation(D->getLocStart());
2293 Record.AddSourceLocation(D->getLBraceLoc());
2294 Record.AddSourceLocation(D->getRBraceLoc());
2295
2297}
2298
2300 Record.writeOMPChildren(D->Data);
2301 VisitDecl(D);
2303}
2304
2306 Record.writeOMPChildren(D->Data);
2307 VisitDecl(D);
2309}
2310
2312 Record.writeOMPChildren(D->Data);
2313 VisitDecl(D);
2315}
2316
2319 "You need to update the serializer after you change the "
2320 "NumOMPDeclareReductionDeclBits");
2321
2323 Record.AddSourceLocation(D->getBeginLoc());
2324 Record.AddStmt(D->getCombinerIn());
2325 Record.AddStmt(D->getCombinerOut());
2326 Record.AddStmt(D->getCombiner());
2327 Record.AddStmt(D->getInitOrig());
2328 Record.AddStmt(D->getInitPriv());
2329 Record.AddStmt(D->getInitializer());
2330 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2331 Record.AddDeclRef(D->getPrevDeclInScope());
2333}
2334
2336 Record.writeOMPChildren(D->Data);
2338 Record.AddDeclarationName(D->getVarName());
2339 Record.AddDeclRef(D->getPrevDeclInScope());
2341}
2342
2344 VisitVarDecl(D);
2346}
2347
2349 Record.writeUInt32(D->clauses().size());
2350 VisitDecl(D);
2351 Record.writeEnum(D->DirKind);
2352 Record.AddSourceLocation(D->DirectiveLoc);
2353 Record.AddSourceLocation(D->EndLoc);
2354 Record.writeOpenACCClauseList(D->clauses());
2356}
2358 Record.writeUInt32(D->clauses().size());
2359 VisitDecl(D);
2360 Record.writeEnum(D->DirKind);
2361 Record.AddSourceLocation(D->DirectiveLoc);
2362 Record.AddSourceLocation(D->EndLoc);
2363 Record.AddSourceRange(D->ParensLoc);
2364 Record.AddStmt(D->FuncRef);
2365 Record.writeOpenACCClauseList(D->clauses());
2367}
2368
2369//===----------------------------------------------------------------------===//
2370// ASTWriter Implementation
2371//===----------------------------------------------------------------------===//
2372
2373namespace {
2374template <FunctionDecl::TemplatedKind Kind>
2375std::shared_ptr<llvm::BitCodeAbbrev>
2376getFunctionDeclAbbrev(serialization::DeclCode Code) {
2377 using namespace llvm;
2378
2379 auto Abv = std::make_shared<BitCodeAbbrev>();
2380 Abv->Add(BitCodeAbbrevOp(Code));
2381 // RedeclarableDecl
2382 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2383 Abv->Add(BitCodeAbbrevOp(Kind));
2384 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2385
2386 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2387 // DescribedFunctionTemplate
2388 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2389 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2390 // Instantiated From Decl
2391 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2392 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2393 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2394 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2395 3)); // TemplateSpecializationKind
2396 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2397 } else if constexpr (Kind ==
2399 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2400 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2401 3)); // TemplateSpecializationKind
2402 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2403 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2404 Abv->Add(
2405 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2406 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2407 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2408 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2409 Abv->Add(BitCodeAbbrevOp(0));
2410 Abv->Add(
2411 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2412 } else if constexpr (Kind == FunctionDecl::
2414 // Candidates of specialization
2415 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2416 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2417 } else {
2418 llvm_unreachable("Unknown templated kind?");
2419 }
2420 // Decl
2421 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2422 8)); // Packed DeclBits: ModuleOwnershipKind,
2423 // isUsed, isReferenced, AccessSpecifier,
2424 // isImplicit
2425 //
2426 // The following bits should be 0:
2427 // HasStandaloneLexicalDC, HasAttrs,
2428 // TopLevelDeclInObjCContainer,
2429 // isInvalidDecl
2430 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2431 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2432 // NamedDecl
2433 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2434 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2435 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2436 // ValueDecl
2437 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2438 // DeclaratorDecl
2439 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2440 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2441 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2442 // FunctionDecl
2443 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2444 Abv->Add(BitCodeAbbrevOp(
2445 BitCodeAbbrevOp::Fixed,
2446 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2447 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2448 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2449 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2450 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2451 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2452 // ShouldSkipCheckingODR
2453 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2454 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2455 // This Array slurps the rest of the record. Fortunately we want to encode
2456 // (nearly) all the remaining (variable number of) fields in the same way.
2457 //
2458 // This is:
2459 // NumParams and Params[] from FunctionDecl, and
2460 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2461 //
2462 // Add an AbbrevOp for 'size then elements' and use it here.
2463 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2464 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2465 return Abv;
2466}
2467
2468template <FunctionDecl::TemplatedKind Kind>
2469std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2470 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2471}
2472} // namespace
2473
2474void ASTWriter::WriteDeclAbbrevs() {
2475 using namespace llvm;
2476
2477 std::shared_ptr<BitCodeAbbrev> Abv;
2478
2479 // Abbreviation for DECL_FIELD
2480 Abv = std::make_shared<BitCodeAbbrev>();
2481 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2482 // Decl
2483 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2484 7)); // Packed DeclBits: ModuleOwnershipKind,
2485 // isUsed, isReferenced, AccessSpecifier,
2486 //
2487 // The following bits should be 0:
2488 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2489 // TopLevelDeclInObjCContainer,
2490 // isInvalidDecl
2491 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2492 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2493 // NamedDecl
2494 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2495 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2496 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2497 // ValueDecl
2498 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2499 // DeclaratorDecl
2500 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2501 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2502 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2503 // FieldDecl
2504 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2505 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2506 // Type Source Info
2507 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2508 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2509 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2510
2511 // Abbreviation for DECL_OBJC_IVAR
2512 Abv = std::make_shared<BitCodeAbbrev>();
2513 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2514 // Decl
2515 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2516 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2517 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2518 // isReferenced, TopLevelDeclInObjCContainer,
2519 // AccessSpecifier, ModuleOwnershipKind
2520 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2521 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2522 // NamedDecl
2523 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2524 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2525 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2526 // ValueDecl
2527 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2528 // DeclaratorDecl
2529 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2530 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2531 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2532 // FieldDecl
2533 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2534 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2535 // ObjC Ivar
2536 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2537 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2538 // Type Source Info
2539 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2540 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2541 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2542
2543 // Abbreviation for DECL_ENUM
2544 Abv = std::make_shared<BitCodeAbbrev>();
2545 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2546 // Redeclarable
2547 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2548 // Decl
2549 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2550 7)); // Packed DeclBits: ModuleOwnershipKind,
2551 // isUsed, isReferenced, AccessSpecifier,
2552 //
2553 // The following bits should be 0:
2554 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2555 // TopLevelDeclInObjCContainer,
2556 // isInvalidDecl
2557 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2558 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2559 // NamedDecl
2560 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2561 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2562 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2563 // TypeDecl
2564 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2565 // TagDecl
2566 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2567 Abv->Add(BitCodeAbbrevOp(
2568 BitCodeAbbrevOp::Fixed,
2569 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2570 // EmbeddedInDeclarator, IsFreeStanding,
2571 // isCompleteDefinitionRequired, ExtInfoKind
2572 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2573 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2574 // EnumDecl
2575 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2576 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2577 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2578 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2579 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2580 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2581 // DC
2582 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2583 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2584 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2585 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2586 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2587
2588 // Abbreviation for DECL_RECORD
2589 Abv = std::make_shared<BitCodeAbbrev>();
2590 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2591 // Redeclarable
2592 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2593 // Decl
2594 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2595 7)); // Packed DeclBits: ModuleOwnershipKind,
2596 // isUsed, isReferenced, AccessSpecifier,
2597 //
2598 // The following bits should be 0:
2599 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2600 // TopLevelDeclInObjCContainer,
2601 // isInvalidDecl
2602 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2603 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2604 // NamedDecl
2605 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2606 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2607 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2608 // TypeDecl
2609 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2610 // TagDecl
2611 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2612 Abv->Add(BitCodeAbbrevOp(
2613 BitCodeAbbrevOp::Fixed,
2614 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2615 // EmbeddedInDeclarator, IsFreeStanding,
2616 // isCompleteDefinitionRequired, ExtInfoKind
2617 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2618 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2619 // RecordDecl
2620 Abv->Add(BitCodeAbbrevOp(
2621 BitCodeAbbrevOp::Fixed,
2622 14)); // Packed Record Decl Bits: FlexibleArrayMember,
2623 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2624 // isNonTrivialToPrimitiveDefaultInitialize,
2625 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2626 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2627 // hasNonTrivialToPrimitiveDestructCUnion,
2628 // hasNonTrivialToPrimitiveCopyCUnion,
2629 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2630 // getArgPassingRestrictions
2631 // ODRHash
2632 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2633
2634 // DC
2635 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2636 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2637 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2638 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2639 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2640
2641 // Abbreviation for DECL_PARM_VAR
2642 Abv = std::make_shared<BitCodeAbbrev>();
2643 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2644 // Redeclarable
2645 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2646 // Decl
2647 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2648 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2649 // isReferenced, AccessSpecifier,
2650 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2651 // TopLevelDeclInObjCContainer,
2652 // isInvalidDecl,
2653 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2654 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2655 // NamedDecl
2656 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2657 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2658 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2659 // ValueDecl
2660 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2661 // DeclaratorDecl
2662 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2663 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2664 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2665 // VarDecl
2666 Abv->Add(
2667 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2668 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2669 // isARCPseudoStrong, Linkage, ModulesCodegen
2670 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2671 // ParmVarDecl
2672 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2673 Abv->Add(BitCodeAbbrevOp(
2674 BitCodeAbbrevOp::Fixed,
2675 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2676 // ObjCDeclQualifier, KNRPromoted,
2677 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2678 // Type Source Info
2679 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2680 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2681 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2682
2683 // Abbreviation for DECL_TYPEDEF
2684 Abv = std::make_shared<BitCodeAbbrev>();
2685 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2686 // Redeclarable
2687 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2688 // Decl
2689 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2690 7)); // Packed DeclBits: ModuleOwnershipKind,
2691 // isReferenced, isUsed, AccessSpecifier. Other
2692 // higher bits should be 0: isImplicit,
2693 // HasStandaloneLexicalDC, HasAttrs,
2694 // TopLevelDeclInObjCContainer, isInvalidDecl
2695 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2696 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2697 // NamedDecl
2698 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2699 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2700 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2701 // TypeDecl
2702 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2703 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2704 // TypedefDecl
2705 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2706 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2707 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2708
2709 // Abbreviation for DECL_VAR
2710 Abv = std::make_shared<BitCodeAbbrev>();
2711 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2712 // Redeclarable
2713 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2714 // Decl
2715 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2716 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2717 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2718 // isReferenced, TopLevelDeclInObjCContainer,
2719 // AccessSpecifier, ModuleOwnershipKind
2720 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2721 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2722 // NamedDecl
2723 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2724 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2725 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2726 // ValueDecl
2727 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2728 // DeclaratorDecl
2729 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2730 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2731 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2732 // VarDecl
2733 Abv->Add(BitCodeAbbrevOp(
2734 BitCodeAbbrevOp::Fixed,
2735 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2736 // SClass, TSCSpec, InitStyle,
2737 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2738 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2739 // isInline, isInlineSpecified, isConstexpr,
2740 // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
2741 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2742 // IsCXXForRangeImplicitVar
2743 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2744 // Type Source Info
2745 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2746 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2747 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2748
2749 // Abbreviation for DECL_CXX_METHOD
2750 DeclCXXMethodAbbrev =
2751 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2752 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2753 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2754 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2755 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2756 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2757 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2758 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2759 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2760 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2761 getCXXMethodAbbrev<
2763
2764 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2765 Abv = std::make_shared<BitCodeAbbrev>();
2766 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2767 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2768 // Decl
2769 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2770 7)); // Packed DeclBits: ModuleOwnershipKind,
2771 // isReferenced, isUsed, AccessSpecifier. Other
2772 // higher bits should be 0: isImplicit,
2773 // HasStandaloneLexicalDC, HasAttrs,
2774 // TopLevelDeclInObjCContainer, isInvalidDecl
2775 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2776 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2777 // NamedDecl
2778 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2779 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2780 Abv->Add(BitCodeAbbrevOp(0));
2781 // TypeDecl
2782 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2783 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2784 // TemplateTypeParmDecl
2785 Abv->Add(
2786 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2787 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2788 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2789
2790 // Abbreviation for DECL_USING_SHADOW
2791 Abv = std::make_shared<BitCodeAbbrev>();
2792 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2793 // Redeclarable
2794 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2795 // Decl
2796 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2797 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2798 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2799 // isReferenced, TopLevelDeclInObjCContainer,
2800 // AccessSpecifier, ModuleOwnershipKind
2801 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2802 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2803 // NamedDecl
2804 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2805 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2806 Abv->Add(BitCodeAbbrevOp(0));
2807 // UsingShadowDecl
2808 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2809 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2810 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2811 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2812 6)); // InstantiatedFromUsingShadowDecl
2813 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2814
2815 // Abbreviation for EXPR_DECL_REF
2816 Abv = std::make_shared<BitCodeAbbrev>();
2817 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2818 // Stmt
2819 // Expr
2820 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2821 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2822 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2823 // DeclRefExpr
2824 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2825 // IsImmediateEscalating, NonOdrUseReason.
2826 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2827 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2828 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2829 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2830 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2831
2832 // Abbreviation for EXPR_INTEGER_LITERAL
2833 Abv = std::make_shared<BitCodeAbbrev>();
2834 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2835 //Stmt
2836 // Expr
2837 // DependenceKind, ValueKind, ObjectKind
2838 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2839 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2840 // Integer Literal
2841 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2842 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2843 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2844 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2845
2846 // Abbreviation for EXPR_CHARACTER_LITERAL
2847 Abv = std::make_shared<BitCodeAbbrev>();
2848 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2849 //Stmt
2850 // Expr
2851 // DependenceKind, ValueKind, ObjectKind
2852 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2853 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2854 // Character Literal
2855 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2856 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2857 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2858 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2859
2860 // Abbreviation for EXPR_IMPLICIT_CAST
2861 Abv = std::make_shared<BitCodeAbbrev>();
2862 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2863 // Stmt
2864 // Expr
2865 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2866 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2867 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2868 // CastExpr
2869 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2870 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2871 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2872 // ImplicitCastExpr
2873 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2874
2875 // Abbreviation for EXPR_BINARY_OPERATOR
2876 Abv = std::make_shared<BitCodeAbbrev>();
2877 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2878 // Stmt
2879 // Expr
2880 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2881 // be 0 in this case.
2882 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2883 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2884 // BinaryOperator
2885 Abv->Add(
2886 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2887 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2888 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2889
2890 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2891 Abv = std::make_shared<BitCodeAbbrev>();
2892 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2893 // Stmt
2894 // Expr
2895 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2896 // be 0 in this case.
2897 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2898 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2899 // BinaryOperator
2900 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2901 Abv->Add(
2902 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2903 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2904 // CompoundAssignOperator
2905 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2906 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2907 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2908
2909 // Abbreviation for EXPR_CALL
2910 Abv = std::make_shared<BitCodeAbbrev>();
2911 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2912 // Stmt
2913 // Expr
2914 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2915 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2916 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2917 // CallExpr
2918 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2919 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2920 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2921 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2922
2923 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2924 Abv = std::make_shared<BitCodeAbbrev>();
2925 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2926 // Stmt
2927 // Expr
2928 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2929 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2930 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2931 // CallExpr
2932 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2933 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2934 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2935 // CXXOperatorCallExpr
2936 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
2937 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2938 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2939
2940 // Abbreviation for EXPR_CXX_MEMBER_CALL
2941 Abv = std::make_shared<BitCodeAbbrev>();
2942 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
2943 // Stmt
2944 // Expr
2945 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2946 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2947 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2948 // CallExpr
2949 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2950 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2951 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2952 // CXXMemberCallExpr
2953 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2954
2955 // Abbreviation for STMT_COMPOUND
2956 Abv = std::make_shared<BitCodeAbbrev>();
2957 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
2958 // Stmt
2959 // CompoundStmt
2960 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
2961 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
2962 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2963 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2964 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
2965
2966 Abv = std::make_shared<BitCodeAbbrev>();
2967 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2968 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2969 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2970
2971 Abv = std::make_shared<BitCodeAbbrev>();
2972 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2973 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2974 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2975
2976 Abv = std::make_shared<BitCodeAbbrev>();
2977 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
2978 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2979 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2980
2981 Abv = std::make_shared<BitCodeAbbrev>();
2982 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
2983 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2984 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2985
2986 Abv = std::make_shared<BitCodeAbbrev>();
2987 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
2988 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2989 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2990
2991 Abv = std::make_shared<BitCodeAbbrev>();
2992 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
2993 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2994 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2995}
2996
2997/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2998/// consumers of the AST.
2999///
3000/// Such decls will always be deserialized from the AST file, so we would like
3001/// this to be as restrictive as possible. Currently the predicate is driven by
3002/// code generation requirements, if other clients have a different notion of
3003/// what is "required" then we may have to consider an alternate scheme where
3004/// clients can iterate over the top-level decls and get information on them,
3005/// without necessary deserializing them. We could explicitly require such
3006/// clients to use a separate API call to "realize" the decl. This should be
3007/// relatively painless since they would presumably only do it for top-level
3008/// decls.
3009static bool isRequiredDecl(const Decl *D, ASTContext &Context,
3010 Module *WritingModule) {
3011 // Named modules have different semantics than header modules. Every named
3012 // module units owns a translation unit. So the importer of named modules
3013 // doesn't need to deserilize everything ahead of time.
3014 if (WritingModule && WritingModule->isNamedModule()) {
3015 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
3016 // And the behavior of MSVC for such cases will leak this to the module
3017 // users. Given pragma is not a standard thing, the compiler has the space
3018 // to do their own decision. Let's follow MSVC here.
3019 if (isa<PragmaCommentDecl, PragmaDetectMismatchDecl>(D))
3020 return true;
3021 return false;
3022 }
3023
3024 // An ObjCMethodDecl is never considered as "required" because its
3025 // implementation container always is.
3026
3027 // File scoped assembly or obj-c or OMP declare target implementation must be
3028 // seen.
3029 if (isa<FileScopeAsmDecl, TopLevelStmtDecl, ObjCImplDecl>(D))
3030 return true;
3031
3032 if (WritingModule && isPartOfPerModuleInitializer(D)) {
3033 // These declarations are part of the module initializer, and are emitted
3034 // if and when the module is imported, rather than being emitted eagerly.
3035 return false;
3036 }
3037
3038 return Context.DeclMustBeEmitted(D);
3039}
3040
3041void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
3042 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
3043 "serializing");
3044
3045 // Determine the ID for this declaration.
3047 assert(!D->isFromASTFile() && "should not be emitting imported decl");
3048 LocalDeclID &IDR = DeclIDs[D];
3049 if (IDR.isInvalid())
3050 IDR = NextDeclID++;
3051
3052 ID = IDR;
3053
3054 assert(ID >= FirstDeclID && "invalid decl ID");
3055
3057 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
3058
3059 // Build a record for this declaration
3060 W.Visit(D);
3061
3062 // Emit this declaration to the bitstream.
3063 uint64_t Offset = W.Emit(D);
3064
3065 // Record the offset for this declaration
3068 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
3069
3070 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
3071 if (DeclOffsets.size() == Index)
3072 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
3073 else if (DeclOffsets.size() < Index) {
3074 // FIXME: Can/should this happen?
3075 DeclOffsets.resize(Index+1);
3076 DeclOffsets[Index].setRawLoc(RawLoc);
3077 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
3078 } else {
3079 llvm_unreachable("declarations should be emitted in ID order");
3080 }
3081
3082 SourceManager &SM = Context.getSourceManager();
3083 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
3084 associateDeclWithFile(D, ID);
3085
3086 // Note declarations that should be deserialized eagerly so that we can add
3087 // them to a record in the AST file later.
3088 if (isRequiredDecl(D, Context, WritingModule))
3089 AddDeclRef(D, EagerlyDeserializedDecls);
3090}
3091
3093 // Switch case IDs are per function body.
3094 Writer->ClearSwitchCaseIDs();
3095
3096 assert(FD->doesThisDeclarationHaveABody());
3097 bool ModulesCodegen = shouldFunctionGenerateHereOnly(FD);
3098 Record->push_back(ModulesCodegen);
3099 if (ModulesCodegen)
3100 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3101 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3102 Record->push_back(CD->getNumCtorInitializers());
3103 if (CD->getNumCtorInitializers())
3104 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3105 }
3106 AddStmt(FD->getBody());
3107}
NodeId Parent
Definition: ASTDiff.cpp:191
StringRef P
static void addExplicitSpecifier(ExplicitSpecifier ES, ASTRecordWriter &Record)
static bool shouldVarGenerateHereOnly(const VarDecl *VD)
static bool shouldFunctionGenerateHereOnly(const FunctionDecl *FD)
static bool isRequiredDecl(const Decl *D, ASTContext &Context, Module *WritingModule)
isRequiredDecl - Check if this is a "required" Decl, which must be seen by consumers of the AST.
const Decl * D
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
llvm::MachO::Record Record
Definition: MachO.h:31
#define SM(sm)
Definition: OffloadArch.cpp:16
This file defines OpenMP AST classes for clauses.
SourceLocation Loc
Definition: SemaObjC.cpp:754
Defines the SourceManager interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
SourceManager & getSourceManager()
Definition: ASTContext.h:801
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
const LangOptions & getLangOpts() const
Definition: ASTContext.h:894
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const
MutableArrayRef< FunctionTemplateSpecializationInfo > getPartialSpecializations(FunctionTemplateDecl::Common *)
void VisitBindingDecl(BindingDecl *D)
void VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
void VisitEmptyDecl(EmptyDecl *D)
void VisitCXXMethodDecl(CXXMethodDecl *D)
void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D)
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
void VisitOMPRequiresDecl(OMPRequiresDecl *D)
void VisitNamedDecl(NamedDecl *D)
void CollectFirstDeclFromEachModule(const Decl *D, bool IncludeLocal, llvm::MapVector< ModuleFile *, const Decl * > &Firsts)
Collect the first declaration from each module file that provides a declaration of D.
RedeclarableTemplateDecl::SpecEntryTraits< EntryType >::DeclType * getSpecializationDecl(EntryType &T)
Get the specialization decl from an entry in the specialization list.
void VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
void VisitOpenACCDeclareDecl(OpenACCDeclareDecl *D)
void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D)
void VisitNamespaceDecl(NamespaceDecl *D)
void VisitOMPAllocateDecl(OMPAllocateDecl *D)
void VisitExportDecl(ExportDecl *D)
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
void VisitParmVarDecl(ParmVarDecl *D)
void VisitRedeclarable(Redeclarable< T > *D)
void VisitFriendDecl(FriendDecl *D)
void VisitDeclaratorDecl(DeclaratorDecl *D)
void VisitTemplateParamObjectDecl(TemplateParamObjectDecl *D)
void VisitConceptDecl(ConceptDecl *D)
void AddFirstSpecializationDeclFromEachModule(const Decl *D, llvm::SmallVectorImpl< const Decl * > &SpecsInMap, llvm::SmallVectorImpl< const Decl * > &PartialSpecsInMap)
Add to the record the first template specialization from each module file that provides a declaration...
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
void VisitBlockDecl(BlockDecl *D)
void VisitLabelDecl(LabelDecl *LD)
void VisitTemplateDecl(TemplateDecl *D)
void VisitImplicitConceptSpecializationDecl(ImplicitConceptSpecializationDecl *D)
void VisitCXXDestructorDecl(CXXDestructorDecl *D)
void VisitFieldDecl(FieldDecl *D)
void VisitRequiresExprBodyDecl(RequiresExprBodyDecl *D)
void VisitObjCContainerDecl(ObjCContainerDecl *D)
void RegisterTemplateSpecialization(const Decl *Template, const Decl *Specialization)
Ensure that this template specialization is associated with the specified template on reload.
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
void VisitVarTemplatePartialSpecializationDecl(VarTemplatePartialSpecializationDecl *D)
void VisitUnnamedGlobalConstantDecl(UnnamedGlobalConstantDecl *D)
void VisitCXXConversionDecl(CXXConversionDecl *D)
void VisitUsingShadowDecl(UsingShadowDecl *D)
void VisitValueDecl(ValueDecl *D)
void VisitIndirectFieldDecl(IndirectFieldDecl *D)
void VisitImplicitParamDecl(ImplicitParamDecl *D)
decltype(T::PartialSpecializations) & getPartialSpecializations(T *Common)
Get the list of partial specializations from a template's common ptr.
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
void VisitTopLevelStmtDecl(TopLevelStmtDecl *D)
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
void VisitAccessSpecDecl(AccessSpecDecl *D)
ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, ASTWriter::RecordDataImpl &Record, bool GeneratingReducedBMI)
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
void VisitDecl(Decl *D)
void VisitLifetimeExtendedTemporaryDecl(LifetimeExtendedTemporaryDecl *D)
void VisitMSPropertyDecl(MSPropertyDecl *D)
void VisitUsingEnumDecl(UsingEnumDecl *D)
void VisitTypeDecl(TypeDecl *D)
void VisitClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl *D)
void VisitEnumConstantDecl(EnumConstantDecl *D)
void VisitObjCIvarDecl(ObjCIvarDecl *D)
void VisitCapturedDecl(CapturedDecl *D)
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
void VisitPragmaCommentDecl(PragmaCommentDecl *D)
void VisitRecordDecl(RecordDecl *D)
void VisitUnresolvedUsingIfExistsDecl(UnresolvedUsingIfExistsDecl *D)
void VisitTypedefDecl(TypedefDecl *D)
void VisitMSGuidDecl(MSGuidDecl *D)
void VisitTypedefNameDecl(TypedefNameDecl *D)
void VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
void VisitUsingDecl(UsingDecl *D)
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
void AddTemplateSpecializations(DeclTy *D)
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D)
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
bool shouldSkipWritingSpecializations(T *Spec)
void VisitFriendTemplateDecl(FriendTemplateDecl *D)
void VisitObjCMethodDecl(ObjCMethodDecl *D)
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
uint64_t Emit(Decl *D)
void VisitVarTemplateDecl(VarTemplateDecl *D)
void VisitHLSLBufferDecl(HLSLBufferDecl *D)
void VisitObjCImplDecl(ObjCImplDecl *D)
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D)
void VisitVarDecl(VarDecl *D)
void VisitImportDecl(ImportDecl *D)
void VisitCXXRecordDecl(CXXRecordDecl *D)
void VisitCXXConstructorDecl(CXXConstructorDecl *D)
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D)
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D)
void VisitClassTemplateDecl(ClassTemplateDecl *D)
void VisitFunctionDecl(FunctionDecl *D)
void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
void VisitOpenACCRoutineDecl(OpenACCRoutineDecl *D)
void VisitEnumDecl(EnumDecl *D)
void VisitTranslationUnitDecl(TranslationUnitDecl *D)
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
void VisitStaticAssertDecl(StaticAssertDecl *D)
void VisitDeclContext(DeclContext *DC)
Emit the DeclContext part of a declaration context decl.
void AddObjCTypeParamList(ObjCTypeParamList *typeParams)
Add an Objective-C type parameter list to the given record.
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal)
Add to the record the first declaration from each module file that provides a declaration of D.
void VisitUsingPackDecl(UsingPackDecl *D)
void VisitDecompositionDecl(DecompositionDecl *D)
void VisitOutlinedFunctionDecl(OutlinedFunctionDecl *D)
void VisitTagDecl(TagDecl *D)
void VisitTypeAliasDecl(TypeAliasDecl *D)
void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D)
ModuleFile * getOwningModuleFile(const Decl *D) const
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:8225
bool haveUnloadedSpecializations(const Decl *D) const
If we have any unloaded specialization for D.
Definition: ASTReader.cpp:8802
An object for streaming information to a record.
void AddFunctionDefinition(const FunctionDecl *FD)
Add a definition for the given function to the queue of statements to emit.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer * > CtorInits)
Emit a CXXCtorInitializer array.
Definition: ASTWriter.cpp:7241
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:97
unsigned getDeclParmVarAbbrev() const
Definition: ASTWriter.h:855
unsigned getDeclTemplateTypeParmAbbrev() const
Definition: ASTWriter.h:879
bool isWritingStdCXXNamedModules() const
Definition: ASTWriter.h:903
unsigned getDeclObjCIvarAbbrev() const
Definition: ASTWriter.h:861
unsigned getDeclTypedefAbbrev() const
Definition: ASTWriter.h:857
bool hasChain() const
Definition: ASTWriter.h:898
unsigned getDeclUsingShadowAbbrev() const
Definition: ASTWriter.h:882
bool isGeneratingReducedBMI() const
Definition: ASTWriter.h:911
unsigned getDeclVarAbbrev() const
Definition: ASTWriter.h:858
unsigned getDeclEnumAbbrev() const
Definition: ASTWriter.h:860
bool IsLocalDecl(const Decl *D)
Is this a local declaration (that is, one that will be written to our AST file)? This is the case for...
Definition: ASTWriter.h:775
LocalDeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its local ID to the module file been writing.
Definition: ASTWriter.cpp:6913
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc)
Return the raw encodings for source locations.
Definition: ASTWriter.cpp:6687
unsigned getDeclCXXMethodAbbrev(FunctionDecl::TemplatedKind Kind) const
Definition: ASTWriter.h:862
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
SmallVector< uint64_t, 64 > RecordData
Definition: ASTWriter.h:102
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
Definition: ASTWriter.cpp:7019
unsigned getDeclFieldAbbrev() const
Definition: ASTWriter.h:859
const LangOptions & getLangOpts() const
Definition: ASTWriter.cpp:5438
unsigned getDeclRecordAbbrev() const
Definition: ASTWriter.h:856
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Definition: ASTWriter.cpp:6909
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:86
A binding in a decomposition declaration.
Definition: DeclCXX.h:4179
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
Definition: ASTWriter.h:1063
void addBit(bool Value)
Definition: ASTWriter.h:1083
void addBits(uint32_t Value, uint32_t BitsWidth)
Definition: ASTWriter.h:1084
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4634
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2604
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2937
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1979
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2869
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2129
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
static bool classofKind(Kind K)
Definition: DeclCXX.h:1916
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4906
unsigned getNumParams() const
Definition: Decl.h:4944
unsigned getContextParamPosition() const
Definition: Decl.h:4973
bool isNothrow() const
Definition: Decl.cpp:5569
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4946
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
Declaration of a C++20 concept.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3671
A POD class for pairing a NamedDecl* with an access specifier.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1449
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1358
@ NumOMPDeclareReductionDeclBits
Definition: DeclBase.h:1725
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
Definition: DeclBase.cpp:1951
DeclID getRawValue() const
Definition: DeclID.h:115
bool isInvalid() const
Definition: DeclID.h:123
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:68
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:1061
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:1076
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:435
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:648
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Definition: DeclBase.h:1226
bool hasAttrs() const
Definition: DeclBase.h:518
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:524
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:593
bool isInNamedModule() const
Whether this declaration comes from a named module.
Definition: DeclBase.cpp:1184
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Definition: Decl.cpp:99
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
Definition: DeclBase.h:876
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:244
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: DeclBase.h:1087
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:578
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:984
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:842
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: DeclBase.h:1070
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:793
bool isInvalidDecl() const
Definition: DeclBase.h:588
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:889
SourceLocation getLocation() const
Definition: DeclBase.h:439
const char * getDeclKindName() const
Definition: DeclBase.cpp:147
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
Definition: DeclBase.h:621
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc....
Definition: DeclBase.h:634
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
Definition: DeclBase.cpp:553
DeclContext * getDeclContext()
Definition: DeclBase.h:448
AccessSpecifier getAccess() const
Definition: DeclBase.h:507
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:431
AttrVec & getAttrs()
Definition: DeclBase.h:524
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:918
bool hasAttr() const
Definition: DeclBase.h:577
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:978
Kind getKind() const
Definition: DeclBase.h:442
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:779
A decomposition declaration.
Definition: DeclCXX.h:4243
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:688
ArrayRef< FunctionTemplateDecl * > getCandidates() const
Returns the candidates for the primary function template.
Definition: DeclTemplate.h:707
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:700
Represents an empty-declaration.
Definition: Decl.h:5141
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3420
Represents an enum.
Definition: Decl.h:4004
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1924
ExplicitSpecKind getKind() const
Definition: DeclCXX.h:1932
const Expr * getExpr() const
Definition: DeclCXX.h:1933
Represents a standard C++ module export declaration.
Definition: Decl.h:5094
This represents one expression.
Definition: Expr.h:112
Represents a member of a struct/union/class.
Definition: Decl.h:3157
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition: DeclFriend.h:54
Declaration of a friend template.
Represents a function declaration or definition.
Definition: Decl.h:1999
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:3271
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2325
@ TK_MemberSpecialization
Definition: Decl.h:2011
@ TK_DependentNonTemplate
Definition: Decl.h:2020
@ TK_FunctionTemplateSpecialization
Definition: Decl.h:2015
@ TK_DependentFunctionTemplateSpecialization
Definition: Decl.h:2018
Declaration of a template function.
Definition: DeclTemplate.h:952
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:470
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:484
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:523
MemberSpecializationInfo * getMemberSpecializationInfo() const
Get the specialization info if this function template specialization is also a member specialization:
Definition: DeclTemplate.h:594
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:488
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:554
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:526
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition: Decl.h:5156
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:5015
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3464
Represents the declaration of a label.
Definition: Decl.h:523
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition: DeclCXX.h:3302
Represents a linkage specification.
Definition: DeclCXX.h:3009
A global _GUID constant.
Definition: DeclCXX.h:4392
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4338
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:614
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:636
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
Definition: DeclTemplate.h:654
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:633
Describes a module or submodule.
Definition: Module.h:144
bool isInterfaceOrPartition() const
Definition: Module.h:671
bool isNamedModule() const
Does this Module is a named module of a standard named module?
Definition: Module.h:224
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
Definition: Module.h:722
This represents a decl that may have a name.
Definition: Decl.h:273
Represents a C++ namespace alias.
Definition: DeclCXX.h:3195
Represent a C++ namespace.
Definition: Decl.h:591
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
This represents '#pragma omp allocate ...' directive.
Definition: DeclOpenMP.h:474
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:383
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:287
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:177
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:417
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:110
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:2030
static bool classofKind(Kind K)
Definition: DeclObjC.h:2051
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2329
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2545
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2775
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:948
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2597
Represents an ObjC class declaration.
Definition: DeclObjC.h:1154
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1952
static bool classofKind(Kind K)
Definition: DeclObjC.h:2015
T *const * iterator
Definition: DeclObjC.h:88
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:731
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2805
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2084
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:662
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:689
SourceLocation getRAngleLoc() const
Definition: DeclObjC.h:711
SourceLocation getLAngleLoc() const
Definition: DeclObjC.h:710
Represents a partial function definition.
Definition: Decl.h:4841
Represents a parameter to a function.
Definition: Decl.h:1789
Represents a #pragma comment line.
Definition: Decl.h:166
Represents a #pragma detect_mismatch line.
Definition: Decl.h:200
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
Definition: TypeBase.h:937
Represents a struct/union/class.
Definition: Decl.h:4309
Declaration of a redeclarable template.
Definition: DeclTemplate.h:715
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
Represents the body of a requires-expression.
Definition: DeclCXX.h:2098
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:4130
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1801
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3714
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:286
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Definition: DeclTemplate.h:271
Represents a template argument.
Definition: TemplateBase.h:61
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:296
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:396
A template parameter object.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
A declaration that models statements at global scope.
Definition: Decl.h:4597
The top declaration context.
Definition: Decl.h:104
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3685
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition: ASTConcept.h:223
UnsignedOrNone getArgPackSubstIndex() const
Definition: ASTConcept.h:246
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Definition: ASTConcept.h:240
ConceptReference * getConceptReference() const
Definition: ASTConcept.h:244
Represents a declaration of a type.
Definition: Decl.h:3510
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3664
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3559
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition: DeclCXX.h:4449
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition: DeclCXX.h:4112
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:4031
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3934
Represents a C++ using-declaration.
Definition: DeclCXX.h:3585
Represents C++ using-directive.
Definition: DeclCXX.h:3090
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3786
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition: DeclCXX.h:3867
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3393
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:711
Represents a variable declaration or definition.
Definition: Decl.h:925
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2810
@ CInit
C-style initialization with assignment.
Definition: Decl.h:930
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition: Decl.h:1228
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
RetTy Visit(PTR(Decl) D)
Definition: DeclVisitor.h:38
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
Definition: ASTBitCodes.h:1226
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1234
@ DECL_EMPTY
An EmptyDecl record.
Definition: ASTBitCodes.h:1493
@ DECL_CAPTURED
A CapturedDecl record.
Definition: ASTBitCodes.h:1326
@ DECL_CXX_RECORD
A CXXRecordDecl record.
Definition: ASTBitCodes.h:1395
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1437
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
Definition: ASTBitCodes.h:1490
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
Definition: ASTBitCodes.h:1290
@ DECL_OMP_DECLARE_MAPPER
An OMPDeclareMapperDecl record.
Definition: ASTBitCodes.h:1514
@ DECL_TOP_LEVEL_STMT_DECL
A TopLevelStmtDecl record.
Definition: ASTBitCodes.h:1317
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
Definition: ASTBitCodes.h:1499
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1461
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1470
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1449
@ DECL_IMPORT
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1481
@ DECL_UNNAMED_GLOBAL_CONSTANT
A UnnamedGlobalConstantDecl record.
Definition: ASTBitCodes.h:1520
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1413
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1502
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1272
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1248
@ DECL_PARM_VAR
A ParmVarDecl record.
Definition: ASTBitCodes.h:1305
@ DECL_TYPEDEF
A TypedefDecl record.
Definition: ASTBitCodes.h:1236
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
Definition: ASTBitCodes.h:1478
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
Definition: ASTBitCodes.h:1523
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1362
@ DECL_TYPEALIAS
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1239
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1440
@ DECL_MS_GUID
A MSGuidDecl record.
Definition: ASTBitCodes.h:1293
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1386
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1425
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
Definition: ASTBitCodes.h:1314
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1404
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1410
@ DECL_FIELD
A FieldDecl record.
Definition: ASTBitCodes.h:1287
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1389
@ DECL_CONTEXT_TU_LOCAL_VISIBLE
A record that stores the set of declarations that are only visible to the TU.
Definition: ASTBitCodes.h:1353
@ DECL_NAMESPACE
A NamespaceDecl record.
Definition: ASTBitCodes.h:1359
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1446
@ DECL_USING_PACK
A UsingPackDecl record.
Definition: ASTBitCodes.h:1371
@ DECL_FUNCTION
A FunctionDecl record.
Definition: ASTBitCodes.h:1251
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1380
@ DECL_RECORD
A RecordDecl record.
Definition: ASTBitCodes.h:1245
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
Definition: ASTBitCodes.h:1336
@ DECL_OUTLINEDFUNCTION
A OutlinedFunctionDecl record.
Definition: ASTBitCodes.h:1323
@ DECL_BLOCK
A BlockDecl record.
Definition: ASTBitCodes.h:1320
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1383
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1452
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1269
@ DECL_VAR
A VarDecl record.
Definition: ASTBitCodes.h:1299
@ DECL_UNRESOLVED_USING_IF_EXISTS
An UnresolvedUsingIfExistsDecl record.
Definition: ASTBitCodes.h:1458
@ DECL_USING
A UsingDecl record.
Definition: ASTBitCodes.h:1365
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1260
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1443
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1434
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1275
@ DECL_LABEL
A LabelDecl record.
Definition: ASTBitCodes.h:1356
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1278
@ DECL_CONSTRUCTOR_USING_SHADOW
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1377
@ DECL_USING_ENUM
A UsingEnumDecl record.
Definition: ASTBitCodes.h:1368
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1419
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1511
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
Definition: ASTBitCodes.h:1474
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1266
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1302
@ DECL_FRIEND
A FriendDecl record.
Definition: ASTBitCodes.h:1416
@ DECL_CXX_METHOD
A CXXMethodDecl record.
Definition: ASTBitCodes.h:1401
@ DECL_EXPORT
An ExportDecl record.
Definition: ASTBitCodes.h:1392
@ DECL_BINDING
A BindingDecl record.
Definition: ASTBitCodes.h:1311
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1508
@ DECL_ENUM
An EnumDecl record.
Definition: ASTBitCodes.h:1242
@ DECL_CONTEXT_MODULE_LOCAL_VISIBLE
A record containing the set of declarations that are only visible from DeclContext in the same module...
Definition: ASTBitCodes.h:1349
@ DECL_DECOMPOSITION
A DecompositionDecl record.
Definition: ASTBitCodes.h:1308
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1517
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1484
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
Definition: ASTBitCodes.h:1254
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1407
@ DECL_OMP_CAPTUREDEXPR
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1505
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1422
@ DECL_USING_SHADOW
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1374
@ DECL_CONCEPT
A ConceptDecl record.
Definition: ASTBitCodes.h:1455
@ DECL_CXX_DEDUCTION_GUIDE
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1398
@ DECL_OMP_REQUIRES
An OMPRequiresDecl record.
Definition: ASTBitCodes.h:1487
@ DECL_OBJC_IVAR
A ObjCIvarDecl record.
Definition: ASTBitCodes.h:1263
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1281
@ DECL_TEMPLATE_PARAM_OBJECT
A TemplateParamObjectDecl record.
Definition: ASTBitCodes.h:1296
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1257
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1431
@ DECL_LIFETIME_EXTENDED_TEMPORARY
An LifetimeExtendedTemporaryDecl record.
Definition: ASTBitCodes.h:1496
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1428
@ DECL_IMPLICIT_CONCEPT_SPECIALIZATION
An ImplicitConceptSpecializationDecl record.
Definition: ASTBitCodes.h:1526
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1345
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1284
@ EXPR_COMPOUND_ASSIGN_OPERATOR
A CompoundAssignOperator record.
Definition: ASTBitCodes.h:1679
@ EXPR_CXX_OPERATOR_CALL
A CXXOperatorCallExpr record.
Definition: ASTBitCodes.h:1837
@ EXPR_IMPLICIT_CAST
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1685
@ EXPR_CHARACTER_LITERAL
A CharacterLiteral record.
Definition: ASTBitCodes.h:1646
@ STMT_COMPOUND
A CompoundStmt record.
Definition: ASTBitCodes.h:1565
@ EXPR_CALL
A CallExpr record.
Definition: ASTBitCodes.h:1670
@ EXPR_BINARY_OPERATOR
A BinaryOperator record.
Definition: ASTBitCodes.h:1676
@ EXPR_DECL_REF
A DeclRefExpr record.
Definition: ASTBitCodes.h:1631
@ EXPR_INTEGER_LITERAL
An IntegerLiteral record.
Definition: ASTBitCodes.h:1634
@ EXPR_CXX_MEMBER_CALL
A CXXMemberCallExpr record.
Definition: ASTBitCodes.h:1840
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:366
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:474
bool isPartOfPerModuleInitializer(const Decl *D)
Determine whether the given declaration will be included in the per-module initializer if it needs to...
Definition: ASTCommon.h:92
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition: Address.h:330
@ GVA_StrongExternal
Definition: Linkage.h:76
@ GVA_AvailableExternally
Definition: Linkage.h:74
@ GVA_Internal
Definition: Linkage.h:73
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
@ AS_none
Definition: Specifiers.h:127
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:24
@ SD_Static
Static storage duration.
Definition: Specifiers.h:343
@ Template
We are parsing a template declaration.
@ ExplicitInstantiation
We are parsing an explicit instantiation.
@ VarTemplate
The name was classified as a variable template name.
bool CanElideDeclDef(const Decl *D)
If we can elide the definition of.
const FunctionProtoType * T
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:206
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:202
bool isExternallyVisible(Linkage L)
Definition: Linkage.h:90
unsigned long uint64_t
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:678
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition: Expr.h:6606
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:958
Parts of a decomposed MSGuidDecl.
Definition: DeclCXX.h:4367
uint16_t Part2
...-89ab-...
Definition: DeclCXX.h:4371
uint32_t Part1
{01234567-...
Definition: DeclCXX.h:4369
uint16_t Part3
...-cdef-...
Definition: DeclCXX.h:4373
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition: DeclCXX.h:4375
static DeclType * getDecl(EntryType *D)
Definition: DeclTemplate.h:736