clang 23.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;
50 ASTRecordWriter Record;
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);
82 void VisitTypeDecl(TypeDecl *D);
88 void VisitTagDecl(TagDecl *D);
89 void VisitEnumDecl(EnumDecl *D);
100 void VisitValueDecl(ValueDecl *D);
110 void VisitFieldDecl(FieldDecl *D);
116 void VisitVarDecl(VarDecl *D);
133 void VisitUsingDecl(UsingDecl *D);
148 void VisitBlockDecl(BlockDecl *D);
151 void VisitEmptyDecl(EmptyDecl *D);
154 template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
156
157 // FIXME: Put in the same order is DeclNodes.td?
178
181
182 /// Add an Objective-C type parameter list to the given record.
184 // Empty type parameter list.
185 if (!typeParams) {
186 Record.push_back(0);
187 return;
188 }
189
190 Record.push_back(typeParams->size());
191 for (auto *typeParam : *typeParams) {
192 Record.AddDeclRef(typeParam);
193 }
194 Record.AddSourceLocation(typeParams->getLAngleLoc());
195 Record.AddSourceLocation(typeParams->getRAngleLoc());
196 }
197
198 /// Add to the record the first declaration from each module file that
199 /// provides a declaration of D. The intent is to provide a sufficient
200 /// set such that reloading this set will load all current redeclarations.
201 void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
202 auto Firsts = Writer.CollectFirstDeclFromEachModule(D, IncludeLocal);
203 for (const auto &[_, First] : Firsts)
204 Record.AddDeclRef(First);
205 }
206
207 template <typename T> bool shouldSkipWritingSpecializations(T *Spec) {
208 // Now we will only avoid writing specializations if we're generating
209 // reduced BMI.
210 if (!GeneratingReducedBMI)
211 return false;
212
215
217 if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
218 Args = CTSD->getTemplateArgs().asArray();
219 else if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
220 Args = VTSD->getTemplateArgs().asArray();
221 else
222 Args = cast<FunctionDecl>(Spec)
223 ->getTemplateSpecializationArgs()
224 ->asArray();
225
226 // If there is any template argument is TULocal, we can avoid writing the
227 // specialization since the consumers of reduced BMI won't get the
228 // specialization anyway.
229 for (const TemplateArgument &TA : Args) {
230 switch (TA.getKind()) {
232 Linkage L = TA.getAsType()->getLinkage();
233 if (!isExternallyVisible(L))
234 return true;
235 break;
236 }
238 if (!TA.getAsDecl()->isExternallyVisible())
239 return true;
240 break;
241 default:
242 break;
243 }
244 }
245
246 return false;
247 }
248
249 /// Add to the record the first template specialization from each module
250 /// file that provides a declaration of D. We store the DeclId and an
251 /// ODRHash of the template arguments of D which should provide enough
252 /// information to load D only if the template instantiator needs it.
254 const Decl *D, llvm::SmallVectorImpl<const Decl *> &SpecsInMap,
255 llvm::SmallVectorImpl<const Decl *> &PartialSpecsInMap) {
258 "Must not be called with other decls");
259 auto Firsts =
260 Writer.CollectFirstDeclFromEachModule(D, /*IncludeLocal=*/true);
261 for (const auto &[_, First] : Firsts) {
263 continue;
264
267 PartialSpecsInMap.push_back(First);
268 else
269 SpecsInMap.push_back(First);
270 }
271 }
272
273 /// Get the specialization decl from an entry in the specialization list.
274 template <typename EntryType>
279
280 /// Get the list of partial specializations from a template's common ptr.
281 template<typename T>
282 decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
283 return Common->PartialSpecializations;
284 }
289
290 template<typename DeclTy>
292 auto *Common = D->getCommonPtr();
293
294 // If we have any lazy specializations, and the external AST source is
295 // our chained AST reader, we can just write out the DeclIDs. Otherwise,
296 // we need to resolve them to actual declarations.
297 if (Writer.Chain != Record.getASTContext().getExternalSource() &&
298 Writer.Chain && Writer.Chain->haveUnloadedSpecializations(D)) {
299 D->LoadLazySpecializations();
300 assert(!Writer.Chain->haveUnloadedSpecializations(D));
301 }
302
303 // AddFirstSpecializationDeclFromEachModule might trigger deserialization,
304 // invalidating *Specializations iterators.
306 for (auto &Entry : Common->Specializations)
307 AllSpecs.push_back(getSpecializationDecl(Entry));
308 for (auto &Entry : getPartialSpecializations(Common))
309 AllSpecs.push_back(getSpecializationDecl(Entry));
310
313 for (auto *D : AllSpecs) {
314 assert(D->isCanonicalDecl() && "non-canonical decl in set");
315 AddFirstSpecializationDeclFromEachModule(D, Specs, PartialSpecs);
316 }
317
318 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
319 D, Specs, /*IsPartial=*/false));
320
321 // Function Template Decl doesn't have partial decls.
323 assert(PartialSpecs.empty());
324 return;
325 }
326
327 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
328 D, PartialSpecs, /*IsPartial=*/true));
329 }
330
331 /// Ensure that this template specialization is associated with the specified
332 /// template on reload.
334 const Decl *Specialization) {
335 Template = Template->getCanonicalDecl();
336
337 // If the canonical template is local, we'll write out this specialization
338 // when we emit it.
339 // FIXME: We can do the same thing if there is any local declaration of
340 // the template, to avoid emitting an update record.
341 if (!Template->isFromASTFile())
342 return;
343
344 // We only need to associate the first local declaration of the
345 // specialization. The other declarations will get pulled in by it.
346 if (Writer.getFirstLocalDecl(Specialization) != Specialization)
347 return;
348
351 Writer.PartialSpecializationsUpdates[cast<NamedDecl>(Template)]
352 .push_back(cast<NamedDecl>(Specialization));
353 else
354 Writer.SpecializationsUpdates[cast<NamedDecl>(Template)].push_back(
356 }
357 };
358}
359
360// When building a C++20 module interface unit or a partition unit, a
361// strong definition in the module interface is provided by the
362// compilation of that unit, not by its users. (Inline variables are still
363// emitted in module users.)
364static bool shouldVarGenerateHereOnly(const VarDecl *VD) {
365 if (VD->getStorageDuration() != SD_Static &&
367 return false;
368
369 if (VD->getDescribedVarTemplate())
370 return false;
371
372 Module *M = VD->getOwningModule();
373 if (!M)
374 return false;
375
376 M = M->getTopLevelModule();
377 ASTContext &Ctx = VD->getASTContext();
378 if (!M->isInterfaceOrPartition() &&
379 (!VD->hasAttr<DLLExportAttr>() ||
380 !Ctx.getLangOpts().BuildingPCHWithObjectFile))
381 return false;
382
384}
385
387 if (FD->isDependentContext())
388 return false;
389
390 ASTContext &Ctx = FD->getASTContext();
391 auto Linkage = Ctx.GetGVALinkageForFunction(FD);
392 if (Ctx.getLangOpts().ModulesCodegen ||
393 (FD->hasAttr<DLLExportAttr>() &&
394 Ctx.getLangOpts().BuildingPCHWithObjectFile))
395 // Under -fmodules-codegen, codegen is performed for all non-internal,
396 // non-always_inline functions, unless they are available elsewhere.
397 if (!FD->hasAttr<AlwaysInlineAttr>() && Linkage != GVA_Internal &&
399 return true;
400
401 Module *M = FD->getOwningModule();
402 if (!M)
403 return false;
404
405 M = M->getTopLevelModule();
406 if (M->isInterfaceOrPartition())
408 return true;
409
410 return false;
411}
412
414 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
415 if (FD->isInlined() || FD->isConstexpr() || FD->isConsteval())
416 return false;
417
418 // If the function should be generated somewhere else, we shouldn't elide
419 // it.
421 return false;
422 }
423
424 if (auto *VD = dyn_cast<VarDecl>(D)) {
425 if (VD->getDeclContext()->isDependentContext())
426 return false;
427
428 // Constant initialized variable may not affect the ABI, but they
429 // may be used in constant evaluation in the frontend, so we have
430 // to remain them.
431 if (VD->hasConstantInitialization() || VD->isConstexpr())
432 return false;
433
434 // If the variable should be generated somewhere else, we shouldn't elide
435 // it.
437 return false;
438 }
439
440 return true;
441}
442
445
446 // Source locations require array (variable-length) abbreviations. The
447 // abbreviation infrastructure requires that arrays are encoded last, so
448 // we handle it here in the case of those classes derived from DeclaratorDecl
449 if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
450 if (auto *TInfo = DD->getTypeSourceInfo())
451 Record.AddTypeLoc(TInfo->getTypeLoc());
452 }
453
454 // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
455 // have been written. We want it last because we will not read it back when
456 // retrieving it from the AST, we'll just lazily set the offset.
457 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
458 if (!GeneratingReducedBMI || !CanElideDeclDef(FD)) {
459 Record.push_back(FD->doesThisDeclarationHaveABody());
460 if (FD->doesThisDeclarationHaveABody())
461 Record.AddFunctionDefinition(FD);
462 } else
463 Record.push_back(0);
464 }
465
466 // Similar to FunctionDecls, handle VarDecl's initializer here and write it
467 // after all other Stmts/Exprs. We will not read the initializer until after
468 // we have finished recursive deserialization, because it can recursively
469 // refer back to the variable.
470 if (auto *VD = dyn_cast<VarDecl>(D)) {
471 if (!GeneratingReducedBMI || !CanElideDeclDef(VD))
472 Record.AddVarDeclInit(VD);
473 else
474 Record.push_back(0);
475 }
476
477 // And similarly for FieldDecls. We already serialized whether there is a
478 // default member initializer.
479 if (auto *FD = dyn_cast<FieldDecl>(D)) {
480 if (FD->hasInClassInitializer()) {
481 if (Expr *Init = FD->getInClassInitializer()) {
482 Record.push_back(1);
483 Record.AddStmt(Init);
484 } else {
485 Record.push_back(0);
486 // Initializer has not been instantiated yet.
487 }
488 }
489 }
490
491 // If this declaration is also a DeclContext, write blocks for the
492 // declarations that lexically stored inside its context and those
493 // declarations that are visible from its context.
494 if (auto *DC = dyn_cast<DeclContext>(D))
496}
497
499 BitsPacker DeclBits;
500
501 // The order matters here. It will be better to put the bit with higher
502 // probability to be 0 in the end of the bits.
503 //
504 // Since we're using VBR6 format to store it.
505 // It will be pretty effient if all the higher bits are 0.
506 // For example, if we need to pack 8 bits into a value and the stored value
507 // is 0xf0, the actual stored value will be 0b000111'110000, which takes 12
508 // bits actually. However, if we changed the order to be 0x0f, then we can
509 // store it as 0b001111, which takes 6 bits only now.
510 DeclBits.addBits((uint64_t)D->getModuleOwnershipKind(), /*BitWidth=*/3);
511 DeclBits.addBit(D->isThisDeclarationReferenced());
512 // If we're writing a BMI for a named module unit, we can treat all decls as in
513 // the BMI as used. Otherwise, the consumer need to mark it as used again, this
514 // simply waste time.
515 DeclBits.addBit(Writer.isWritingStdCXXNamedModules() ? true : D->isUsed(false));
516 DeclBits.addBits(D->getAccess(), /*BitWidth=*/2);
517 DeclBits.addBit(D->isImplicit());
518 DeclBits.addBit(D->getDeclContext() != D->getLexicalDeclContext());
519 DeclBits.addBit(D->hasAttrs());
521 DeclBits.addBit(D->isInvalidDecl());
522 Record.push_back(DeclBits);
523
524 Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
525 if (D->getDeclContext() != D->getLexicalDeclContext())
526 Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
527
528 if (D->hasAttrs())
529 Record.AddAttributes(D->getAttrs());
530
531 Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
532
533 // If this declaration injected a name into a context different from its
534 // lexical context, and that context is an imported namespace, we need to
535 // update its visible declarations to include this name.
536 //
537 // This happens when we instantiate a class with a friend declaration or a
538 // function with a local extern declaration, for instance.
539 //
540 // FIXME: Can we handle this in AddedVisibleDecl instead?
541 if (D->isOutOfLine()) {
542 auto *DC = D->getDeclContext();
543 while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
544 if (!NS->isFromASTFile())
545 break;
546 Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
547 if (!NS->isInlineNamespace())
548 break;
549 DC = NS->getParent();
550 }
551 }
552}
553
555 StringRef Arg = D->getArg();
556 Record.push_back(Arg.size());
557 VisitDecl(D);
558 Record.AddSourceLocation(D->getBeginLoc());
559 Record.push_back(D->getCommentKind());
560 Record.AddString(Arg);
562}
563
566 StringRef Name = D->getName();
567 StringRef Value = D->getValue();
568 Record.push_back(Name.size() + 1 + Value.size());
569 VisitDecl(D);
570 Record.AddSourceLocation(D->getBeginLoc());
571 Record.AddString(Name);
572 Record.AddString(Value);
574}
575
577 llvm_unreachable("Translation units aren't directly serialized");
578}
579
581 VisitDecl(D);
582 Record.AddDeclarationName(D->getDeclName());
583 Record.push_back(needsAnonymousDeclarationNumber(D)
584 ? Writer.getAnonymousDeclarationNumber(D)
585 : 0);
586}
587
590 Record.AddSourceLocation(D->getBeginLoc());
592 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
593}
594
597 VisitTypeDecl(D);
598 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
599 Record.push_back(D->isModed());
600 if (D->isModed())
601 Record.AddTypeRef(D->getUnderlyingType());
602 Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
603}
604
607 if (D->getDeclContext() == D->getLexicalDeclContext() &&
608 !D->hasAttrs() &&
609 !D->isImplicit() &&
610 D->getFirstDecl() == D->getMostRecentDecl() &&
611 !D->isInvalidDecl() &&
613 !D->isModulePrivate() &&
616 AbbrevToUse = Writer.getDeclTypedefAbbrev();
617
619}
620
626
628 static_assert(DeclContext::NumTagDeclBits == 23,
629 "You need to update the serializer after you change the "
630 "TagDeclBits");
631
633 VisitTypeDecl(D);
634 Record.push_back(D->getIdentifierNamespace());
635
636 BitsPacker TagDeclBits;
637 TagDeclBits.addBits(llvm::to_underlying(D->getTagKind()), /*BitWidth=*/3);
638 TagDeclBits.addBit(!isa<CXXRecordDecl>(D) ? D->isCompleteDefinition() : 0);
639 TagDeclBits.addBit(D->isEmbeddedInDeclarator());
640 TagDeclBits.addBit(D->isFreeStanding());
641 TagDeclBits.addBit(D->isCompleteDefinitionRequired());
642 TagDeclBits.addBits(
643 D->hasExtInfo() ? 1 : (D->getTypedefNameForAnonDecl() ? 2 : 0),
644 /*BitWidth=*/2);
645 Record.push_back(TagDeclBits);
646
647 Record.AddSourceRange(D->getBraceRange());
648
649 if (D->hasExtInfo()) {
650 Record.AddQualifierInfo(*D->getExtInfo());
651 } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
652 Record.AddDeclRef(TD);
653 Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
654 }
655}
656
658 static_assert(DeclContext::NumEnumDeclBits == 43,
659 "You need to update the serializer after you change the "
660 "EnumDeclBits");
661
662 VisitTagDecl(D);
663 Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
664 if (!D->getIntegerTypeSourceInfo())
665 Record.AddTypeRef(D->getIntegerType());
666 Record.AddTypeRef(D->getPromotionType());
667
668 BitsPacker EnumDeclBits;
669 EnumDeclBits.addBits(D->getNumPositiveBits(), /*BitWidth=*/8);
670 EnumDeclBits.addBits(D->getNumNegativeBits(), /*BitWidth=*/8);
671 EnumDeclBits.addBit(D->isScoped());
672 EnumDeclBits.addBit(D->isScopedUsingClassTag());
673 EnumDeclBits.addBit(D->isFixed());
674 Record.push_back(EnumDeclBits);
675
676 Record.push_back(D->getODRHash());
677
679 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
680 Record.push_back(MemberInfo->getTemplateSpecializationKind());
681 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
682 } else {
683 Record.AddDeclRef(nullptr);
684 }
685
686 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
687 !D->isInvalidDecl() && !D->isImplicit() && !D->hasExtInfo() &&
689 D->getFirstDecl() == D->getMostRecentDecl() &&
695 AbbrevToUse = Writer.getDeclEnumAbbrev();
696
698}
699
701 static_assert(DeclContext::NumRecordDeclBits == 64,
702 "You need to update the serializer after you change the "
703 "RecordDeclBits");
704
705 VisitTagDecl(D);
706
707 BitsPacker RecordDeclBits;
708 RecordDeclBits.addBit(D->hasFlexibleArrayMember());
709 RecordDeclBits.addBit(D->isAnonymousStructOrUnion());
710 RecordDeclBits.addBit(D->hasObjectMember());
711 RecordDeclBits.addBit(D->hasVolatileMember());
713 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveCopy());
714 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDestroy());
717 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveCopyCUnion());
718 RecordDeclBits.addBit(D->hasUninitializedExplicitInitFields());
719 RecordDeclBits.addBit(D->isParamDestroyedInCallee());
720 RecordDeclBits.addBits(llvm::to_underlying(D->getArgPassingRestrictions()), 2);
721 Record.push_back(RecordDeclBits);
722
723 // Only compute this for C/Objective-C, in C++ this is computed as part
724 // of CXXRecordDecl.
725 if (!isa<CXXRecordDecl>(D))
726 Record.push_back(D->getODRHash());
727
728 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
729 !D->isImplicit() && !D->isInvalidDecl() && !D->hasExtInfo() &&
731 D->getFirstDecl() == D->getMostRecentDecl() &&
736 AbbrevToUse = Writer.getDeclRecordAbbrev();
737
739}
740
743 Record.AddTypeRef(D->getType());
744}
745
748 Record.push_back(D->getInitExpr()? 1 : 0);
749 if (D->getInitExpr())
750 Record.AddStmt(D->getInitExpr());
751 Record.AddAPSInt(D->getInitVal());
752
754}
755
758 Record.AddSourceLocation(D->getInnerLocStart());
759 Record.push_back(D->hasExtInfo());
760 if (D->hasExtInfo()) {
761 DeclaratorDecl::ExtInfo *Info = D->getExtInfo();
762 Record.AddQualifierInfo(*Info);
763 Record.AddStmt(
764 const_cast<Expr *>(Info->TrailingRequiresClause.ConstraintExpr));
765 Record.writeUnsignedOrNone(Info->TrailingRequiresClause.ArgPackSubstIndex);
766 }
767 // The location information is deferred until the end of the record.
768 Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType()
769 : QualType());
770}
771
773 static_assert(DeclContext::NumFunctionDeclBits == 45,
774 "You need to update the serializer after you change the "
775 "FunctionDeclBits");
776
778
779 Record.push_back(D->getTemplatedKind());
780 switch (D->getTemplatedKind()) {
782 break;
784 Record.AddDeclRef(D->getInstantiatedFromDecl());
785 break;
787 Record.AddDeclRef(D->getDescribedFunctionTemplate());
788 break;
791 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
792 Record.push_back(MemberInfo->getTemplateSpecializationKind());
793 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
794 break;
795 }
798 FTSInfo = D->getTemplateSpecializationInfo();
799
801
802 Record.AddDeclRef(FTSInfo->getTemplate());
803 Record.push_back(FTSInfo->getTemplateSpecializationKind());
804
805 // Template arguments.
806 Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
807
808 // Template args as written.
809 Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
810 if (FTSInfo->TemplateArgumentsAsWritten)
811 Record.AddASTTemplateArgumentListInfo(
813
814 Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
815
816 if (MemberSpecializationInfo *MemberInfo =
817 FTSInfo->getMemberSpecializationInfo()) {
818 Record.push_back(1);
819 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
820 Record.push_back(MemberInfo->getTemplateSpecializationKind());
821 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
822 } else {
823 Record.push_back(0);
824 }
825
826 if (D->isCanonicalDecl()) {
827 // Write the template that contains the specializations set. We will
828 // add a FunctionTemplateSpecializationInfo to it when reading.
829 Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
830 }
831 break;
832 }
835 DFTSInfo = D->getDependentSpecializationInfo();
836
837 // Candidates.
838 Record.push_back(DFTSInfo->getCandidates().size());
839 for (FunctionTemplateDecl *FTD : DFTSInfo->getCandidates())
840 Record.AddDeclRef(FTD);
841
842 // Templates args.
843 Record.push_back(DFTSInfo->TemplateArgumentsAsWritten != nullptr);
844 if (DFTSInfo->TemplateArgumentsAsWritten)
845 Record.AddASTTemplateArgumentListInfo(
847 break;
848 }
849 }
850
852 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
853 Record.push_back(D->getIdentifierNamespace());
854
855 // The order matters here. It will be better to put the bit with higher
856 // probability to be 0 in the end of the bits. See the comments in VisitDecl
857 // for details.
858 BitsPacker FunctionDeclBits;
859 // FIXME: stable encoding
860 FunctionDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()), 3);
861 FunctionDeclBits.addBits((uint32_t)D->getStorageClass(), /*BitWidth=*/3);
862 FunctionDeclBits.addBit(D->isInlineSpecified());
863 FunctionDeclBits.addBit(D->isInlined());
864 FunctionDeclBits.addBit(D->hasSkippedBody());
865 FunctionDeclBits.addBit(D->isVirtualAsWritten());
866 FunctionDeclBits.addBit(D->isPureVirtual());
867 FunctionDeclBits.addBit(D->hasInheritedPrototype());
868 FunctionDeclBits.addBit(D->hasWrittenPrototype());
869 FunctionDeclBits.addBit(D->isDeletedBit());
870 FunctionDeclBits.addBit(D->isTrivial());
871 FunctionDeclBits.addBit(D->isTrivialForCall());
872 FunctionDeclBits.addBit(D->isDefaulted());
873 FunctionDeclBits.addBit(D->isExplicitlyDefaulted());
874 FunctionDeclBits.addBit(D->isIneligibleOrNotSelected());
875 FunctionDeclBits.addBits((uint64_t)(D->getConstexprKind()), /*BitWidth=*/2);
876 FunctionDeclBits.addBit(D->hasImplicitReturnZero());
877 FunctionDeclBits.addBit(D->isMultiVersion());
878 FunctionDeclBits.addBit(D->isLateTemplateParsed());
879 FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate());
881 FunctionDeclBits.addBit(D->usesSEHTry());
882 FunctionDeclBits.addBit(D->isDestroyingOperatorDelete());
883 FunctionDeclBits.addBit(D->isTypeAwareOperatorNewOrDelete());
884 Record.push_back(FunctionDeclBits);
885
886 Record.AddSourceLocation(D->getEndLoc());
887 if (D->isExplicitlyDefaulted())
888 Record.AddSourceLocation(D->getDefaultLoc());
889
890 Record.push_back(D->getODRHash());
891
892 if (D->isDefaulted() || D->isDeletedAsWritten()) {
893 if (auto *FDI = D->getDefaultedOrDeletedInfo()) {
894 // Store both that there is an DefaultedOrDeletedInfo and whether it
895 // contains a DeletedMessage.
896 StringLiteral *DeletedMessage = FDI->getDeletedMessage();
897 Record.push_back(1 | (DeletedMessage ? 2 : 0));
898 if (DeletedMessage)
899 Record.AddStmt(DeletedMessage);
900
901 Record.push_back(FDI->getUnqualifiedLookups().size());
902 for (DeclAccessPair P : FDI->getUnqualifiedLookups()) {
903 Record.AddDeclRef(P.getDecl());
904 Record.push_back(P.getAccess());
905 }
906 } else {
907 Record.push_back(0);
908 }
909 }
910
911 if (D->getFriendObjectKind()) {
912 // For a friend function defined inline within a class template, we have to
913 // force the definition to be the one inside the definition of the template
914 // class. Remember this relation to deserialize them together.
915 if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent());
916 RD && isDefinitionInDependentContext(RD)) {
917 Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
918 Writer.GetDeclRef(D));
919 }
920 }
921
922 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
923 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
924 Writer.GetDeclRef(EID);
925
926 Record.push_back(D->param_size());
927 for (auto *P : D->parameters())
928 Record.AddDeclRef(P);
930}
931
934 uint64_t Kind = static_cast<uint64_t>(ES.getKind());
935 Kind = Kind << 1 | static_cast<bool>(ES.getExpr());
936 Record.push_back(Kind);
937 if (ES.getExpr()) {
938 Record.AddStmt(ES.getExpr());
939 }
940}
941
944 Record.AddDeclRef(D->Ctor);
946 Record.push_back(static_cast<unsigned char>(D->getDeductionCandidateKind()));
947 Record.AddDeclRef(D->getSourceDeductionGuide());
948 Record.push_back(
949 static_cast<unsigned char>(D->getSourceDeductionGuideKind()));
951}
952
954 static_assert(DeclContext::NumObjCMethodDeclBits == 37,
955 "You need to update the serializer after you change the "
956 "ObjCMethodDeclBits");
957
959 // FIXME: convert to LazyStmtPtr?
960 // Unlike C/C++, method bodies will never be in header files.
961 bool HasBodyStuff = D->getBody() != nullptr;
962 Record.push_back(HasBodyStuff);
963 if (HasBodyStuff) {
964 Record.AddStmt(D->getBody());
965 }
966 Record.AddDeclRef(D->getSelfDecl());
967 Record.AddDeclRef(D->getCmdDecl());
968 Record.push_back(D->isInstanceMethod());
969 Record.push_back(D->isVariadic());
970 Record.push_back(D->isPropertyAccessor());
971 Record.push_back(D->isSynthesizedAccessorStub());
972 Record.push_back(D->isDefined());
973 Record.push_back(D->isOverriding());
974 Record.push_back(D->hasSkippedBody());
975
976 Record.push_back(D->isRedeclaration());
977 Record.push_back(D->hasRedeclaration());
978 if (D->hasRedeclaration()) {
979 assert(Record.getASTContext().getObjCMethodRedeclaration(D));
980 Record.AddDeclRef(Record.getASTContext().getObjCMethodRedeclaration(D));
981 }
982
983 // FIXME: stable encoding for @required/@optional
984 Record.push_back(llvm::to_underlying(D->getImplementationControl()));
985 // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
986 Record.push_back(D->getObjCDeclQualifier());
987 Record.push_back(D->hasRelatedResultType());
988 Record.AddTypeRef(D->getReturnType());
989 Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
990 Record.AddSourceLocation(D->getEndLoc());
991 Record.push_back(D->param_size());
992 for (const auto *P : D->parameters())
993 Record.AddDeclRef(P);
994
995 Record.push_back(D->getSelLocsKind());
996 unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
997 SourceLocation *SelLocs = D->getStoredSelLocs();
998 Record.push_back(NumStoredSelLocs);
999 for (unsigned i = 0; i != NumStoredSelLocs; ++i)
1000 Record.AddSourceLocation(SelLocs[i]);
1001
1003}
1004
1007 Record.push_back(D->Variance);
1008 Record.push_back(D->Index);
1009 Record.AddSourceLocation(D->VarianceLoc);
1010 Record.AddSourceLocation(D->ColonLoc);
1011
1013}
1014
1016 static_assert(DeclContext::NumObjCContainerDeclBits == 64,
1017 "You need to update the serializer after you change the "
1018 "ObjCContainerDeclBits");
1019
1020 VisitNamedDecl(D);
1021 Record.AddSourceLocation(D->getAtStartLoc());
1022 Record.AddSourceRange(D->getAtEndRange());
1023 // Abstract class (no need to define a stable serialization::DECL code).
1024}
1025
1029 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
1030 AddObjCTypeParamList(D->TypeParamList);
1031
1032 Record.push_back(D->isThisDeclarationADefinition());
1034 // Write the DefinitionData
1035 ObjCInterfaceDecl::DefinitionData &Data = D->data();
1036
1037 Record.AddTypeSourceInfo(D->getSuperClassTInfo());
1038 Record.AddSourceLocation(D->getEndOfDefinitionLoc());
1039 Record.push_back(Data.HasDesignatedInitializers);
1040 Record.push_back(D->getODRHash());
1041
1042 // Write out the protocols that are directly referenced by the @interface.
1043 Record.push_back(Data.ReferencedProtocols.size());
1044 for (const auto *P : D->protocols())
1045 Record.AddDeclRef(P);
1046 for (const auto &PL : D->protocol_locs())
1047 Record.AddSourceLocation(PL);
1048
1049 // Write out the protocols that are transitively referenced.
1050 Record.push_back(Data.AllReferencedProtocols.size());
1052 P = Data.AllReferencedProtocols.begin(),
1053 PEnd = Data.AllReferencedProtocols.end();
1054 P != PEnd; ++P)
1055 Record.AddDeclRef(*P);
1056
1057
1058 if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
1059 // Ensure that we write out the set of categories for this class.
1060 Writer.ObjCClassesWithCategories.insert(D);
1061
1062 // Make sure that the categories get serialized.
1063 for (; Cat; Cat = Cat->getNextClassCategoryRaw())
1064 (void)Writer.GetDeclRef(Cat);
1065 }
1066 }
1067
1069}
1070
1072 VisitFieldDecl(D);
1073 // FIXME: stable encoding for @public/@private/@protected/@package
1074 Record.push_back(D->getAccessControl());
1075 Record.push_back(D->getSynthesize());
1076
1077 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1078 !D->hasAttrs() &&
1079 !D->isImplicit() &&
1080 !D->isUsed(false) &&
1081 !D->isInvalidDecl() &&
1082 !D->isReferenced() &&
1083 !D->isModulePrivate() &&
1084 !D->getBitWidth() &&
1085 !D->hasExtInfo() &&
1086 D->getDeclName())
1087 AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
1088
1090}
1091
1095
1096 Record.push_back(D->isThisDeclarationADefinition());
1098 Record.push_back(D->protocol_size());
1099 for (const auto *I : D->protocols())
1100 Record.AddDeclRef(I);
1101 for (const auto &PL : D->protocol_locs())
1102 Record.AddSourceLocation(PL);
1103 Record.push_back(D->getODRHash());
1104 }
1105
1107}
1108
1113
1116 Record.AddSourceLocation(D->getCategoryNameLoc());
1117 Record.AddSourceLocation(D->getIvarLBraceLoc());
1118 Record.AddSourceLocation(D->getIvarRBraceLoc());
1119 Record.AddDeclRef(D->getClassInterface());
1120 AddObjCTypeParamList(D->TypeParamList);
1121 Record.push_back(D->protocol_size());
1122 for (const auto *I : D->protocols())
1123 Record.AddDeclRef(I);
1124 for (const auto &PL : D->protocol_locs())
1125 Record.AddSourceLocation(PL);
1127}
1128
1134
1136 VisitNamedDecl(D);
1137 Record.AddSourceLocation(D->getAtLoc());
1138 Record.AddSourceLocation(D->getLParenLoc());
1139 Record.AddTypeRef(D->getType());
1140 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
1141 // FIXME: stable encoding
1142 Record.push_back((unsigned)D->getPropertyAttributes());
1143 Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
1144 // FIXME: stable encoding
1145 Record.push_back((unsigned)D->getPropertyImplementation());
1146 Record.AddDeclarationName(D->getGetterName());
1147 Record.AddSourceLocation(D->getGetterNameLoc());
1148 Record.AddDeclarationName(D->getSetterName());
1149 Record.AddSourceLocation(D->getSetterNameLoc());
1150 Record.AddDeclRef(D->getGetterMethodDecl());
1151 Record.AddDeclRef(D->getSetterMethodDecl());
1152 Record.AddDeclRef(D->getPropertyIvarDecl());
1154}
1155
1158 Record.AddDeclRef(D->getClassInterface());
1159 // Abstract class (no need to define a stable serialization::DECL code).
1160}
1161
1167
1170 Record.AddDeclRef(D->getSuperClass());
1171 Record.AddSourceLocation(D->getSuperClassLoc());
1172 Record.AddSourceLocation(D->getIvarLBraceLoc());
1173 Record.AddSourceLocation(D->getIvarRBraceLoc());
1174 Record.push_back(D->hasNonZeroConstructors());
1175 Record.push_back(D->hasDestructors());
1176 Record.push_back(D->NumIvarInitializers);
1177 if (D->NumIvarInitializers)
1178 Record.AddCXXCtorInitializers(
1179 llvm::ArrayRef(D->init_begin(), D->init_end()));
1181}
1182
1184 VisitDecl(D);
1185 Record.AddSourceLocation(D->getBeginLoc());
1186 Record.AddDeclRef(D->getPropertyDecl());
1187 Record.AddDeclRef(D->getPropertyIvarDecl());
1188 Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
1189 Record.AddDeclRef(D->getGetterMethodDecl());
1190 Record.AddDeclRef(D->getSetterMethodDecl());
1191 Record.AddStmt(D->getGetterCXXConstructor());
1192 Record.AddStmt(D->getSetterCXXAssignment());
1194}
1195
1198 Record.push_back(D->isMutable());
1199
1200 Record.push_back((D->StorageKind << 1) | D->BitField);
1201 if (D->StorageKind == FieldDecl::ISK_CapturedVLAType)
1202 Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
1203 else if (D->BitField)
1204 Record.AddStmt(D->getBitWidth());
1205
1206 if (!D->getDeclName() || D->isPlaceholderVar(Writer.getLangOpts()))
1207 Record.AddDeclRef(
1208 Record.getASTContext().getInstantiatedFromUnnamedFieldDecl(D));
1209
1210 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1211 !D->hasAttrs() &&
1212 !D->isImplicit() &&
1213 !D->isUsed(false) &&
1214 !D->isInvalidDecl() &&
1215 !D->isReferenced() &&
1217 !D->isModulePrivate() &&
1218 !D->getBitWidth() &&
1219 !D->hasInClassInitializer() &&
1220 !D->hasCapturedVLAType() &&
1221 !D->hasExtInfo() &&
1224 D->getDeclName())
1225 AbbrevToUse = Writer.getDeclFieldAbbrev();
1226
1228}
1229
1232 Record.AddIdentifierRef(D->getGetterId());
1233 Record.AddIdentifierRef(D->getSetterId());
1235}
1236
1238 VisitValueDecl(D);
1239 MSGuidDecl::Parts Parts = D->getParts();
1240 Record.push_back(Parts.Part1);
1241 Record.push_back(Parts.Part2);
1242 Record.push_back(Parts.Part3);
1243 Record.append(std::begin(Parts.Part4And5), std::end(Parts.Part4And5));
1245}
1246
1253
1259
1261 VisitValueDecl(D);
1262 Record.push_back(D->getChainingSize());
1263
1264 for (const auto *P : D->chain())
1265 Record.AddDeclRef(P);
1267}
1268
1272
1273 // The order matters here. It will be better to put the bit with higher
1274 // probability to be 0 in the end of the bits. See the comments in VisitDecl
1275 // for details.
1276 BitsPacker VarDeclBits;
1277 VarDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()),
1278 /*BitWidth=*/3);
1279
1280 bool ModulesCodegen = shouldVarGenerateHereOnly(D);
1281 VarDeclBits.addBit(ModulesCodegen);
1282
1283 VarDeclBits.addBits(D->getStorageClass(), /*BitWidth=*/3);
1284 VarDeclBits.addBits(D->getTSCSpec(), /*BitWidth=*/2);
1285 VarDeclBits.addBits(D->getInitStyle(), /*BitWidth=*/2);
1286 VarDeclBits.addBit(D->isARCPseudoStrong());
1287
1288 bool HasDeducedType = false;
1289 if (!isa<ParmVarDecl>(D)) {
1291 VarDeclBits.addBit(D->isExceptionVariable());
1292 VarDeclBits.addBit(D->isNRVOVariable());
1293 VarDeclBits.addBit(D->isCXXForRangeDecl());
1294
1295 VarDeclBits.addBit(D->isInline());
1296 VarDeclBits.addBit(D->isInlineSpecified());
1297 VarDeclBits.addBit(D->isConstexpr());
1298 VarDeclBits.addBit(D->isInitCapture());
1299 VarDeclBits.addBit(D->isPreviousDeclInSameBlockScope());
1300
1301 VarDeclBits.addBit(D->isEscapingByref());
1302 HasDeducedType = D->getType()->getContainedDeducedType();
1303 VarDeclBits.addBit(HasDeducedType);
1304
1305 if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
1306 VarDeclBits.addBits(llvm::to_underlying(IPD->getParameterKind()),
1307 /*Width=*/3);
1308 else
1309 VarDeclBits.addBits(0, /*Width=*/3);
1310
1311 VarDeclBits.addBit(D->isObjCForDecl());
1312 VarDeclBits.addBit(D->isCXXForRangeImplicitVar());
1313 }
1314
1315 Record.push_back(VarDeclBits);
1316
1317 if (ModulesCodegen)
1318 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1319
1320 if (D->hasAttr<BlocksAttr>()) {
1321 BlockVarCopyInit Init = Record.getASTContext().getBlockVarCopyInit(D);
1322 Record.AddStmt(Init.getCopyExpr());
1323 if (Init.getCopyExpr())
1324 Record.push_back(Init.canThrow());
1325 }
1326
1327 enum {
1328 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1329 };
1330 if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
1331 Record.push_back(VarTemplate);
1332 Record.AddDeclRef(TemplD);
1333 } else if (MemberSpecializationInfo *SpecInfo
1335 Record.push_back(StaticDataMemberSpecialization);
1336 Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
1337 Record.push_back(SpecInfo->getTemplateSpecializationKind());
1338 Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
1339 } else {
1340 Record.push_back(VarNotTemplate);
1341 }
1342
1343 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1347 !D->hasExtInfo() && D->getFirstDecl() == D->getMostRecentDecl() &&
1348 D->getKind() == Decl::Var && !D->isInline() && !D->isConstexpr() &&
1350 !D->hasInitWithSideEffects() && !D->isEscapingByref() &&
1351 !HasDeducedType && D->getStorageDuration() != SD_Static &&
1354 !D->isEscapingByref())
1355 AbbrevToUse = Writer.getDeclVarAbbrev();
1356
1358}
1359
1364
1366 VisitVarDecl(D);
1367
1368 // See the implementation of `ParmVarDecl::getParameterIndex()`, which may
1369 // exceed the size of the normal bitfield. So it may be better to not pack
1370 // these bits.
1371 Record.push_back(D->getFunctionScopeIndex());
1372
1373 BitsPacker ParmVarDeclBits;
1374 ParmVarDeclBits.addBit(D->isObjCMethodParameter());
1375 ParmVarDeclBits.addBits(D->getFunctionScopeDepth(), /*BitsWidth=*/7);
1376 // FIXME: stable encoding
1377 ParmVarDeclBits.addBits(D->getObjCDeclQualifier(), /*BitsWidth=*/7);
1378 ParmVarDeclBits.addBit(D->isKNRPromoted());
1379 ParmVarDeclBits.addBit(D->hasInheritedDefaultArg());
1380 ParmVarDeclBits.addBit(D->hasUninstantiatedDefaultArg());
1381 ParmVarDeclBits.addBit(D->getExplicitObjectParamThisLoc().isValid());
1382 Record.push_back(ParmVarDeclBits);
1383
1385 Record.AddStmt(D->getUninstantiatedDefaultArg());
1387 Record.AddSourceLocation(D->getExplicitObjectParamThisLoc());
1389
1390 // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1391 // we dynamically check for the properties that we optimize for, but don't
1392 // know are true of all PARM_VAR_DECLs.
1393 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1394 !D->hasExtInfo() && D->getStorageClass() == 0 && !D->isInvalidDecl() &&
1396 D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1397 D->getInit() == nullptr) // No default expr.
1398 AbbrevToUse = Writer.getDeclParmVarAbbrev();
1399
1400 // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1401 // just us assuming it.
1402 assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1404 && "PARM_VAR_DECL can't be demoted definition.");
1405 assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1406 assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1407 assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1408 assert(!D->isStaticDataMember() &&
1409 "PARM_VAR_DECL can't be static data member");
1410}
1411
1413 // Record the number of bindings first to simplify deserialization.
1414 Record.push_back(D->bindings().size());
1415
1416 VisitVarDecl(D);
1417 for (auto *B : D->bindings())
1418 Record.AddDeclRef(B);
1420}
1421
1423 VisitValueDecl(D);
1424 Record.AddStmt(D->getBinding());
1426}
1427
1429 VisitDecl(D);
1430 Record.AddStmt(D->getAsmStringExpr());
1431 Record.AddSourceLocation(D->getRParenLoc());
1433}
1434
1440
1445
1448 VisitDecl(D);
1449 Record.AddDeclRef(D->getExtendingDecl());
1450 Record.AddStmt(D->getTemporaryExpr());
1451 Record.push_back(static_cast<bool>(D->getValue()));
1452 if (D->getValue())
1453 Record.AddAPValue(*D->getValue());
1454 Record.push_back(D->getManglingNumber());
1456}
1458 VisitDecl(D);
1459 Record.AddStmt(D->getBody());
1460 Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1461 Record.push_back(D->param_size());
1462 for (ParmVarDecl *P : D->parameters())
1463 Record.AddDeclRef(P);
1464 Record.push_back(D->isVariadic());
1465 Record.push_back(D->blockMissingReturnType());
1466 Record.push_back(D->isConversionFromLambda());
1467 Record.push_back(D->doesNotEscape());
1468 Record.push_back(D->canAvoidCopyToHeap());
1469 Record.push_back(D->capturesCXXThis());
1470 Record.push_back(D->getNumCaptures());
1471 for (const auto &capture : D->captures()) {
1472 Record.AddDeclRef(capture.getVariable());
1473
1474 unsigned flags = 0;
1475 if (capture.isByRef()) flags |= 1;
1476 if (capture.isNested()) flags |= 2;
1477 if (capture.hasCopyExpr()) flags |= 4;
1478 Record.push_back(flags);
1479
1480 if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1481 }
1482
1484}
1485
1487 Record.push_back(D->getNumParams());
1488 VisitDecl(D);
1489 for (unsigned I = 0; I < D->getNumParams(); ++I)
1490 Record.AddDeclRef(D->getParam(I));
1491 Record.push_back(D->isNothrow() ? 1 : 0);
1492 Record.AddStmt(D->getBody());
1494}
1495
1497 Record.push_back(CD->getNumParams());
1498 VisitDecl(CD);
1499 Record.push_back(CD->getContextParamPosition());
1500 Record.push_back(CD->isNothrow() ? 1 : 0);
1501 // Body is stored by VisitCapturedStmt.
1502 for (unsigned I = 0; I < CD->getNumParams(); ++I)
1503 Record.AddDeclRef(CD->getParam(I));
1505}
1506
1508 static_assert(DeclContext::NumLinkageSpecDeclBits == 17,
1509 "You need to update the serializer after you change the"
1510 "LinkageSpecDeclBits");
1511
1512 VisitDecl(D);
1513 Record.push_back(llvm::to_underlying(D->getLanguage()));
1514 Record.AddSourceLocation(D->getExternLoc());
1515 Record.AddSourceLocation(D->getRBraceLoc());
1517}
1518
1520 VisitDecl(D);
1521 Record.AddSourceLocation(D->getRBraceLoc());
1523}
1524
1526 VisitNamedDecl(D);
1527 Record.AddSourceLocation(D->getBeginLoc());
1529}
1530
1531
1534 VisitNamedDecl(D);
1535
1536 BitsPacker NamespaceDeclBits;
1537 NamespaceDeclBits.addBit(D->isInline());
1538 NamespaceDeclBits.addBit(D->isNested());
1539 Record.push_back(NamespaceDeclBits);
1540
1541 Record.AddSourceLocation(D->getBeginLoc());
1542 Record.AddSourceLocation(D->getRBraceLoc());
1543
1544 if (D->isFirstDecl())
1545 Record.AddDeclRef(D->getAnonymousNamespace());
1547
1548 if (Writer.hasChain() && D->isAnonymousNamespace() &&
1549 D == D->getMostRecentDecl()) {
1550 // This is a most recent reopening of the anonymous namespace. If its parent
1551 // is in a previous PCH (or is the TU), mark that parent for update, because
1552 // the original namespace always points to the latest re-opening of its
1553 // anonymous namespace.
1554 Decl *Parent = cast<Decl>(
1556 if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1557 Writer.DeclUpdates[Parent].push_back(
1558 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, D));
1559 }
1560 }
1561}
1562
1565 VisitNamedDecl(D);
1566 Record.AddSourceLocation(D->getNamespaceLoc());
1567 Record.AddSourceLocation(D->getTargetNameLoc());
1568 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1569 Record.AddDeclRef(D->getNamespace());
1571}
1572
1574 VisitNamedDecl(D);
1575 Record.AddSourceLocation(D->getUsingLoc());
1576 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1577 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1578 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1579 Record.push_back(D->hasTypename());
1580 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingDecl(D));
1582}
1583
1585 VisitNamedDecl(D);
1586 Record.AddSourceLocation(D->getUsingLoc());
1587 Record.AddSourceLocation(D->getEnumLoc());
1588 Record.AddTypeSourceInfo(D->getEnumType());
1589 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1590 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingEnumDecl(D));
1592}
1593
1595 Record.push_back(D->NumExpansions);
1596 VisitNamedDecl(D);
1597 Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1598 for (auto *E : D->expansions())
1599 Record.AddDeclRef(E);
1601}
1602
1605 VisitNamedDecl(D);
1606 Record.AddDeclRef(D->getTargetDecl());
1607 Record.push_back(D->getIdentifierNamespace());
1608 Record.AddDeclRef(D->UsingOrNextShadow);
1609 Record.AddDeclRef(
1610 Record.getASTContext().getInstantiatedFromUsingShadowDecl(D));
1611
1612 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1613 D->getFirstDecl() == D->getMostRecentDecl() && !D->hasAttrs() &&
1616 AbbrevToUse = Writer.getDeclUsingShadowAbbrev();
1617
1619}
1620
1624 Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1625 Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1626 Record.push_back(D->IsVirtual);
1628}
1629
1631 VisitNamedDecl(D);
1632 Record.AddSourceLocation(D->getUsingLoc());
1633 Record.AddSourceLocation(D->getNamespaceKeyLocation());
1634 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1635 Record.AddDeclRef(D->getNominatedNamespace());
1636 Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1638}
1639
1641 VisitValueDecl(D);
1642 Record.AddSourceLocation(D->getUsingLoc());
1643 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1644 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1645 Record.AddSourceLocation(D->getEllipsisLoc());
1647}
1648
1651 VisitTypeDecl(D);
1652 Record.AddSourceLocation(D->getTypenameLoc());
1653 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1654 Record.AddSourceLocation(D->getEllipsisLoc());
1656}
1657
1663
1665 VisitRecordDecl(D);
1666
1667 enum {
1668 CXXRecNotTemplate = 0,
1669 CXXRecTemplate,
1670 CXXRecMemberSpecialization,
1671 CXXLambda
1672 };
1673 if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1674 Record.push_back(CXXRecTemplate);
1675 Record.AddDeclRef(TemplD);
1676 } else if (MemberSpecializationInfo *MSInfo
1678 Record.push_back(CXXRecMemberSpecialization);
1679 Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1680 Record.push_back(MSInfo->getTemplateSpecializationKind());
1681 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1682 } else if (D->isLambda()) {
1683 // For a lambda, we need some information early for merging.
1684 Record.push_back(CXXLambda);
1685 if (auto *Context = D->getLambdaContextDecl()) {
1686 Record.AddDeclRef(Context);
1687 Record.push_back(D->getLambdaIndexInContext());
1688 } else {
1689 Record.push_back(0);
1690 }
1691 // For lambdas inside template functions, remember the mapping to
1692 // deserialize them together.
1693 if (auto *FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
1694 FD && isDefinitionInDependentContext(FD)) {
1695 Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
1696 Writer.GetDeclRef(D->getLambdaCallOperator()));
1697 }
1698 } else {
1699 Record.push_back(CXXRecNotTemplate);
1700 }
1701
1702 Record.push_back(D->isThisDeclarationADefinition());
1704 Record.AddCXXDefinitionData(D);
1705
1706 if (D->isCompleteDefinition() && D->isInNamedModule())
1707 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1708
1709 // Store (what we currently believe to be) the key function to avoid
1710 // deserializing every method so we can compute it.
1711 //
1712 // FIXME: Avoid adding the key function if the class is defined in
1713 // module purview since in that case the key function is meaningless.
1714 if (D->isCompleteDefinition())
1715 Record.AddDeclRef(Record.getASTContext().getCurrentKeyFunction(D));
1716
1718}
1719
1722 if (D->isCanonicalDecl()) {
1723 Record.push_back(D->size_overridden_methods());
1724 for (const CXXMethodDecl *MD : D->overridden_methods())
1725 Record.AddDeclRef(MD);
1726 } else {
1727 // We only need to record overridden methods once for the canonical decl.
1728 Record.push_back(0);
1729 }
1730
1731 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1732 D->getFirstDecl() == D->getMostRecentDecl() && !D->isInvalidDecl() &&
1733 !D->hasAttrs() && !D->isTopLevelDeclInObjCContainer() &&
1735 !D->hasExtInfo() && !D->isExplicitlyDefaulted()) {
1740 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1741 else if (D->getTemplatedKind() ==
1745
1746 if (FTSInfo->TemplateArguments->size() == 1) {
1747 const TemplateArgument &TA = FTSInfo->TemplateArguments->get(0);
1748 if (TA.getKind() == TemplateArgument::Type &&
1749 !FTSInfo->TemplateArgumentsAsWritten &&
1750 !FTSInfo->getMemberSpecializationInfo())
1751 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1752 }
1753 } else if (D->getTemplatedKind() ==
1757 if (!DFTSInfo->TemplateArgumentsAsWritten)
1758 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1759 }
1760 }
1761
1763}
1764
1766 static_assert(DeclContext::NumCXXConstructorDeclBits == 64,
1767 "You need to update the serializer after you change the "
1768 "CXXConstructorDeclBits");
1769
1770 Record.push_back(D->getTrailingAllocKind());
1771 addExplicitSpecifier(D->getExplicitSpecifierInternal(), Record);
1772 if (auto Inherited = D->getInheritedConstructor()) {
1773 Record.AddDeclRef(Inherited.getShadowDecl());
1774 Record.AddDeclRef(Inherited.getConstructor());
1775 }
1776
1779}
1780
1783
1784 Record.AddDeclRef(D->getOperatorDelete());
1785 if (D->getOperatorDelete())
1786 Record.AddStmt(D->getOperatorDeleteThisArg());
1787 Record.AddDeclRef(D->getOperatorGlobalDelete());
1788 Record.AddDeclRef(D->getArrayOperatorDelete());
1789 Record.AddDeclRef(D->getGlobalArrayOperatorDelete());
1790
1792}
1793
1799
1801 VisitDecl(D);
1802 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1803 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1804 Record.push_back(!IdentifierLocs.empty());
1805 if (IdentifierLocs.empty()) {
1806 Record.AddSourceLocation(D->getEndLoc());
1807 Record.push_back(1);
1808 } else {
1809 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1810 Record.AddSourceLocation(IdentifierLocs[I]);
1811 Record.push_back(IdentifierLocs.size());
1812 }
1813 // Note: the number of source locations must always be the last element in
1814 // the record.
1816}
1817
1819 VisitDecl(D);
1820 Record.AddSourceLocation(D->getColonLoc());
1822}
1823
1825 // Record the number of friend type template parameter lists here
1826 // so as to simplify memory allocation during deserialization.
1827 Record.push_back(D->NumTPLists);
1828 VisitDecl(D);
1829 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1830 Record.push_back(hasFriendDecl);
1831 if (hasFriendDecl)
1832 Record.AddDeclRef(D->getFriendDecl());
1833 else
1834 Record.AddTypeSourceInfo(D->getFriendType());
1835 for (unsigned i = 0; i < D->NumTPLists; ++i)
1836 Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1837 Record.AddDeclRef(D->getNextFriend());
1838 Record.push_back(D->UnsupportedFriend);
1839 Record.AddSourceLocation(D->FriendLoc);
1840 Record.AddSourceLocation(D->EllipsisLoc);
1842}
1843
1845 VisitDecl(D);
1846 Record.push_back(D->getNumTemplateParameters());
1847 for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1848 Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1849 Record.push_back(D->getFriendDecl() != nullptr);
1850 if (D->getFriendDecl())
1851 Record.AddDeclRef(D->getFriendDecl());
1852 else
1853 Record.AddTypeSourceInfo(D->getFriendType());
1854 Record.AddSourceLocation(D->getFriendLoc());
1856}
1857
1859 VisitNamedDecl(D);
1860
1861 Record.AddTemplateParameterList(D->getTemplateParameters());
1862 Record.AddDeclRef(D->getTemplatedDecl());
1863}
1864
1870
1873 Record.push_back(D->getTemplateArguments().size());
1874 VisitDecl(D);
1875 for (const TemplateArgument &Arg : D->getTemplateArguments())
1876 Record.AddTemplateArgument(Arg);
1878}
1879
1883
1886
1887 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1888 // getCommonPtr() can be used while this is still initializing.
1889 if (D->isFirstDecl()) {
1890 // This declaration owns the 'common' pointer, so serialize that data now.
1891 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1893 Record.push_back(D->isMemberSpecialization());
1894 }
1895
1897 Record.push_back(D->getIdentifierNamespace());
1898}
1899
1902
1903 if (D->isFirstDecl())
1905
1906 // Force emitting the corresponding deduction guide in reduced BMI mode.
1907 // Otherwise, the deduction guide may be optimized out incorrectly.
1908 if (Writer.isGeneratingReducedBMI()) {
1909 auto Name =
1910 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1911 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1912 Writer.GetDeclRef(DG->getCanonicalDecl());
1913 }
1914
1916}
1917
1921
1923
1924 llvm::PointerUnion<ClassTemplateDecl *,
1927 if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1928 Record.AddDeclRef(InstFromD);
1929 } else {
1930 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1931 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1932 }
1933
1934 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1935 Record.AddSourceLocation(D->getPointOfInstantiation());
1936 Record.push_back(D->getSpecializationKind());
1937 Record.push_back(D->hasStrictPackMatch());
1938 Record.push_back(D->isCanonicalDecl());
1939
1940 if (D->isCanonicalDecl()) {
1941 // When reading, we'll add it to the folding set of the following template.
1942 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1943 }
1944
1949 Record.push_back(ExplicitInstantiation);
1951 Record.AddSourceLocation(D->getExternKeywordLoc());
1952 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1953 }
1954
1955 const ASTTemplateArgumentListInfo *ArgsWritten =
1957 Record.push_back(!!ArgsWritten);
1958 if (ArgsWritten)
1959 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1960
1961 // Mention the implicitly generated C++ deduction guide to make sure the
1962 // deduction guide will be rewritten as expected.
1963 //
1964 // FIXME: Would it be more efficient to add a callback register function
1965 // in sema to register the deduction guide?
1966 if (Writer.isWritingStdCXXNamedModules()) {
1967 auto Name =
1968 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
1970 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1971 Writer.GetDeclRef(DG->getCanonicalDecl());
1972 }
1973
1974 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
1975 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
1976 Writer.GetDeclRef(EID);
1977
1979}
1980
1983 Record.AddTemplateParameterList(D->getTemplateParameters());
1984
1986
1987 // These are read/set from/to the first declaration.
1988 if (D->getPreviousDecl() == nullptr) {
1989 Record.AddDeclRef(D->getInstantiatedFromMember());
1990 Record.push_back(D->isMemberSpecialization());
1991 }
1992
1994}
1995
2003
2007
2008 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2009 InstFrom = D->getSpecializedTemplateOrPartial();
2010 if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
2011 Record.AddDeclRef(InstFromD);
2012 } else {
2013 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
2014 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
2015 }
2016
2021 Record.push_back(ExplicitInstantiation);
2023 Record.AddSourceLocation(D->getExternKeywordLoc());
2024 Record.AddSourceLocation(D->getTemplateKeywordLoc());
2025 }
2026
2027 const ASTTemplateArgumentListInfo *ArgsWritten =
2029 Record.push_back(!!ArgsWritten);
2030 if (ArgsWritten)
2031 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
2032
2033 Record.AddTemplateArgumentList(&D->getTemplateArgs());
2034 Record.AddSourceLocation(D->getPointOfInstantiation());
2035 Record.push_back(D->getSpecializationKind());
2036 Record.push_back(D->IsCompleteDefinition);
2037
2038 VisitVarDecl(D);
2039
2040 Record.push_back(D->isCanonicalDecl());
2041
2042 if (D->isCanonicalDecl()) {
2043 // When reading, we'll add it to the folding set of the following template.
2044 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
2045 }
2046
2047 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
2048 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
2049 Writer.GetDeclRef(EID);
2050
2052}
2053
2056 Record.AddTemplateParameterList(D->getTemplateParameters());
2057
2059
2060 // These are read/set from/to the first declaration.
2061 if (D->getPreviousDecl() == nullptr) {
2062 Record.AddDeclRef(D->getInstantiatedFromMember());
2063 Record.push_back(D->isMemberSpecialization());
2064 }
2065
2067}
2068
2076
2078 Record.push_back(D->hasTypeConstraint());
2079 VisitTypeDecl(D);
2080
2081 Record.push_back(D->wasDeclaredWithTypename());
2082
2083 const TypeConstraint *TC = D->getTypeConstraint();
2084 if (D->hasTypeConstraint())
2085 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
2086 if (TC) {
2087 auto *CR = TC->getConceptReference();
2088 Record.push_back(CR != nullptr);
2089 if (CR)
2090 Record.AddConceptReference(CR);
2091 Record.AddStmt(TC->getImmediatelyDeclaredConstraint());
2092 Record.writeUnsignedOrNone(TC->getArgPackSubstIndex());
2093 Record.writeUnsignedOrNone(D->getNumExpansionParameters());
2094 }
2095
2096 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2098 Record.push_back(OwnsDefaultArg);
2099 if (OwnsDefaultArg)
2100 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2101
2102 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
2104 !D->isInvalidDecl() && !D->hasAttrs() &&
2107 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
2108
2110}
2111
2113 // For an expanded parameter pack, record the number of expansion types here
2114 // so that it's easier for deserialization to allocate the right amount of
2115 // memory.
2116 Record.push_back(D->hasPlaceholderTypeConstraint());
2117 if (D->isExpandedParameterPack())
2118 Record.push_back(D->getNumExpansionTypes());
2119
2121 // TemplateParmPosition.
2122 Record.push_back(D->getDepth());
2123 Record.push_back(D->getPosition());
2124
2126 Record.AddStmt(D->getPlaceholderTypeConstraint());
2127
2128 if (D->isExpandedParameterPack()) {
2129 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2130 Record.AddTypeRef(D->getExpansionType(I));
2131 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2132 }
2133
2135 } else {
2136 // Rest of NonTypeTemplateParmDecl.
2137 Record.push_back(D->isParameterPack());
2138 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2140 Record.push_back(OwnsDefaultArg);
2141 if (OwnsDefaultArg)
2142 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2144 }
2145}
2146
2148 // For an expanded parameter pack, record the number of expansion types here
2149 // so that it's easier for deserialization to allocate the right amount of
2150 // memory.
2151 if (D->isExpandedParameterPack())
2152 Record.push_back(D->getNumExpansionTemplateParameters());
2153
2155 Record.push_back(D->templateParameterKind());
2156 Record.push_back(D->wasDeclaredWithTypename());
2157 // TemplateParmPosition.
2158 Record.push_back(D->getDepth());
2159 Record.push_back(D->getPosition());
2160
2161 if (D->isExpandedParameterPack()) {
2162 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2163 I != N; ++I)
2164 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2166 } else {
2167 // Rest of TemplateTemplateParmDecl.
2168 Record.push_back(D->isParameterPack());
2169 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2171 Record.push_back(OwnsDefaultArg);
2172 if (OwnsDefaultArg)
2173 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2175 }
2176}
2177
2182
2184 VisitDecl(D);
2185 Record.AddStmt(D->getAssertExpr());
2186 Record.push_back(D->isFailed());
2187 Record.AddStmt(D->getMessage());
2188 Record.AddSourceLocation(D->getRParenLoc());
2190}
2191
2194 // Trailing-object flags must be the first thing written so the reader can
2195 // allocate the right amount of trailing storage in CreateDeserialized.
2196 unsigned Flags = 0;
2197 if (D->hasTrailingQualifier())
2198 Flags |= ExplicitInstantiationDecl::HasQualifierFlag;
2199 if (D->hasTrailingArgsAsWritten())
2200 Flags |= ExplicitInstantiationDecl::HasArgsAsWrittenFlag;
2201 Record.push_back(Flags);
2202
2203 VisitDecl(D);
2204 Record.AddDeclRef(D->getSpecialization());
2205 Record.AddSourceLocation(D->getExternLoc());
2206 Record.AddSourceLocation(D->getNameLoc());
2207 Record.AddTypeSourceInfo(D->getRawTypeSourceInfo());
2208 Record.push_back(D->getTemplateSpecializationKind());
2209 // Trailing objects.
2210 if (D->hasTrailingQualifier())
2211 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
2212 if (const auto *Args = D->getTrailingArgsInfo())
2213 Record.AddASTTemplateArgumentListInfo(Args);
2215}
2216
2217/// Emit the DeclContext part of a declaration context decl.
2219 static_assert(DeclContext::NumDeclContextBits == 13,
2220 "You need to update the serializer after you change the "
2221 "DeclContextBits");
2222 LookupBlockOffsets Offsets;
2223
2224 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2225 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2226 // In reduced BMI, delay writing lexical and visible block for namespace
2227 // in the global module fragment. See the comments of DelayedNamespace for
2228 // details.
2229 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2230 } else {
2231 Offsets.LexicalOffset =
2232 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2233 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC, Offsets);
2234 }
2235
2236 Record.AddLookupOffsets(Offsets);
2237}
2238
2240 assert(IsLocalDecl(D) && "expected a local declaration");
2241
2242 const Decl *Canon = D->getCanonicalDecl();
2243 if (IsLocalDecl(Canon))
2244 return Canon;
2245
2246 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2247 if (CacheEntry)
2248 return CacheEntry;
2249
2250 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2251 if (IsLocalDecl(Redecl))
2252 D = Redecl;
2253 return CacheEntry = D;
2254}
2255
2256template <typename T>
2258 T *First = D->getFirstDecl();
2259 T *MostRecent = First->getMostRecentDecl();
2260 T *DAsT = static_cast<T *>(D);
2261 if (MostRecent != First) {
2262 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2263 "Not considered redeclarable?");
2264
2265 Record.AddDeclRef(First);
2266
2267 // Write out a list of local redeclarations of this declaration if it's the
2268 // first local declaration in the chain.
2269 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2270 if (DAsT == FirstLocal) {
2271 // Emit a list of all imported first declarations so that we can be sure
2272 // that all redeclarations visible to this module are before D in the
2273 // redecl chain.
2274 unsigned I = Record.size();
2275 Record.push_back(0);
2276 if (Writer.Chain)
2277 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2278 // This is the number of imported first declarations + 1.
2279 Record[I] = Record.size() - I;
2280
2281 // Collect the set of local redeclarations of this declaration, from
2282 // newest to oldest.
2283 ASTWriter::RecordData LocalRedecls;
2284 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2285 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2286 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2287 if (!Prev->isFromASTFile())
2288 LocalRedeclWriter.AddDeclRef(Prev);
2289
2290 // If we have any redecls, write them now as a separate record preceding
2291 // the declaration itself.
2292 if (LocalRedecls.empty())
2293 Record.push_back(0);
2294 else
2295 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2296 } else {
2297 Record.push_back(0);
2298 Record.AddDeclRef(FirstLocal);
2299 }
2300
2301 // Make sure that we serialize both the previous and the most-recent
2302 // declarations, which (transitively) ensures that all declarations in the
2303 // chain get serialized.
2304 //
2305 // FIXME: This is not correct; when we reach an imported declaration we
2306 // won't emit its previous declaration.
2307 (void)Writer.GetDeclRef(D->getPreviousDecl());
2308 (void)Writer.GetDeclRef(MostRecent);
2309 } else {
2310 // We use the sentinel value 0 to indicate an only declaration.
2311 Record.push_back(0);
2312 }
2313}
2314
2316 VisitNamedDecl(D);
2318 Record.push_back(D->isCBuffer());
2319 Record.AddSourceLocation(D->getLocStart());
2320 Record.AddSourceLocation(D->getLBraceLoc());
2321 Record.AddSourceLocation(D->getRBraceLoc());
2322
2324}
2325
2327 Record.writeOMPChildren(D->Data);
2328 VisitDecl(D);
2330}
2331
2333 Record.writeOMPChildren(D->Data);
2334 VisitDecl(D);
2336}
2337
2339 Record.writeOMPChildren(D->Data);
2340 VisitDecl(D);
2342}
2343
2346 "You need to update the serializer after you change the "
2347 "NumOMPDeclareReductionDeclBits");
2348
2349 VisitValueDecl(D);
2350 Record.AddSourceLocation(D->getBeginLoc());
2351 Record.AddStmt(D->getCombinerIn());
2352 Record.AddStmt(D->getCombinerOut());
2353 Record.AddStmt(D->getCombiner());
2354 Record.AddStmt(D->getInitOrig());
2355 Record.AddStmt(D->getInitPriv());
2356 Record.AddStmt(D->getInitializer());
2357 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2358 Record.AddDeclRef(D->getPrevDeclInScope());
2360}
2361
2363 Record.writeOMPChildren(D->Data);
2364 VisitValueDecl(D);
2365 Record.AddDeclarationName(D->getVarName());
2366 Record.AddDeclRef(D->getPrevDeclInScope());
2368}
2369
2374
2376 Record.writeUInt32(D->clauses().size());
2377 VisitDecl(D);
2378 Record.writeEnum(D->DirKind);
2379 Record.AddSourceLocation(D->DirectiveLoc);
2380 Record.AddSourceLocation(D->EndLoc);
2381 Record.writeOpenACCClauseList(D->clauses());
2383}
2385 Record.writeUInt32(D->clauses().size());
2386 VisitDecl(D);
2387 Record.writeEnum(D->DirKind);
2388 Record.AddSourceLocation(D->DirectiveLoc);
2389 Record.AddSourceLocation(D->EndLoc);
2390 Record.AddSourceRange(D->ParensLoc);
2391 Record.AddStmt(D->FuncRef);
2392 Record.writeOpenACCClauseList(D->clauses());
2394}
2395
2396//===----------------------------------------------------------------------===//
2397// ASTWriter Implementation
2398//===----------------------------------------------------------------------===//
2399
2400namespace {
2401template <FunctionDecl::TemplatedKind Kind>
2402std::shared_ptr<llvm::BitCodeAbbrev>
2403getFunctionDeclAbbrev(serialization::DeclCode Code) {
2404 using namespace llvm;
2405
2406 auto Abv = std::make_shared<BitCodeAbbrev>();
2407 Abv->Add(BitCodeAbbrevOp(Code));
2408 // RedeclarableDecl
2409 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2410 Abv->Add(BitCodeAbbrevOp(Kind));
2411 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2412
2413 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2414 // DescribedFunctionTemplate
2415 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2416 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2417 // Instantiated From Decl
2418 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2419 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2420 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2421 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2422 3)); // TemplateSpecializationKind
2423 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2424 } else if constexpr (Kind ==
2426 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2427 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2428 3)); // TemplateSpecializationKind
2429 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2430 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2431 Abv->Add(
2432 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2433 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2434 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2435 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2436 Abv->Add(BitCodeAbbrevOp(0));
2437 Abv->Add(
2438 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2439 } else if constexpr (Kind == FunctionDecl::
2440 TK_DependentFunctionTemplateSpecialization) {
2441 // Candidates of specialization
2442 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2443 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2444 } else {
2445 llvm_unreachable("Unknown templated kind?");
2446 }
2447 // Decl
2448 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2449 8)); // Packed DeclBits: ModuleOwnershipKind,
2450 // isUsed, isReferenced, AccessSpecifier,
2451 // isImplicit
2452 //
2453 // The following bits should be 0:
2454 // HasStandaloneLexicalDC, HasAttrs,
2455 // TopLevelDeclInObjCContainer,
2456 // isInvalidDecl
2457 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2458 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2459 // NamedDecl
2460 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2461 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2462 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2463 // ValueDecl
2464 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2465 // DeclaratorDecl
2466 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2467 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2468 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2469 // FunctionDecl
2470 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2471 Abv->Add(BitCodeAbbrevOp(
2472 BitCodeAbbrevOp::Fixed,
2473 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2474 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2475 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2476 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2477 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2478 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2479 // ShouldSkipCheckingODR
2480 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2481 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2482 // This Array slurps the rest of the record. Fortunately we want to encode
2483 // (nearly) all the remaining (variable number of) fields in the same way.
2484 //
2485 // This is:
2486 // NumParams and Params[] from FunctionDecl, and
2487 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2488 //
2489 // Add an AbbrevOp for 'size then elements' and use it here.
2490 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2491 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2492 return Abv;
2493}
2494
2495template <FunctionDecl::TemplatedKind Kind>
2496std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2497 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2498}
2499} // namespace
2500
2501void ASTWriter::WriteDeclAbbrevs() {
2502 using namespace llvm;
2503
2504 std::shared_ptr<BitCodeAbbrev> Abv;
2505
2506 // Abbreviation for DECL_FIELD
2507 Abv = std::make_shared<BitCodeAbbrev>();
2508 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2509 // Decl
2510 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2511 7)); // Packed DeclBits: ModuleOwnershipKind,
2512 // isUsed, isReferenced, AccessSpecifier,
2513 //
2514 // The following bits should be 0:
2515 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2516 // TopLevelDeclInObjCContainer,
2517 // isInvalidDecl
2518 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2519 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2520 // NamedDecl
2521 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2522 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2523 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2524 // ValueDecl
2525 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2526 // DeclaratorDecl
2527 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2528 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2529 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2530 // FieldDecl
2531 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2532 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2533 // Type Source Info
2534 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2535 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2536 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2537
2538 // Abbreviation for DECL_OBJC_IVAR
2539 Abv = std::make_shared<BitCodeAbbrev>();
2540 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2541 // Decl
2542 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2543 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2544 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2545 // isReferenced, TopLevelDeclInObjCContainer,
2546 // AccessSpecifier, ModuleOwnershipKind
2547 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2548 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2549 // NamedDecl
2550 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2551 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2552 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2553 // ValueDecl
2554 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2555 // DeclaratorDecl
2556 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2557 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2558 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2559 // FieldDecl
2560 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2561 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2562 // ObjC Ivar
2563 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2564 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2565 // Type Source Info
2566 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2567 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2568 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2569
2570 // Abbreviation for DECL_ENUM
2571 Abv = std::make_shared<BitCodeAbbrev>();
2572 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2573 // Redeclarable
2574 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2575 // Decl
2576 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2577 7)); // Packed DeclBits: ModuleOwnershipKind,
2578 // isUsed, isReferenced, AccessSpecifier,
2579 //
2580 // The following bits should be 0:
2581 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2582 // TopLevelDeclInObjCContainer,
2583 // isInvalidDecl
2584 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2585 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2586 // NamedDecl
2587 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2588 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2589 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2590 // TypeDecl
2591 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2592 // TagDecl
2593 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2594 Abv->Add(BitCodeAbbrevOp(
2595 BitCodeAbbrevOp::Fixed,
2596 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2597 // EmbeddedInDeclarator, IsFreeStanding,
2598 // isCompleteDefinitionRequired, ExtInfoKind
2599 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2600 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2601 // EnumDecl
2602 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2603 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2604 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2605 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2606 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2607 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2608 // DC
2609 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2610 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2611 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2612 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2613 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2614
2615 // Abbreviation for DECL_RECORD
2616 Abv = std::make_shared<BitCodeAbbrev>();
2617 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2618 // Redeclarable
2619 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2620 // Decl
2621 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2622 7)); // Packed DeclBits: ModuleOwnershipKind,
2623 // isUsed, isReferenced, AccessSpecifier,
2624 //
2625 // The following bits should be 0:
2626 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2627 // TopLevelDeclInObjCContainer,
2628 // isInvalidDecl
2629 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2630 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2631 // NamedDecl
2632 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2633 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2634 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2635 // TypeDecl
2636 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2637 // TagDecl
2638 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2639 Abv->Add(BitCodeAbbrevOp(
2640 BitCodeAbbrevOp::Fixed,
2641 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2642 // EmbeddedInDeclarator, IsFreeStanding,
2643 // isCompleteDefinitionRequired, ExtInfoKind
2644 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2645 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2646 // RecordDecl
2647 Abv->Add(BitCodeAbbrevOp(
2648 BitCodeAbbrevOp::Fixed,
2649 14)); // Packed Record Decl Bits: FlexibleArrayMember,
2650 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2651 // isNonTrivialToPrimitiveDefaultInitialize,
2652 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2653 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2654 // hasNonTrivialToPrimitiveDestructCUnion,
2655 // hasNonTrivialToPrimitiveCopyCUnion,
2656 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2657 // getArgPassingRestrictions
2658 // ODRHash
2659 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2660
2661 // DC
2662 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2663 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2664 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2665 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2666 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2667
2668 // Abbreviation for DECL_PARM_VAR
2669 Abv = std::make_shared<BitCodeAbbrev>();
2670 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2671 // Redeclarable
2672 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2673 // Decl
2674 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2675 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2676 // isReferenced, AccessSpecifier,
2677 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2678 // TopLevelDeclInObjCContainer,
2679 // isInvalidDecl,
2680 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2681 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2682 // NamedDecl
2683 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2684 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2685 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2686 // ValueDecl
2687 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2688 // DeclaratorDecl
2689 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2690 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2691 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2692 // VarDecl
2693 Abv->Add(
2694 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2695 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2696 // isARCPseudoStrong, Linkage, ModulesCodegen
2697 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2698 // ParmVarDecl
2699 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2700 Abv->Add(BitCodeAbbrevOp(
2701 BitCodeAbbrevOp::Fixed,
2702 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2703 // ObjCDeclQualifier, KNRPromoted,
2704 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2705 // Type Source Info
2706 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2707 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2708 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2709
2710 // Abbreviation for DECL_TYPEDEF
2711 Abv = std::make_shared<BitCodeAbbrev>();
2712 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2713 // Redeclarable
2714 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2715 // Decl
2716 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2717 7)); // Packed DeclBits: ModuleOwnershipKind,
2718 // isReferenced, isUsed, AccessSpecifier. Other
2719 // higher bits should be 0: isImplicit,
2720 // HasStandaloneLexicalDC, HasAttrs,
2721 // TopLevelDeclInObjCContainer, isInvalidDecl
2722 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2723 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2724 // NamedDecl
2725 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2726 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2727 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2728 // TypeDecl
2729 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2730 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2731 // TypedefDecl
2732 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2733 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2734 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2735
2736 // Abbreviation for DECL_VAR
2737 Abv = std::make_shared<BitCodeAbbrev>();
2738 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2739 // Redeclarable
2740 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2741 // Decl
2742 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2743 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2744 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2745 // isReferenced, TopLevelDeclInObjCContainer,
2746 // AccessSpecifier, ModuleOwnershipKind
2747 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2748 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2749 // NamedDecl
2750 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2751 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2752 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2753 // ValueDecl
2754 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2755 // DeclaratorDecl
2756 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2757 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2758 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2759 // VarDecl
2760 Abv->Add(BitCodeAbbrevOp(
2761 BitCodeAbbrevOp::Fixed,
2762 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2763 // SClass, TSCSpec, InitStyle,
2764 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2765 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2766 // isInline, isInlineSpecified, isConstexpr,
2767 // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
2768 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2769 // IsCXXForRangeImplicitVar
2770 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2771 // Type Source Info
2772 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2773 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2774 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2775
2776 // Abbreviation for DECL_CXX_METHOD
2777 DeclCXXMethodAbbrev =
2778 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2779 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2780 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2781 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2782 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2783 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2784 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2785 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2786 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2787 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2788 getCXXMethodAbbrev<
2790
2791 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2792 Abv = std::make_shared<BitCodeAbbrev>();
2793 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2794 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2795 // Decl
2796 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2797 7)); // Packed DeclBits: ModuleOwnershipKind,
2798 // isReferenced, isUsed, AccessSpecifier. Other
2799 // higher bits should be 0: isImplicit,
2800 // HasStandaloneLexicalDC, HasAttrs,
2801 // TopLevelDeclInObjCContainer, isInvalidDecl
2802 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2803 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2804 // NamedDecl
2805 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2806 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2807 Abv->Add(BitCodeAbbrevOp(0));
2808 // TypeDecl
2809 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2810 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2811 // TemplateTypeParmDecl
2812 Abv->Add(
2813 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2814 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2815 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2816
2817 // Abbreviation for DECL_USING_SHADOW
2818 Abv = std::make_shared<BitCodeAbbrev>();
2819 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2820 // Redeclarable
2821 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2822 // Decl
2823 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2824 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2825 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2826 // isReferenced, TopLevelDeclInObjCContainer,
2827 // AccessSpecifier, ModuleOwnershipKind
2828 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2829 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2830 // NamedDecl
2831 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2832 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2833 Abv->Add(BitCodeAbbrevOp(0));
2834 // UsingShadowDecl
2835 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2836 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2837 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2838 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2839 6)); // InstantiatedFromUsingShadowDecl
2840 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2841
2842 // Abbreviation for EXPR_DECL_REF
2843 Abv = std::make_shared<BitCodeAbbrev>();
2844 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2845 // Stmt
2846 // Expr
2847 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2848 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2849 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2850 // DeclRefExpr
2851 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2852 // IsImmediateEscalating, NonOdrUseReason.
2853 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2854 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2855 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2856 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2857 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2858
2859 // Abbreviation for EXPR_INTEGER_LITERAL
2860 Abv = std::make_shared<BitCodeAbbrev>();
2861 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2862 //Stmt
2863 // Expr
2864 // DependenceKind, ValueKind, ObjectKind
2865 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2866 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2867 // Integer Literal
2868 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2869 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2870 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2871 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2872
2873 // Abbreviation for EXPR_CHARACTER_LITERAL
2874 Abv = std::make_shared<BitCodeAbbrev>();
2875 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2876 //Stmt
2877 // Expr
2878 // DependenceKind, ValueKind, ObjectKind
2879 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2880 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2881 // Character Literal
2882 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2883 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2884 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2885 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2886
2887 // Abbreviation for EXPR_IMPLICIT_CAST
2888 Abv = std::make_shared<BitCodeAbbrev>();
2889 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2890 // Stmt
2891 // Expr
2892 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2893 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2894 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2895 // CastExpr
2896 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2897 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2898 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2899 // ImplicitCastExpr
2900 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2901
2902 // Abbreviation for EXPR_BINARY_OPERATOR
2903 Abv = std::make_shared<BitCodeAbbrev>();
2904 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2905 // Stmt
2906 // Expr
2907 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2908 // be 0 in this case.
2909 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2910 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2911 // BinaryOperator
2912 Abv->Add(
2913 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2914 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2915 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2916
2917 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2918 Abv = std::make_shared<BitCodeAbbrev>();
2919 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2920 // Stmt
2921 // Expr
2922 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2923 // be 0 in this case.
2924 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2925 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2926 // BinaryOperator
2927 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2928 Abv->Add(
2929 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2930 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2931 // CompoundAssignOperator
2932 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2933 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2934 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2935
2936 // Abbreviation for EXPR_CALL
2937 Abv = std::make_shared<BitCodeAbbrev>();
2938 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2939 // Stmt
2940 // Expr
2941 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2942 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2943 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2944 // CallExpr
2945 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2946 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2947 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2948 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2949
2950 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2951 Abv = std::make_shared<BitCodeAbbrev>();
2952 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2953 // Stmt
2954 // Expr
2955 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2956 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2957 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2958 // CallExpr
2959 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2960 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2961 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2962 // CXXOperatorCallExpr
2963 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
2964 Abv->Add(BitCodeAbbrevOp(0)); // IsReversed
2965 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2966 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2967
2968 // Abbreviation for EXPR_CXX_MEMBER_CALL
2969 Abv = std::make_shared<BitCodeAbbrev>();
2970 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
2971 // Stmt
2972 // Expr
2973 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2974 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2975 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2976 // CallExpr
2977 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2978 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2979 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2980 // CXXMemberCallExpr
2981 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2982
2983 // Abbreviation for STMT_COMPOUND
2984 Abv = std::make_shared<BitCodeAbbrev>();
2985 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
2986 // Stmt
2987 // CompoundStmt
2988 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
2989 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
2990 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2991 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2992 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
2993
2994 Abv = std::make_shared<BitCodeAbbrev>();
2995 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2996 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2997 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2998
2999 Abv = std::make_shared<BitCodeAbbrev>();
3000 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
3001 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3002 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3003
3004 Abv = std::make_shared<BitCodeAbbrev>();
3005 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
3006 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3007 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3008
3009 Abv = std::make_shared<BitCodeAbbrev>();
3010 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
3011 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3012 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3013
3014 Abv = std::make_shared<BitCodeAbbrev>();
3015 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
3016 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3017 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
3018
3019 Abv = std::make_shared<BitCodeAbbrev>();
3020 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
3021 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3022 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
3023}
3024
3025/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
3026/// consumers of the AST.
3027///
3028/// Such decls will always be deserialized from the AST file, so we would like
3029/// this to be as restrictive as possible. Currently the predicate is driven by
3030/// code generation requirements, if other clients have a different notion of
3031/// what is "required" then we may have to consider an alternate scheme where
3032/// clients can iterate over the top-level decls and get information on them,
3033/// without necessary deserializing them. We could explicitly require such
3034/// clients to use a separate API call to "realize" the decl. This should be
3035/// relatively painless since they would presumably only do it for top-level
3036/// decls.
3037static bool isRequiredDecl(const Decl *D, ASTContext &Context,
3038 Module *WritingModule) {
3039 // Named modules have different semantics than header modules. Every named
3040 // module units owns a translation unit. So the importer of named modules
3041 // doesn't need to deserilize everything ahead of time.
3042 if (WritingModule && WritingModule->isNamedModule()) {
3043 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
3044 // And the behavior of MSVC for such cases will leak this to the module
3045 // users. Given pragma is not a standard thing, the compiler has the space
3046 // to do their own decision. Let's follow MSVC here.
3048 return true;
3049 return false;
3050 }
3051
3052 // An ObjCMethodDecl is never considered as "required" because its
3053 // implementation container always is.
3054
3055 // File scoped assembly or obj-c or OMP declare target implementation must be
3056 // seen.
3058 return true;
3059
3060 if (WritingModule && isPartOfPerModuleInitializer(D)) {
3061 // These declarations are part of the module initializer, and are emitted
3062 // if and when the module is imported, rather than being emitted eagerly.
3063 return false;
3064 }
3065
3066 return Context.DeclMustBeEmitted(D);
3067}
3068
3069void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
3070 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
3071 "serializing");
3072
3073 // Determine the ID for this declaration.
3074 LocalDeclID ID;
3075 assert(!D->isFromASTFile() && "should not be emitting imported decl");
3076 LocalDeclID &IDR = DeclIDs[D];
3077 if (IDR.isInvalid())
3078 IDR = NextDeclID++;
3079
3080 ID = IDR;
3081
3082 assert(ID >= FirstDeclID && "invalid decl ID");
3083
3085 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
3086
3087 // Build a record for this declaration
3088 W.Visit(D);
3089
3090 // Emit this declaration to the bitstream.
3091 uint64_t Offset = W.Emit(D);
3092
3093 // Record the offset for this declaration
3094 SourceLocation Loc = D->getLocation();
3096 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
3097
3098 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
3099 if (DeclOffsets.size() == Index)
3100 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
3101 else if (DeclOffsets.size() < Index) {
3102 // FIXME: Can/should this happen?
3103 DeclOffsets.resize(Index+1);
3104 DeclOffsets[Index].setRawLoc(RawLoc);
3105 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
3106 } else {
3107 llvm_unreachable("declarations should be emitted in ID order");
3108 }
3109
3110 SourceManager &SM = Context.getSourceManager();
3111 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
3112 associateDeclWithFile(D, ID);
3113
3114 // Note declarations that should be deserialized eagerly so that we can add
3115 // them to a record in the AST file later.
3116 if (isRequiredDecl(D, Context, WritingModule))
3117 AddDeclRef(D, EagerlyDeserializedDecls);
3118}
3119
3121 // Switch case IDs are per function body.
3122 Writer->ClearSwitchCaseIDs();
3123
3124 assert(FD->doesThisDeclarationHaveABody());
3125 bool ModulesCodegen = shouldFunctionGenerateHereOnly(FD);
3126 Record->push_back(ModulesCodegen);
3127 if (ModulesCodegen)
3128 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3129 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3130 Record->push_back(CD->getNumCtorInitializers());
3131 if (CD->getNumCtorInitializers())
3132 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3133 }
3134 AddStmt(FD->getBody());
3135}
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.
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)
This file defines OpenMP AST classes for clauses.
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:227
SourceManager & getSourceManager()
Definition ASTContext.h:866
const LangOptions & getLangOpts() const
Definition ASTContext.h:959
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)
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 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 VisitExplicitInstantiationDecl(ExplicitInstantiationDecl *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)
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.
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
bool IsLocalDecl(const Decl *D) const
Is this a local declaration (that is, one that will be written to our AST file)?
Definition ASTWriter.h:785
SmallVectorImpl< uint64_t > RecordDataImpl
Definition ASTWriter.h:103
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc)
Return the raw encodings for source locations.
friend class ASTDeclWriter
Definition ASTWriter.h:99
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
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Represents an access specifier followed by colon ':'.
Definition DeclCXX.h:86
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
Definition DeclCXX.h:108
A binding in a decomposition declaration.
Definition DeclCXX.h:4201
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition DeclCXX.h:4227
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
Definition ASTWriter.h:1086
void addBit(bool Value)
Definition ASTWriter.h:1106
void addBits(uint32_t Value, uint32_t BitsWidth)
Definition ASTWriter.h:1107
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4689
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition Decl.h:4812
bool canAvoidCopyToHeap() const
Definition Decl.h:4843
size_t param_size() const
Definition Decl.h:4791
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition Decl.h:4768
ArrayRef< Capture > captures() const
Definition Decl.h:4816
bool blockMissingReturnType() const
Definition Decl.h:4824
bool capturesCXXThis() const
Definition Decl.h:4821
bool doesNotEscape() const
Definition Decl.h:4840
bool isConversionFromLambda() const
Definition Decl.h:4832
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:4775
bool isVariadic() const
Definition Decl.h:4764
TypeSourceInfo * getSignatureAsWritten() const
Definition Decl.h:4772
Represents a C++ constructor within a class.
Definition DeclCXX.h:2624
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition DeclCXX.h:2862
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2959
ExplicitSpecifier getExplicitSpecifier()
Definition DeclCXX.h:2986
Represents a C++ deduction guide declaration.
Definition DeclCXX.h:1986
const CXXDeductionGuideDecl * getSourceDeductionGuide() const
Get the deduction guide from which this deduction guide was generated, if it was generated as part of...
Definition DeclCXX.h:2062
ExplicitSpecifier getExplicitSpecifier()
Definition DeclCXX.h:2044
DeductionCandidate getDeductionCandidateKind() const
Definition DeclCXX.h:2082
SourceDeductionGuideKind getSourceDeductionGuideKind() const
Definition DeclCXX.h:2070
Represents a C++ destructor within a class.
Definition DeclCXX.h:2889
const FunctionDecl * getOperatorGlobalDelete() const
Definition DeclCXX.cpp:3227
const FunctionDecl * getGlobalArrayOperatorDelete() const
Definition DeclCXX.cpp:3237
const FunctionDecl * getOperatorDelete() const
Definition DeclCXX.cpp:3222
Expr * getOperatorDeleteThisArg() const
Definition DeclCXX.h:2928
const FunctionDecl * getArrayOperatorDelete() const
Definition DeclCXX.cpp:3232
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2136
CXXMethodDecl * getMostRecentDecl()
Definition DeclCXX.h:2252
overridden_method_range overridden_methods() const
Definition DeclCXX.cpp:2830
unsigned size_overridden_methods() const
Definition DeclCXX.cpp:2824
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
Definition DeclCXX.cpp:1834
unsigned getLambdaIndexInContext() const
Retrieve the index of this lambda within the context declaration returned by getLambdaContextDecl().
Definition DeclCXX.h:1799
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition DeclCXX.h:1018
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition DeclCXX.cpp:2060
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition DeclCXX.cpp:2052
static bool classofKind(Kind K)
Definition DeclCXX.h:1923
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
Definition DeclCXX.cpp:2037
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition DeclCXX.cpp:1742
CXXRecordDecl * getPreviousDecl()
Definition DeclCXX.h:530
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4961
unsigned getNumParams() const
Definition Decl.h:4999
unsigned getContextParamPosition() const
Definition Decl.h:5028
bool isNothrow() const
Definition Decl.cpp:5667
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5001
Declaration of a class template.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
bool isMemberSpecialization() const
Determines whether this class template partial specialization template was a specialization of a memb...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition DeclCXX.h:3693
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:1462
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2122
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Definition DeclBase.h:2138
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
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:1074
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition DeclBase.h:1089
SourceLocation getEndLoc() const LLVM_READONLY
Definition DeclBase.h:443
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Definition DeclBase.h:1239
bool hasAttrs() const
Definition DeclBase.h:526
ASTContext & getASTContext() const LLVM_READONLY
Definition DeclBase.cpp:547
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition DeclBase.h:601
bool isInNamedModule() const
Whether this declaration comes from a named module.
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:889
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition DeclBase.cpp:601
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition DeclBase.h:997
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:850
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition DeclBase.h:801
bool isInvalidDecl() const
Definition DeclBase.h:596
unsigned getIdentifierNamespace() const
Definition DeclBase.h:902
SourceLocation getLocation() const
Definition DeclBase.h:447
const char * getDeclKindName() const
Definition DeclBase.cpp:169
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
Definition DeclBase.h:629
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc....
Definition DeclBase.h:642
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
Definition DeclBase.cpp:576
DeclContext * getDeclContext()
Definition DeclBase.h:456
AccessSpecifier getAccess() const
Definition DeclBase.h:515
SourceLocation getBeginLoc() const LLVM_READONLY
Definition DeclBase.h:439
AttrVec & getAttrs()
Definition DeclBase.h:532
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition DeclBase.h:931
bool hasAttr() const
Definition DeclBase.h:585
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:991
Kind getKind() const
Definition DeclBase.h:450
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:780
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:822
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:809
A decomposition declaration.
Definition DeclCXX.h:4265
ArrayRef< BindingDecl * > bindings() const
Definition DeclCXX.h:4303
Provides information about a dependent function-template specialization declaration.
ArrayRef< FunctionTemplateDecl * > getCandidates() const
Returns the candidates for the primary function template.
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Represents an empty-declaration.
Definition Decl.h:5196
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3438
llvm::APSInt getInitVal() const
Definition Decl.h:3458
const Expr * getInitExpr() const
Definition Decl.h:3456
Represents an enum.
Definition Decl.h:4028
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition Decl.h:4300
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4246
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition Decl.h:4238
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4249
unsigned getODRHash()
Definition Decl.cpp:5133
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Definition Decl.h:4217
EnumDecl * getMostRecentDecl()
Definition Decl.h:4133
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition Decl.h:4255
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition Decl.h:4201
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
Definition Decl.h:4227
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition Decl.h:4193
Represents an explicit instantiation of a template entity in source code.
TemplateSpecializationKind getTemplateSpecializationKind() const
SourceLocation getExternLoc() const
bool hasTrailingQualifier() const
Whether the qualifier is stored as a trailing object (function / variable templates) rather than insi...
NamedDecl * getSpecialization() const
NestedNameSpecifierLoc getQualifierLoc() const
Returns the qualifier regardless of where it is stored.
SourceLocation getNameLoc() const
Store information needed for an explicit specifier.
Definition DeclCXX.h:1931
ExplicitSpecKind getKind() const
Definition DeclCXX.h:1939
const Expr * getExpr() const
Definition DeclCXX.h:1940
Represents a standard C++ module export declaration.
Definition Decl.h:5149
SourceLocation getRBraceLoc() const
Definition Decl.h:5168
This represents one expression.
Definition Expr.h:112
Represents a member of a struct/union/class.
Definition Decl.h:3175
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition Decl.h:3275
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition Decl.h:3355
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition Decl.h:3394
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
Definition Decl.h:3291
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition Decl.h:3399
const Expr * getAsmStringExpr() const
Definition Decl.h:4637
SourceLocation getRParenLoc() const
Definition Decl.h:4631
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition DeclFriend.h:54
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
Definition DeclFriend.h:133
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition DeclFriend.h:139
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition DeclFriend.h:125
Declaration of a friend template.
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
NamedDecl * getFriendDecl() const
If this friend declaration names a templated function (or a member function of a templated type),...
TemplateParameterList * getTemplateParameterList(unsigned i) const
unsigned getNumTemplateParameters() const
TypeSourceInfo * getFriendType() const
If this friend declaration names a templated type (or a dependent member type of a templated type),...
Represents a function declaration or definition.
Definition Decl.h:2015
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Definition Decl.h:2704
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition Decl.cpp:3245
bool isTrivialForCall() const
Definition Decl.h:2395
ConstexprSpecKind getConstexprKind() const
Definition Decl.h:2491
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
Definition Decl.cpp:3160
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition Decl.cpp:4159
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
Definition Decl.cpp:3517
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
Definition Decl.h:2936
SourceLocation getDefaultLoc() const
Definition Decl.h:2413
bool usesSEHTry() const
Indicates the function uses __try.
Definition Decl.h:2533
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2789
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
Definition Decl.h:2404
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition Decl.h:2392
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Definition Decl.h:2463
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
Definition Decl.cpp:4138
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition Decl.cpp:4289
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition Decl.h:2341
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition Decl.cpp:4355
unsigned getODRHash()
Returns ODRHash of the function.
Definition Decl.cpp:4645
@ TK_FunctionTemplateSpecialization
Definition Decl.h:2031
@ TK_DependentFunctionTemplateSpecialization
Definition Decl.h:2034
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:2903
bool FriendConstraintRefersToEnclosingTemplate() const
Definition Decl.h:2722
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition Decl.cpp:4110
bool isDeletedAsWritten() const
Definition Decl.h:2559
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
Definition Decl.h:2368
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition Decl.h:2372
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
Definition Decl.h:2443
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Definition Decl.h:2694
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
Definition Decl.cpp:3525
bool isDefaulted() const
Whether this function is defaulted.
Definition Decl.h:2400
bool isIneligibleOrNotSelected() const
Definition Decl.h:2433
FunctionDecl * getInstantiatedFromDecl() const
Definition Decl.cpp:4183
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition Decl.h:2359
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition Decl.h:2474
size_t param_size() const
Definition Decl.h:2805
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition Decl.h:2914
bool isInstantiatedFromMemberTemplate() const
Definition Decl.h:2381
Declaration of a template function.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
MemberSpecializationInfo * getMemberSpecializationInfo() const
Get the specialization info if this function template specialization is also a member specialization:
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition Decl.h:5211
bool isCBuffer() const
Definition Decl.h:5255
SourceLocation getLBraceLoc() const
Definition Decl.h:5252
SourceLocation getLocStart() const LLVM_READONLY
Definition Decl.h:5251
SourceLocation getRBraceLoc() const
Definition Decl.h:5253
ArrayRef< TemplateArgument > getTemplateArguments() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5070
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
Definition Decl.cpp:6036
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition Decl.h:5128
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3482
unsigned getChainingSize() const
Definition Decl.h:3507
ArrayRef< NamedDecl * > chain() const
Definition Decl.h:3503
Represents the declaration of a label.
Definition Decl.h:524
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition DeclCXX.h:3324
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition DeclCXX.h:3370
Represents a linkage specification.
Definition DeclCXX.h:3031
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition DeclCXX.h:3054
SourceLocation getExternLoc() const
Definition DeclCXX.h:3070
SourceLocation getRBraceLoc() const
Definition DeclCXX.h:3071
A global _GUID constant.
Definition DeclCXX.h:4414
Parts getParts() const
Get the decomposed parts of this declaration.
Definition DeclCXX.h:4444
MSGuidDeclParts Parts
Definition DeclCXX.h:4416
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4360
IdentifierInfo * getGetterId() const
Definition DeclCXX.h:4382
IdentifierInfo * getSetterId() const
Definition DeclCXX.h:4384
Provides information a specialization of a member of a class template, which may be a member function...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Describes a module or submodule.
Definition Module.h:237
bool isInterfaceOrPartition() const
Definition Module.h:768
bool isNamedModule() const
Does this Module is a named module of a standard named module?
Definition Module.h:320
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
Definition Module.h:819
This represents a decl that may have a name.
Definition Decl.h:274
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition DeclBase.h:656
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition Decl.cpp:1182
bool isPlaceholderVar(const LangOptions &LangOpts) const
Definition Decl.cpp:1095
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:340
Represents a C++ namespace alias.
Definition DeclCXX.h:3217
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3278
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3303
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition DeclCXX.h:3306
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition DeclCXX.h:3287
Represent a C++ namespace.
Definition Decl.h:592
SourceLocation getRBraceLoc() const
Definition Decl.h:692
NamespaceDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:691
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition Decl.h:643
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition Decl.h:648
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
Definition Decl.h:675
bool isNested() const
Returns true if this is a nested namespace declaration.
Definition Decl.h:657
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
bool hasPlaceholderTypeConstraint() const
Determine whether this non-type template parameter's type has a placeholder with a type-constraint.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
This represents 'pragma omp allocate ...' directive.
Definition DeclOpenMP.h:536
Pseudo declaration for capturing expressions.
Definition DeclOpenMP.h:445
OMPChildren * Data
Data, associated with the directive.
Definition DeclOpenMP.h:43
This represents 'pragma omp declare mapper ...' directive.
Definition DeclOpenMP.h:349
OMPDeclareMapperDecl * getPrevDeclInScope()
Get reference to previous declare mapper construct in the same scope with the same name.
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
Definition DeclOpenMP.h:421
This represents 'pragma omp declare reduction ...' directive.
Definition DeclOpenMP.h:239
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition DeclOpenMP.h:300
Expr * getInitPriv()
Get Priv variable of the initializer.
Definition DeclOpenMP.h:311
Expr * getCombinerOut()
Get Out variable of the combiner.
Definition DeclOpenMP.h:288
Expr * getCombinerIn()
Get In variable of the combiner.
Definition DeclOpenMP.h:285
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition DeclOpenMP.h:282
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name.
Expr * getInitOrig()
Get Orig variable of the initializer.
Definition DeclOpenMP.h:308
OMPDeclareReductionInitKind getInitializerKind() const
Get initializer kind.
Definition DeclOpenMP.h:303
This represents 'pragma omp requires...' directive.
Definition DeclOpenMP.h:479
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
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:2417
unsigned protocol_size() const
Definition DeclObjC.h:2412
ObjCInterfaceDecl * getClassInterface()
Definition DeclObjC.h:2372
SourceLocation getIvarLBraceLoc() const
Definition DeclObjC.h:2464
SourceLocation getIvarRBraceLoc() const
Definition DeclObjC.h:2466
protocol_range protocols() const
Definition DeclObjC.h:2403
SourceLocation getCategoryNameLoc() const
Definition DeclObjC.h:2460
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition DeclObjC.h:2545
SourceLocation getCategoryNameLoc() const
Definition DeclObjC.h:2572
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition DeclObjC.h:2775
const ObjCInterfaceDecl * getClassInterface() const
Definition DeclObjC.h:2793
ObjCContainerDecl - Represents a container for method declarations.
Definition DeclObjC.h:948
SourceRange getAtEndRange() const
Definition DeclObjC.h:1103
SourceLocation getAtStartLoc() const
Definition DeclObjC.h:1096
const ObjCInterfaceDecl * getClassInterface() const
Definition DeclObjC.h:2486
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition DeclObjC.h:2597
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition DeclObjC.h:2678
SourceLocation getIvarRBraceLoc() const
Definition DeclObjC.h:2744
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition DeclObjC.h:2702
SourceLocation getSuperClassLoc() const
Definition DeclObjC.h:2737
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction?
Definition DeclObjC.h:2707
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition DeclObjC.h:2669
const ObjCInterfaceDecl * getSuperClass() const
Definition DeclObjC.h:2735
SourceLocation getIvarLBraceLoc() const
Definition DeclObjC.h:2742
Represents an ObjC class declaration.
Definition DeclObjC.h:1154
protocol_range protocols() const
Definition DeclObjC.h:1359
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition DeclObjC.cpp:788
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:1388
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition DeclObjC.h:1785
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition DeclObjC.h:1523
const Type * getTypeForDecl() const
Definition DeclObjC.h:1919
SourceLocation getEndOfDefinitionLoc() const
Definition DeclObjC.h:1878
TypeSourceInfo * getSuperClassTInfo() const
Definition DeclObjC.h:1573
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
AccessControl getAccessControl() const
Definition DeclObjC.h:2000
bool getSynthesize() const
Definition DeclObjC.h:2007
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
ImplicitParamDecl * getSelfDecl() const
Definition DeclObjC.h:418
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
Definition DeclObjC.h:462
ObjCDeclQualifier getObjCDeclQualifier() const
Definition DeclObjC.h:246
ArrayRef< ParmVarDecl * > parameters() const
Definition DeclObjC.h:373
unsigned param_size() const
Definition DeclObjC.h:347
bool isPropertyAccessor() const
Definition DeclObjC.h:436
bool isVariadic() const
Definition DeclObjC.h:431
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition DeclObjC.cpp:906
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition DeclObjC.h:343
bool hasRedeclaration() const
True if redeclared in the same interface.
Definition DeclObjC.h:271
bool isSynthesizedAccessorStub() const
Definition DeclObjC.h:444
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
Definition DeclObjC.h:256
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
Definition DeclObjC.h:266
ImplicitParamDecl * getCmdDecl() const
Definition DeclObjC.h:420
bool isInstanceMethod() const
Definition DeclObjC.h:426
bool isDefined() const
Definition DeclObjC.h:452
QualType getReturnType() const
Definition DeclObjC.h:329
ObjCImplementationControl getImplementationControl() const
Definition DeclObjC.h:500
bool hasSkippedBody() const
True if the method was a definition but its body was skipped.
Definition DeclObjC.h:477
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
SourceLocation getGetterNameLoc() const
Definition DeclObjC.h:886
ObjCMethodDecl * getGetterMethodDecl() const
Definition DeclObjC.h:901
ObjCMethodDecl * getSetterMethodDecl() const
Definition DeclObjC.h:904
SourceLocation getSetterNameLoc() const
Definition DeclObjC.h:894
SourceLocation getAtLoc() const
Definition DeclObjC.h:796
ObjCIvarDecl * getPropertyIvarDecl() const
Definition DeclObjC.h:924
Selector getSetterName() const
Definition DeclObjC.h:893
TypeSourceInfo * getTypeSourceInfo() const
Definition DeclObjC.h:802
QualType getType() const
Definition DeclObjC.h:804
Selector getGetterName() const
Definition DeclObjC.h:885
SourceLocation getLParenLoc() const
Definition DeclObjC.h:799
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
Definition DeclObjC.h:827
ObjCPropertyAttribute::Kind getPropertyAttributes() const
Definition DeclObjC.h:815
PropertyControl getPropertyImplementation() const
Definition DeclObjC.h:912
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition DeclObjC.h:2805
ObjCIvarDecl * getPropertyIvarDecl() const
Definition DeclObjC.h:2879
SourceLocation getPropertyIvarDeclLoc() const
Definition DeclObjC.h:2882
Expr * getSetterCXXAssignment() const
Definition DeclObjC.h:2915
ObjCPropertyDecl * getPropertyDecl() const
Definition DeclObjC.h:2870
Expr * getGetterCXXConstructor() const
Definition DeclObjC.h:2907
ObjCMethodDecl * getSetterMethodDecl() const
Definition DeclObjC.h:2904
SourceLocation getBeginLoc() const LLVM_READONLY
Definition DeclObjC.h:2867
ObjCMethodDecl * getGetterMethodDecl() const
Definition DeclObjC.h:2901
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2084
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition DeclObjC.h:2261
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:2182
protocol_range protocols() const
Definition DeclObjC.h:2161
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
unsigned protocol_size() const
Definition DeclObjC.h:2200
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
ArrayRef< const OpenACCClause * > clauses() const
Definition DeclOpenACC.h:62
Represents a partial function definition.
Definition Decl.h:4896
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4928
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition Decl.cpp:5638
unsigned getNumParams() const
Definition Decl.h:4926
Represents a parameter to a function.
Definition Decl.h:1805
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion:
Definition Decl.h:1886
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1865
SourceLocation getExplicitObjectParamThisLoc() const
Definition Decl.h:1901
bool isObjCMethodParameter() const
Definition Decl.h:1848
ObjCDeclQualifier getObjCDeclQualifier() const
Definition Decl.h:1869
bool hasUninstantiatedDefaultArg() const
Definition Decl.h:1938
bool hasInheritedDefaultArg() const
Definition Decl.h:1950
Expr * getUninstantiatedDefaultArg()
Definition Decl.cpp:3018
unsigned getFunctionScopeDepth() const
Definition Decl.h:1855
Represents a #pragma comment line.
Definition Decl.h:167
StringRef getArg() const
Definition Decl.h:190
PragmaMSCommentKind getCommentKind() const
Definition Decl.h:188
Represents a #pragma detect_mismatch line.
Definition Decl.h:201
StringRef getName() const
Definition Decl.h:222
StringRef getValue() const
Definition Decl.h:223
A (possibly-)qualified type.
Definition TypeBase.h:937
Represents a struct/union/class.
Definition Decl.h:4342
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition Decl.cpp:5384
bool hasNonTrivialToPrimitiveDestructCUnion() const
Definition Decl.h:4452
bool hasNonTrivialToPrimitiveCopyCUnion() const
Definition Decl.h:4460
RecordArgPassingKind getArgPassingRestrictions() const
Definition Decl.h:4483
bool hasVolatileMember() const
Definition Decl.h:4405
bool hasFlexibleArrayMember() const
Definition Decl.h:4375
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Definition Decl.h:4444
bool hasObjectMember() const
Definition Decl.h:4402
bool isNonTrivialToPrimitiveDestroy() const
Definition Decl.h:4436
bool isNonTrivialToPrimitiveCopy() const
Definition Decl.h:4428
bool isParamDestroyedInCallee() const
Definition Decl.h:4492
RecordDecl * getMostRecentDecl()
Definition Decl.h:4368
bool hasUninitializedExplicitInitFields() const
Definition Decl.h:4468
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition Decl.h:4420
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition Decl.h:4394
Declaration of a redeclarable template.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
RedeclarableTemplateDecl * getInstantiatedFromMemberTemplate() const
Retrieve the member template from which this template was instantiated, or nullptr if this template w...
Provides common interface for the Decls that can be redeclared.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Represents the body of a requires-expression.
Definition DeclCXX.h:2105
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
Represents a C++11 static_assert declaration.
Definition DeclCXX.h:4152
bool isFailed() const
Definition DeclCXX.h:4181
SourceLocation getRParenLoc() const
Definition DeclCXX.h:4183
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1802
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3732
SourceRange getBraceRange() const
Definition Decl.h:3809
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition Decl.h:3828
bool isEmbeddedInDeclarator() const
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
Definition Decl.h:3857
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:3833
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition Decl.h:3969
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition Decl.h:3842
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
Definition Decl.h:3868
TagKind getTagKind() const
Definition Decl.h:3932
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Represents a template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Type
The template argument is a type.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
A template parameter object.
const APValue & getValue() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
TemplateNameKind templateParameterKind() const
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
UnsignedOrNone getNumExpansionParameters() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
A declaration that models statements at global scope.
Definition Decl.h:4652
The top declaration context.
Definition Decl.h:105
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition Decl.h:3703
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition Decl.h:3721
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:227
UnsignedOrNone getArgPackSubstIndex() const
Definition ASTConcept.h:250
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Definition ASTConcept.h:244
ConceptReference * getConceptReference() const
Definition ASTConcept.h:248
Represents a declaration of a type.
Definition Decl.h:3528
const Type * getTypeForDecl() const
Definition Decl.h:3553
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:3562
QualType getType() const
Return the type wrapped by this type source info.
Definition TypeBase.h:8418
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition Type.cpp:2109
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3682
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3577
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:3627
TypedefNameDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isModed() const
Definition Decl.h:3623
QualType getUnderlyingType() const
Definition Decl.h:3632
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
Definition Decl.cpp:5736
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4471
const APValue & getValue() const
Definition DeclCXX.h:4497
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition DeclCXX.h:4134
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4053
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition DeclCXX.h:4083
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4087
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4104
Represents a dependent using declaration which was not marked with typename.
Definition DeclCXX.h:3956
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition DeclCXX.h:3987
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3997
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4014
Represents a C++ using-declaration.
Definition DeclCXX.h:3607
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition DeclCXX.h:3656
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3641
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition DeclCXX.h:3634
Represents C++ using-directive.
Definition DeclCXX.h:3112
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition DeclCXX.h:3183
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition DeclCXX.cpp:3349
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition DeclCXX.h:3179
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3187
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3157
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3808
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
Definition DeclCXX.h:3832
TypeSourceInfo * getEnumType() const
Definition DeclCXX.h:3844
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Definition DeclCXX.h:3828
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition DeclCXX.h:3889
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition DeclCXX.h:3918
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition DeclCXX.h:3922
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3415
UsingShadowDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition DeclCXX.h:3479
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
QualType getType() const
Definition Decl.h:723
Represents a variable declaration or definition.
Definition Decl.h:926
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition Decl.cpp:2787
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition Decl.h:1584
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition Decl.h:1481
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition Decl.h:1593
@ CInit
C-style initialization with assignment.
Definition Decl.h:931
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C.
Definition Decl.h:1547
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
Definition Decl.cpp:2421
bool isInlineSpecified() const
Definition Decl.h:1569
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition Decl.h:1298
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
Definition Decl.h:1537
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition Decl.h:1527
bool isCXXForRangeImplicitVar() const
Whether this variable is the implicit '__range' variable in C++ range-based for loops.
Definition Decl.h:1637
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition Decl.h:1509
bool isInline() const
Whether this variable is (C++1z) inline.
Definition Decl.h:1566
ThreadStorageClassSpecifier getTSCSpec() const
Definition Decl.h:1177
const Expr * getInit() const
Definition Decl.h:1383
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition Decl.h:1562
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition Decl.h:1244
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1168
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
Definition Decl.cpp:2675
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition Decl.h:1491
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition Decl.h:1603
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Definition Decl.cpp:2756
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Definition Decl.cpp:2875
Declaration of a variable template.
VarTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
bool isMemberSpecialization() const
Determines whether this variable template partial specialization was a specialization of a member par...
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
DeclCode
Record codes for each kind of declaration.
@ DECL_EMPTY
An EmptyDecl record.
@ DECL_CAPTURED
A CapturedDecl record.
@ DECL_CXX_RECORD
A CXXRecordDecl record.
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
@ DECL_OMP_DECLARE_MAPPER
An OMPDeclareMapperDecl record.
@ DECL_TOP_LEVEL_STMT_DECL
A TopLevelStmtDecl record.
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
@ DECL_IMPORT
An ImportDecl recording a module import.
@ DECL_UNNAMED_GLOBAL_CONSTANT
A UnnamedGlobalConstantDecl record.
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
@ DECL_PARM_VAR
A ParmVarDecl record.
@ DECL_TYPEDEF
A TypedefDecl record.
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
@ DECL_TYPEALIAS
A TypeAliasDecl record.
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
@ DECL_MS_GUID
A MSGuidDecl record.
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
@ DECL_FIELD
A FieldDecl record.
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
@ DECL_CONTEXT_TU_LOCAL_VISIBLE
A record that stores the set of declarations that are only visible to the TU.
@ DECL_NAMESPACE
A NamespaceDecl record.
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
@ DECL_USING_PACK
A UsingPackDecl record.
@ DECL_FUNCTION
A FunctionDecl record.
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
@ DECL_RECORD
A RecordDecl record.
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
@ DECL_OUTLINEDFUNCTION
A OutlinedFunctionDecl record.
@ DECL_BLOCK
A BlockDecl record.
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
@ DECL_VAR
A VarDecl record.
@ DECL_UNRESOLVED_USING_IF_EXISTS
An UnresolvedUsingIfExistsDecl record.
@ DECL_USING
A UsingDecl record.
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
@ DECL_LABEL
A LabelDecl record.
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
@ DECL_CONSTRUCTOR_USING_SHADOW
A ConstructorUsingShadowDecl record.
@ DECL_USING_ENUM
A UsingEnumDecl record.
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
@ DECL_FRIEND
A FriendDecl record.
@ DECL_CXX_METHOD
A CXXMethodDecl record.
@ DECL_EXPORT
An ExportDecl record.
@ DECL_BINDING
A BindingDecl record.
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
@ DECL_ENUM
An EnumDecl record.
@ DECL_CONTEXT_MODULE_LOCAL_VISIBLE
A record containing the set of declarations that are only visible from DeclContext in the same module...
@ DECL_DECOMPOSITION
A DecompositionDecl record.
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
@ DECL_EXPLICIT_INSTANTIATION
An ExplicitInstantiationDecl record.
@ DECL_OMP_CAPTUREDEXPR
An OMPCapturedExprDecl record.
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
@ DECL_USING_SHADOW
A UsingShadowDecl record.
@ DECL_CONCEPT
A ConceptDecl record.
@ DECL_CXX_DEDUCTION_GUIDE
A CXXDeductionGuideDecl record.
@ DECL_OMP_REQUIRES
An OMPRequiresDecl record.
@ DECL_OBJC_IVAR
A ObjCIvarDecl record.
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
@ DECL_TEMPLATE_PARAM_OBJECT
A TemplateParamObjectDecl record.
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
@ DECL_LIFETIME_EXTENDED_TEMPORARY
An LifetimeExtendedTemporaryDecl record.
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
@ DECL_IMPLICIT_CONCEPT_SPECIALIZATION
An ImplicitConceptSpecializationDecl record.
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
@ EXPR_COMPOUND_ASSIGN_OPERATOR
A CompoundAssignOperator record.
@ EXPR_CXX_OPERATOR_CALL
A CXXOperatorCallExpr record.
@ EXPR_IMPLICIT_CAST
An ImplicitCastExpr record.
@ EXPR_CHARACTER_LITERAL
A CharacterLiteral record.
@ STMT_COMPOUND
A CompoundStmt record.
@ EXPR_CALL
A CallExpr record.
@ EXPR_BINARY_OPERATOR
A BinaryOperator record.
@ EXPR_DECL_REF
A DeclRefExpr record.
@ EXPR_INTEGER_LITERAL
An IntegerLiteral record.
@ EXPR_CXX_MEMBER_CALL
A CXXMemberCallExpr record.
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
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:96
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...
Definition Template.h:50
@ AS_none
Definition Specifiers.h:128
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition Linkage.h:24
@ SD_Thread
Thread storage duration.
Definition Specifiers.h:343
@ SD_Static
Static storage duration.
Definition Specifiers.h:344
@ Template
We are parsing a template declaration.
Definition Parser.h:81
@ ExplicitInstantiation
We are parsing an explicit instantiation.
Definition Parser.h:85
@ VarTemplate
The name was classified as a variable template name.
Definition Sema.h:585
bool CanElideDeclDef(const Decl *D)
If we can elide the definition of.
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition Specifiers.h:207
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition Specifiers.h:203
U cast(CodeGen::Address addr)
Definition Address.h:327
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>".
const Expr * ConstraintExpr
Definition Decl.h:88
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:89
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition Expr.h:6717
Data that is common to all of the declarations of a given function template.
uint16_t Part2
...-89ab-...
Definition DeclCXX.h:4393
uint32_t Part1
{01234567-...
Definition DeclCXX.h:4391
uint16_t Part3
...-cdef-...
Definition DeclCXX.h:4395
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition DeclCXX.h:4397
static DeclType * getDecl(EntryType *D)