clang 24.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);
149 void VisitBlockDecl(BlockDecl *D);
152 void VisitEmptyDecl(EmptyDecl *D);
155 template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
157
158 // FIXME: Put in the same order is DeclNodes.td?
179
182
183 /// Add an Objective-C type parameter list to the given record.
185 // Empty type parameter list.
186 if (!typeParams) {
187 Record.push_back(0);
188 return;
189 }
190
191 Record.push_back(typeParams->size());
192 for (auto *typeParam : *typeParams) {
193 Record.AddDeclRef(typeParam);
194 }
195 Record.AddSourceLocation(typeParams->getLAngleLoc());
196 Record.AddSourceLocation(typeParams->getRAngleLoc());
197 }
198
199 /// Add to the record the first declaration from each module file that
200 /// provides a declaration of D. The intent is to provide a sufficient
201 /// set such that reloading this set will load all current redeclarations.
202 void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
203 auto Firsts = Writer.CollectFirstDeclFromEachModule(D, IncludeLocal);
204 for (const auto &[_, First] : Firsts)
205 Record.AddDeclRef(First);
206 }
207
208 template <typename T> bool shouldSkipWritingSpecializations(T *Spec) {
209 // Now we will only avoid writing specializations if we're generating
210 // reduced BMI.
211 if (!GeneratingReducedBMI)
212 return false;
213
216
218 if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Spec))
219 Args = CTSD->getTemplateArgs().asArray();
220 else if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Spec))
221 Args = VTSD->getTemplateArgs().asArray();
222 else
223 Args = cast<FunctionDecl>(Spec)
224 ->getTemplateSpecializationArgs()
225 ->asArray();
226
227 // If there is any template argument is TULocal, we can avoid writing the
228 // specialization since the consumers of reduced BMI won't get the
229 // specialization anyway.
230 for (const TemplateArgument &TA : Args) {
231 switch (TA.getKind()) {
233 Linkage L = TA.getAsType()->getLinkage();
234 if (!isExternallyVisible(L))
235 return true;
236 break;
237 }
239 if (!TA.getAsDecl()->isExternallyVisible())
240 return true;
241 break;
242 default:
243 break;
244 }
245 }
246
247 return false;
248 }
249
250 /// Add to the record the first template specialization from each module
251 /// file that provides a declaration of D. We store the DeclId and an
252 /// ODRHash of the template arguments of D which should provide enough
253 /// information to load D only if the template instantiator needs it.
255 const Decl *D, llvm::SmallVectorImpl<const Decl *> &SpecsInMap,
256 llvm::SmallVectorImpl<const Decl *> &PartialSpecsInMap) {
259 "Must not be called with other decls");
260 auto Firsts =
261 Writer.CollectFirstDeclFromEachModule(D, /*IncludeLocal=*/true);
262 for (const auto &[_, First] : Firsts) {
264 continue;
265
268 PartialSpecsInMap.push_back(First);
269 else
270 SpecsInMap.push_back(First);
271 }
272 }
273
274 /// Get the specialization decl from an entry in the specialization list.
275 template <typename EntryType>
280
281 /// Get the list of partial specializations from a template's common ptr.
282 template<typename T>
283 decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
284 return Common->PartialSpecializations;
285 }
290
291 template<typename DeclTy>
293 auto *Common = D->getCommonPtr();
294
295 // If we have any lazy specializations, and the external AST source is
296 // our chained AST reader, we can just write out the DeclIDs. Otherwise,
297 // we need to resolve them to actual declarations.
298 if (Writer.Chain != Record.getASTContext().getExternalSource() &&
299 Writer.Chain && Writer.Chain->haveUnloadedSpecializations(D)) {
300 D->LoadLazySpecializations();
301 assert(!Writer.Chain->haveUnloadedSpecializations(D));
302 }
303
304 // AddFirstSpecializationDeclFromEachModule might trigger deserialization,
305 // invalidating *Specializations iterators.
307 for (auto &Entry : Common->Specializations)
308 AllSpecs.push_back(getSpecializationDecl(Entry));
309 for (auto &Entry : getPartialSpecializations(Common))
310 AllSpecs.push_back(getSpecializationDecl(Entry));
311
314 for (auto *D : AllSpecs) {
315 assert(D->isCanonicalDecl() && "non-canonical decl in set");
316 AddFirstSpecializationDeclFromEachModule(D, Specs, PartialSpecs);
317 }
318
319 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
320 D, Specs, /*IsPartial=*/false));
321
322 // Function Template Decl doesn't have partial decls.
324 assert(PartialSpecs.empty());
325 return;
326 }
327
328 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
329 D, PartialSpecs, /*IsPartial=*/true));
330 }
331
332 /// Ensure that this template specialization is associated with the specified
333 /// template on reload.
335 const Decl *Specialization) {
336 Template = Template->getCanonicalDecl();
337
338 // If the canonical template is local, we'll write out this specialization
339 // when we emit it.
340 // FIXME: We can do the same thing if there is any local declaration of
341 // the template, to avoid emitting an update record.
342 if (!Template->isFromASTFile())
343 return;
344
345 // We only need to associate the first local declaration of the
346 // specialization. The other declarations will get pulled in by it.
347 if (Writer.getFirstLocalDecl(Specialization) != Specialization)
348 return;
349
352 Writer.PartialSpecializationsUpdates[cast<NamedDecl>(Template)]
353 .push_back(cast<NamedDecl>(Specialization));
354 else
355 Writer.SpecializationsUpdates[cast<NamedDecl>(Template)].push_back(
357 }
358 };
359}
360
361// When building a C++20 module interface unit or a partition unit, a
362// strong definition in the module interface is provided by the
363// compilation of that unit, not by its users. (Inline variables are still
364// emitted in module users.)
365static bool shouldVarGenerateHereOnly(const VarDecl *VD) {
366 if (VD->getStorageDuration() != SD_Static &&
368 return false;
369
370 if (VD->getDescribedVarTemplate())
371 return false;
372
373 Module *M = VD->getOwningModule();
374 if (!M)
375 return false;
376
377 M = M->getTopLevelModule();
378 ASTContext &Ctx = VD->getASTContext();
379 if (!M->isInterfaceOrPartition() &&
380 (!VD->hasAttr<DLLExportAttr>() ||
381 !Ctx.getLangOpts().BuildingPCHWithObjectFile))
382 return false;
383
385}
386
388 if (FD->isDependentContext())
389 return false;
390
391 ASTContext &Ctx = FD->getASTContext();
392 auto Linkage = Ctx.GetGVALinkageForFunction(FD);
393 if (Ctx.getLangOpts().ModulesCodegen ||
394 (FD->hasAttr<DLLExportAttr>() &&
395 Ctx.getLangOpts().BuildingPCHWithObjectFile))
396 // Under -fmodules-codegen, codegen is performed for all non-internal,
397 // non-always_inline functions, unless they are available elsewhere.
398 if (!FD->hasAttr<AlwaysInlineAttr>() && Linkage != GVA_Internal &&
400 return true;
401
402 Module *M = FD->getOwningModule();
403 if (!M)
404 return false;
405
406 M = M->getTopLevelModule();
407 if (M->isInterfaceOrPartition())
409 return true;
410
411 return false;
412}
413
415 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
416 if (FD->isInlined() || FD->isConstexpr() || FD->isConsteval())
417 return false;
418
419 // If the function should be generated somewhere else, we shouldn't elide
420 // it.
422 return false;
423 }
424
425 if (auto *VD = dyn_cast<VarDecl>(D)) {
426 if (VD->getDeclContext()->isDependentContext())
427 return false;
428
429 // Constant initialized variable may not affect the ABI, but they
430 // may be used in constant evaluation in the frontend, so we have
431 // to remain them.
432 if (VD->hasConstantInitialization() || VD->isConstexpr())
433 return false;
434
435 // If the variable should be generated somewhere else, we shouldn't elide
436 // it.
438 return false;
439 }
440
441 return true;
442}
443
446
447 // Source locations require array (variable-length) abbreviations. The
448 // abbreviation infrastructure requires that arrays are encoded last, so
449 // we handle it here in the case of those classes derived from DeclaratorDecl
450 if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
451 if (auto *TInfo = DD->getTypeSourceInfo())
452 Record.AddTypeLoc(TInfo->getTypeLoc());
453 }
454
455 // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
456 // have been written. We want it last because we will not read it back when
457 // retrieving it from the AST, we'll just lazily set the offset.
458 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
459 if (!GeneratingReducedBMI || !CanElideDeclDef(FD)) {
460 Record.push_back(FD->doesThisDeclarationHaveABody());
461 if (FD->doesThisDeclarationHaveABody())
462 Record.AddFunctionDefinition(FD);
463 } else
464 Record.push_back(0);
465 }
466
467 // Similar to FunctionDecls, handle VarDecl's initializer here and write it
468 // after all other Stmts/Exprs. We will not read the initializer until after
469 // we have finished recursive deserialization, because it can recursively
470 // refer back to the variable.
471 if (auto *VD = dyn_cast<VarDecl>(D)) {
472 if (!GeneratingReducedBMI || !CanElideDeclDef(VD))
473 Record.AddVarDeclInit(VD);
474 else
475 Record.push_back(0);
476 }
477
478 // And similarly for FieldDecls. We already serialized whether there is a
479 // default member initializer.
480 if (auto *FD = dyn_cast<FieldDecl>(D)) {
481 if (FD->hasInClassInitializer()) {
482 if (Expr *Init = FD->getInClassInitializer()) {
483 Record.push_back(1);
484 Record.AddStmt(Init);
485 } else {
486 Record.push_back(0);
487 // Initializer has not been instantiated yet.
488 }
489 }
490 }
491
492 // If this declaration is also a DeclContext, write blocks for the
493 // declarations that lexically stored inside its context and those
494 // declarations that are visible from its context.
495 if (auto *DC = dyn_cast<DeclContext>(D))
497}
498
500 BitsPacker DeclBits;
501
502 // The order matters here. It will be better to put the bit with higher
503 // probability to be 0 in the end of the bits.
504 //
505 // Since we're using VBR6 format to store it.
506 // It will be pretty effient if all the higher bits are 0.
507 // For example, if we need to pack 8 bits into a value and the stored value
508 // is 0xf0, the actual stored value will be 0b000111'110000, which takes 12
509 // bits actually. However, if we changed the order to be 0x0f, then we can
510 // store it as 0b001111, which takes 6 bits only now.
511 DeclBits.addBits((uint64_t)D->getModuleOwnershipKind(), /*BitWidth=*/3);
512 DeclBits.addBit(D->isThisDeclarationReferenced());
513 // If we're writing a BMI for a named module unit, we can treat all decls as in
514 // the BMI as used. Otherwise, the consumer need to mark it as used again, this
515 // simply waste time.
516 DeclBits.addBit(Writer.isWritingStdCXXNamedModules() ? true : D->isUsed(false));
517 DeclBits.addBits(D->getAccess(), /*BitWidth=*/2);
518 DeclBits.addBit(D->isImplicit());
519 DeclBits.addBit(D->getDeclContext() != D->getLexicalDeclContext());
520 DeclBits.addBit(D->hasAttrs());
522 DeclBits.addBit(D->isInvalidDecl());
523 Record.push_back(DeclBits);
524
525 Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
526 if (D->getDeclContext() != D->getLexicalDeclContext())
527 Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
528
529 if (D->hasAttrs())
530 Record.AddAttributes(D->getAttrs());
531
532 Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
533
534 // If this declaration injected a name into a context different from its
535 // lexical context, and that context is an imported namespace, we need to
536 // update its visible declarations to include this name.
537 //
538 // This happens when we instantiate a class with a friend declaration or a
539 // function with a local extern declaration, for instance.
540 //
541 // FIXME: Can we handle this in AddedVisibleDecl instead?
542 if (D->isOutOfLine()) {
543 auto *DC = D->getDeclContext();
544 while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
545 if (!NS->isFromASTFile())
546 break;
547 Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
548 if (!NS->isInlineNamespace())
549 break;
550 DC = NS->getParent();
551 }
552 }
553}
554
556 StringRef Arg = D->getArg();
557 Record.push_back(Arg.size());
558 VisitDecl(D);
559 Record.AddSourceLocation(D->getBeginLoc());
560 Record.push_back(D->getCommentKind());
561 Record.AddString(Arg);
563}
564
567 StringRef Name = D->getName();
568 StringRef Value = D->getValue();
569 Record.push_back(Name.size() + 1 + Value.size());
570 VisitDecl(D);
571 Record.AddSourceLocation(D->getBeginLoc());
572 Record.AddString(Name);
573 Record.AddString(Value);
575}
576
578 llvm_unreachable("Translation units aren't directly serialized");
579}
580
582 VisitDecl(D);
583 Record.AddDeclarationName(D->getDeclName());
584 Record.push_back(needsAnonymousDeclarationNumber(D)
585 ? Writer.getAnonymousDeclarationNumber(D)
586 : 0);
587}
588
591 Record.AddSourceLocation(D->getBeginLoc());
593 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
594}
595
598 VisitTypeDecl(D);
599 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
600 Record.push_back(D->isModed());
601 if (D->isModed())
602 Record.AddTypeRef(D->getUnderlyingType());
603 Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
604}
605
608 if (D->getDeclContext() == D->getLexicalDeclContext() &&
609 !D->hasAttrs() &&
610 !D->isImplicit() &&
611 D->getFirstDecl() == D->getMostRecentDecl() &&
612 !D->isInvalidDecl() &&
614 !D->isModulePrivate() &&
617 AbbrevToUse = Writer.getDeclTypedefAbbrev();
618
620}
621
627
629 static_assert(DeclContext::NumTagDeclBits == 23,
630 "You need to update the serializer after you change the "
631 "TagDeclBits");
632
634 VisitTypeDecl(D);
635 Record.push_back(D->getIdentifierNamespace());
636
637 BitsPacker TagDeclBits;
638 TagDeclBits.addBits(llvm::to_underlying(D->getTagKind()), /*BitWidth=*/3);
639 TagDeclBits.addBit(!isa<CXXRecordDecl>(D) ? D->isCompleteDefinition() : 0);
640 TagDeclBits.addBit(D->isEmbeddedInDeclarator());
641 TagDeclBits.addBit(D->isFreeStanding());
642 TagDeclBits.addBit(D->isCompleteDefinitionRequired());
643 TagDeclBits.addBits(
644 D->hasExtInfo() ? 1 : (D->getTypedefNameForAnonDecl() ? 2 : 0),
645 /*BitWidth=*/2);
646 Record.push_back(TagDeclBits);
647
648 Record.AddSourceRange(D->getBraceRange());
649
650 if (D->hasExtInfo()) {
651 Record.AddQualifierInfo(*D->getExtInfo());
652 } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
653 Record.AddDeclRef(TD);
654 Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
655 }
656}
657
659 static_assert(DeclContext::NumEnumDeclBits == 43,
660 "You need to update the serializer after you change the "
661 "EnumDeclBits");
662
663 VisitTagDecl(D);
664 Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
665 if (!D->getIntegerTypeSourceInfo())
666 Record.AddTypeRef(D->getIntegerType());
667 Record.AddTypeRef(D->getPromotionType());
668
669 BitsPacker EnumDeclBits;
670 EnumDeclBits.addBits(D->getNumPositiveBits(), /*BitWidth=*/8);
671 EnumDeclBits.addBits(D->getNumNegativeBits(), /*BitWidth=*/8);
672 EnumDeclBits.addBit(D->isScoped());
673 EnumDeclBits.addBit(D->isScopedUsingClassTag());
674 EnumDeclBits.addBit(D->isFixed());
675 Record.push_back(EnumDeclBits);
676
677 Record.push_back(D->getODRHash());
678
680 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
681 Record.push_back(MemberInfo->getTemplateSpecializationKind());
682 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
683 } else {
684 Record.AddDeclRef(nullptr);
685 }
686
687 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
688 !D->isInvalidDecl() && !D->isImplicit() && !D->hasExtInfo() &&
690 D->getFirstDecl() == D->getMostRecentDecl() &&
696 AbbrevToUse = Writer.getDeclEnumAbbrev();
697
699}
700
702 static_assert(DeclContext::NumRecordDeclBits == 64,
703 "You need to update the serializer after you change the "
704 "RecordDeclBits");
705
706 VisitTagDecl(D);
707
708 BitsPacker RecordDeclBits;
709 RecordDeclBits.addBit(D->hasFlexibleArrayMember());
710 RecordDeclBits.addBit(D->isAnonymousStructOrUnion());
711 RecordDeclBits.addBit(D->hasObjectMember());
712 RecordDeclBits.addBit(D->hasVolatileMember());
714 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveCopy());
715 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDestroy());
718 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveCopyCUnion());
719 RecordDeclBits.addBit(D->hasUninitializedExplicitInitFields());
720 RecordDeclBits.addBit(D->isParamDestroyedInCallee());
721 RecordDeclBits.addBits(llvm::to_underlying(D->getArgPassingRestrictions()), 2);
722 Record.push_back(RecordDeclBits);
723
724 // Only compute this for C/Objective-C, in C++ this is computed as part
725 // of CXXRecordDecl.
726 if (!isa<CXXRecordDecl>(D))
727 Record.push_back(D->getODRHash());
728
729 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
730 !D->isImplicit() && !D->isInvalidDecl() && !D->hasExtInfo() &&
732 D->getFirstDecl() == D->getMostRecentDecl() &&
737 AbbrevToUse = Writer.getDeclRecordAbbrev();
738
740}
741
744 Record.AddTypeRef(D->getType());
745}
746
749 Record.push_back(D->getInitExpr()? 1 : 0);
750 if (D->getInitExpr())
751 Record.AddStmt(D->getInitExpr());
752 Record.AddAPSInt(D->getInitVal());
753
755}
756
759 Record.AddSourceLocation(D->getInnerLocStart());
760 Record.push_back(D->hasExtInfo());
761 if (D->hasExtInfo()) {
762 DeclaratorDecl::ExtInfo *Info = D->getExtInfo();
763 Record.AddQualifierInfo(*Info);
764 Record.AddStmt(
765 const_cast<Expr *>(Info->TrailingRequiresClause.ConstraintExpr));
766 Record.writeUnsignedOrNone(Info->TrailingRequiresClause.ArgPackSubstIndex);
767 }
768 // The location information is deferred until the end of the record.
769 Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType()
770 : QualType());
771}
772
774 static_assert(DeclContext::NumFunctionDeclBits == 45,
775 "You need to update the serializer after you change the "
776 "FunctionDeclBits");
777
779
780 Record.push_back(D->getTemplatedKind());
781 switch (D->getTemplatedKind()) {
783 break;
785 Record.AddDeclRef(D->getInstantiatedFromDecl());
786 break;
788 Record.AddDeclRef(D->getDescribedFunctionTemplate());
789 break;
792 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
793 Record.push_back(MemberInfo->getTemplateSpecializationKind());
794 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
795 break;
796 }
799 FTSInfo = D->getTemplateSpecializationInfo();
800
802
803 Record.AddDeclRef(FTSInfo->getTemplate());
804 Record.push_back(FTSInfo->getTemplateSpecializationKind());
805
806 // Template arguments.
807 Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
808
809 // Template args as written.
810 Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
811 if (FTSInfo->TemplateArgumentsAsWritten)
812 Record.AddASTTemplateArgumentListInfo(
814
815 Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
816
817 if (MemberSpecializationInfo *MemberInfo =
818 FTSInfo->getMemberSpecializationInfo()) {
819 Record.push_back(1);
820 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
821 Record.push_back(MemberInfo->getTemplateSpecializationKind());
822 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
823 } else {
824 Record.push_back(0);
825 }
826
827 if (D->isCanonicalDecl()) {
828 // Write the template that contains the specializations set. We will
829 // add a FunctionTemplateSpecializationInfo to it when reading.
830 Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
831 }
832 break;
833 }
836 DFTSInfo = D->getDependentSpecializationInfo();
837
838 // Candidates.
839 Record.push_back(DFTSInfo->getCandidates().size());
840 for (FunctionTemplateDecl *FTD : DFTSInfo->getCandidates())
841 Record.AddDeclRef(FTD);
842
843 // Templates args.
844 Record.push_back(DFTSInfo->TemplateArgumentsAsWritten != nullptr);
845 if (DFTSInfo->TemplateArgumentsAsWritten)
846 Record.AddASTTemplateArgumentListInfo(
848 break;
849 }
850 }
851
853 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
854 Record.push_back(D->getIdentifierNamespace());
855
856 // The order matters here. It will be better to put the bit with higher
857 // probability to be 0 in the end of the bits. See the comments in VisitDecl
858 // for details.
859 BitsPacker FunctionDeclBits;
860 // FIXME: stable encoding
861 FunctionDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()), 3);
862 FunctionDeclBits.addBits((uint32_t)D->getStorageClass(), /*BitWidth=*/3);
863 FunctionDeclBits.addBit(D->isInlineSpecified());
864 FunctionDeclBits.addBit(D->isInlined());
865 FunctionDeclBits.addBit(D->hasSkippedBody());
866 FunctionDeclBits.addBit(D->isVirtualAsWritten());
867 FunctionDeclBits.addBit(D->isPureVirtual());
868 FunctionDeclBits.addBit(D->hasInheritedPrototype());
869 FunctionDeclBits.addBit(D->hasWrittenPrototype());
870 FunctionDeclBits.addBit(D->isDeletedBit());
871 FunctionDeclBits.addBit(D->isTrivial());
872 FunctionDeclBits.addBit(D->isTrivialForCall());
873 FunctionDeclBits.addBit(D->isDefaulted());
874 FunctionDeclBits.addBit(D->isExplicitlyDefaulted());
875 FunctionDeclBits.addBit(D->isIneligibleOrNotSelected());
876 FunctionDeclBits.addBits((uint64_t)(D->getConstexprKind()), /*BitWidth=*/2);
877 FunctionDeclBits.addBit(D->hasImplicitReturnZero());
878 FunctionDeclBits.addBit(D->isMultiVersion());
879 FunctionDeclBits.addBit(D->isLateTemplateParsed());
880 FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate());
882 FunctionDeclBits.addBit(D->usesSEHTry());
883 FunctionDeclBits.addBit(D->isDestroyingOperatorDelete());
884 FunctionDeclBits.addBit(D->isTypeAwareOperatorNewOrDelete());
885 Record.push_back(FunctionDeclBits);
886
887 Record.AddSourceLocation(D->getEndLoc());
888 if (D->isExplicitlyDefaulted())
889 Record.AddSourceLocation(D->getDefaultLoc());
890
891 Record.push_back(D->getODRHash());
892
893 if (D->isDefaulted() || D->isDeletedAsWritten()) {
894 if (auto *FDI = D->getDefaultedOrDeletedInfo()) {
895 // Store both that there is an DefaultedOrDeletedInfo and whether it
896 // contains a DeletedMessage.
897 StringLiteral *DeletedMessage = FDI->getDeletedMessage();
898 Record.push_back(1 | (DeletedMessage ? 2 : 0));
899 if (DeletedMessage)
900 Record.AddStmt(DeletedMessage);
901
902 Record.push_back(FDI->getFPFeatures().getAsOpaqueInt());
903
904 Record.push_back(FDI->getUnqualifiedLookups().size());
905 for (DeclAccessPair P : FDI->getUnqualifiedLookups()) {
906 Record.AddDeclRef(P.getDecl());
907 Record.push_back(P.getAccess());
908 }
909 } else {
910 Record.push_back(0);
911 }
912 }
913
914 if (D->getFriendObjectKind()) {
915 // For a friend function defined inline within a class template, we have to
916 // force the definition to be the one inside the definition of the template
917 // class. Remember this relation to deserialize them together.
918 if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent());
919 RD && isDefinitionInDependentContext(RD)) {
920 Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
921 Writer.GetDeclRef(D));
922 }
923 }
924
925 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
926 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
927 Writer.GetDeclRef(EID);
928
929 Record.push_back(D->param_size());
930 for (auto *P : D->parameters())
931 Record.AddDeclRef(P);
933}
934
937 uint64_t Kind = static_cast<uint64_t>(ES.getKind());
938 Kind = Kind << 1 | static_cast<bool>(ES.getExpr());
939 Record.push_back(Kind);
940 if (ES.getExpr()) {
941 Record.AddStmt(ES.getExpr());
942 }
943}
944
947 Record.AddDeclRef(D->Ctor);
949 Record.push_back(static_cast<unsigned char>(D->getDeductionCandidateKind()));
950 Record.AddDeclRef(D->getSourceDeductionGuide());
951 Record.push_back(
952 static_cast<unsigned char>(D->getSourceDeductionGuideKind()));
954}
955
957 static_assert(DeclContext::NumObjCMethodDeclBits == 37,
958 "You need to update the serializer after you change the "
959 "ObjCMethodDeclBits");
960
962 // FIXME: convert to LazyStmtPtr?
963 // Unlike C/C++, method bodies will never be in header files.
964 bool HasBodyStuff = D->getBody() != nullptr;
965 Record.push_back(HasBodyStuff);
966 if (HasBodyStuff) {
967 Record.AddStmt(D->getBody());
968 }
969 Record.AddDeclRef(D->getSelfDecl());
970 Record.AddDeclRef(D->getCmdDecl());
971 Record.push_back(D->isInstanceMethod());
972 Record.push_back(D->isVariadic());
973 Record.push_back(D->isPropertyAccessor());
974 Record.push_back(D->isSynthesizedAccessorStub());
975 Record.push_back(D->isDefined());
976 Record.push_back(D->isOverriding());
977 Record.push_back(D->hasSkippedBody());
978
979 Record.push_back(D->isRedeclaration());
980 Record.push_back(D->hasRedeclaration());
981 if (D->hasRedeclaration()) {
982 assert(Record.getASTContext().getObjCMethodRedeclaration(D));
983 Record.AddDeclRef(Record.getASTContext().getObjCMethodRedeclaration(D));
984 }
985
986 // FIXME: stable encoding for @required/@optional
987 Record.push_back(llvm::to_underlying(D->getImplementationControl()));
988 // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
989 Record.push_back(D->getObjCDeclQualifier());
990 Record.push_back(D->hasRelatedResultType());
991 Record.AddTypeRef(D->getReturnType());
992 Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
993 Record.AddSourceLocation(D->getEndLoc());
994 Record.push_back(D->param_size());
995 for (const auto *P : D->parameters())
996 Record.AddDeclRef(P);
997
998 Record.push_back(D->getSelLocsKind());
999 unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
1000 SourceLocation *SelLocs = D->getStoredSelLocs();
1001 Record.push_back(NumStoredSelLocs);
1002 for (unsigned i = 0; i != NumStoredSelLocs; ++i)
1003 Record.AddSourceLocation(SelLocs[i]);
1004
1006}
1007
1010 Record.push_back(D->Variance);
1011 Record.push_back(D->Index);
1012 Record.AddSourceLocation(D->VarianceLoc);
1013 Record.AddSourceLocation(D->ColonLoc);
1014
1016}
1017
1019 static_assert(DeclContext::NumObjCContainerDeclBits == 64,
1020 "You need to update the serializer after you change the "
1021 "ObjCContainerDeclBits");
1022
1023 VisitNamedDecl(D);
1024 Record.AddSourceLocation(D->getAtStartLoc());
1025 Record.AddSourceRange(D->getAtEndRange());
1026 // Abstract class (no need to define a stable serialization::DECL code).
1027}
1028
1032 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
1033 AddObjCTypeParamList(D->TypeParamList);
1034
1035 Record.push_back(D->isThisDeclarationADefinition());
1037 // Write the DefinitionData
1038 ObjCInterfaceDecl::DefinitionData &Data = D->data();
1039
1040 Record.AddTypeSourceInfo(D->getSuperClassTInfo());
1041 Record.AddSourceLocation(D->getEndOfDefinitionLoc());
1042 Record.push_back(Data.HasDesignatedInitializers);
1043 Record.push_back(D->getODRHash());
1044
1045 // Write out the protocols that are directly referenced by the @interface.
1046 Record.push_back(Data.ReferencedProtocols.size());
1047 for (const auto *P : D->protocols())
1048 Record.AddDeclRef(P);
1049 for (const auto &PL : D->protocol_locs())
1050 Record.AddSourceLocation(PL);
1051
1052 // Write out the protocols that are transitively referenced.
1053 Record.push_back(Data.AllReferencedProtocols.size());
1055 P = Data.AllReferencedProtocols.begin(),
1056 PEnd = Data.AllReferencedProtocols.end();
1057 P != PEnd; ++P)
1058 Record.AddDeclRef(*P);
1059
1060
1061 if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
1062 // Ensure that we write out the set of categories for this class.
1063 Writer.ObjCClassesWithCategories.insert(D);
1064
1065 // Make sure that the categories get serialized.
1066 for (; Cat; Cat = Cat->getNextClassCategoryRaw())
1067 (void)Writer.GetDeclRef(Cat);
1068 }
1069 }
1070
1072}
1073
1075 VisitFieldDecl(D);
1076 // FIXME: stable encoding for @public/@private/@protected/@package
1077 Record.push_back(D->getAccessControl());
1078 Record.push_back(D->getSynthesize());
1079
1080 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1081 !D->hasAttrs() &&
1082 !D->isImplicit() &&
1083 !D->isUsed(false) &&
1084 !D->isInvalidDecl() &&
1085 !D->isReferenced() &&
1086 !D->isModulePrivate() &&
1087 !D->getBitWidth() &&
1088 !D->hasExtInfo() &&
1089 D->getDeclName())
1090 AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
1091
1093}
1094
1098
1099 Record.push_back(D->isThisDeclarationADefinition());
1101 Record.push_back(D->protocol_size());
1102 for (const auto *I : D->protocols())
1103 Record.AddDeclRef(I);
1104 for (const auto &PL : D->protocol_locs())
1105 Record.AddSourceLocation(PL);
1106 Record.push_back(D->getODRHash());
1107 }
1108
1110}
1111
1116
1119 Record.AddSourceLocation(D->getCategoryNameLoc());
1120 Record.AddSourceLocation(D->getIvarLBraceLoc());
1121 Record.AddSourceLocation(D->getIvarRBraceLoc());
1122 Record.AddDeclRef(D->getClassInterface());
1123 AddObjCTypeParamList(D->TypeParamList);
1124 Record.push_back(D->protocol_size());
1125 for (const auto *I : D->protocols())
1126 Record.AddDeclRef(I);
1127 for (const auto &PL : D->protocol_locs())
1128 Record.AddSourceLocation(PL);
1130}
1131
1137
1139 VisitNamedDecl(D);
1140 Record.AddSourceLocation(D->getAtLoc());
1141 Record.AddSourceLocation(D->getLParenLoc());
1142 Record.AddTypeRef(D->getType());
1143 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
1144 // FIXME: stable encoding
1145 Record.push_back((unsigned)D->getPropertyAttributes());
1146 Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
1147 // FIXME: stable encoding
1148 Record.push_back((unsigned)D->getPropertyImplementation());
1149 Record.AddDeclarationName(D->getGetterName());
1150 Record.AddSourceLocation(D->getGetterNameLoc());
1151 Record.AddDeclarationName(D->getSetterName());
1152 Record.AddSourceLocation(D->getSetterNameLoc());
1153 Record.AddDeclRef(D->getGetterMethodDecl());
1154 Record.AddDeclRef(D->getSetterMethodDecl());
1155 Record.AddDeclRef(D->getPropertyIvarDecl());
1157}
1158
1161 Record.AddDeclRef(D->getClassInterface());
1162 // Abstract class (no need to define a stable serialization::DECL code).
1163}
1164
1170
1173 Record.AddDeclRef(D->getSuperClass());
1174 Record.AddSourceLocation(D->getSuperClassLoc());
1175 Record.AddSourceLocation(D->getIvarLBraceLoc());
1176 Record.AddSourceLocation(D->getIvarRBraceLoc());
1177 Record.push_back(D->hasNonZeroConstructors());
1178 Record.push_back(D->hasDestructors());
1179 Record.push_back(D->NumIvarInitializers);
1180 if (D->NumIvarInitializers)
1181 Record.AddCXXCtorInitializers(
1182 llvm::ArrayRef(D->init_begin(), D->init_end()));
1184}
1185
1187 VisitDecl(D);
1188 Record.AddSourceLocation(D->getBeginLoc());
1189 Record.AddDeclRef(D->getPropertyDecl());
1190 Record.AddDeclRef(D->getPropertyIvarDecl());
1191 Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
1192 Record.AddDeclRef(D->getGetterMethodDecl());
1193 Record.AddDeclRef(D->getSetterMethodDecl());
1194 Record.AddStmt(D->getGetterCXXConstructor());
1195 Record.AddStmt(D->getSetterCXXAssignment());
1197}
1198
1201 Record.push_back(D->isMutable());
1202
1203 Record.push_back((D->StorageKind << 1) | D->BitField);
1204 if (D->StorageKind == FieldDecl::ISK_CapturedVLAType)
1205 Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
1206 else if (D->BitField)
1207 Record.AddStmt(D->getBitWidth());
1208
1209 if (!D->getDeclName() || D->isPlaceholderVar(Writer.getLangOpts()))
1210 Record.AddDeclRef(
1211 Record.getASTContext().getInstantiatedFromUnnamedFieldDecl(D));
1212
1213 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1214 !D->hasAttrs() &&
1215 !D->isImplicit() &&
1216 !D->isUsed(false) &&
1217 !D->isInvalidDecl() &&
1218 !D->isReferenced() &&
1220 !D->isModulePrivate() &&
1221 !D->getBitWidth() &&
1222 !D->hasInClassInitializer() &&
1223 !D->hasCapturedVLAType() &&
1224 !D->hasExtInfo() &&
1227 D->getDeclName())
1228 AbbrevToUse = Writer.getDeclFieldAbbrev();
1229
1231}
1232
1235 Record.AddIdentifierRef(D->getGetterId());
1236 Record.AddIdentifierRef(D->getSetterId());
1238}
1239
1241 VisitValueDecl(D);
1242 MSGuidDecl::Parts Parts = D->getParts();
1243 Record.push_back(Parts.Part1);
1244 Record.push_back(Parts.Part2);
1245 Record.push_back(Parts.Part3);
1246 Record.append(std::begin(Parts.Part4And5), std::end(Parts.Part4And5));
1248}
1249
1256
1262
1264 VisitValueDecl(D);
1265 Record.push_back(D->getChainingSize());
1266
1267 for (const auto *P : D->chain())
1268 Record.AddDeclRef(P);
1270}
1271
1275
1276 // The order matters here. It will be better to put the bit with higher
1277 // probability to be 0 in the end of the bits. See the comments in VisitDecl
1278 // for details.
1279 BitsPacker VarDeclBits;
1280 VarDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()),
1281 /*BitWidth=*/3);
1282
1283 bool ModulesCodegen = shouldVarGenerateHereOnly(D);
1284 VarDeclBits.addBit(ModulesCodegen);
1285
1286 VarDeclBits.addBits(D->getStorageClass(), /*BitWidth=*/3);
1287 VarDeclBits.addBits(D->getTSCSpec(), /*BitWidth=*/2);
1288 VarDeclBits.addBits(D->getInitStyle(), /*BitWidth=*/2);
1289 VarDeclBits.addBit(D->isARCPseudoStrong());
1290
1291 bool HasDeducedType = false;
1292 if (!isa<ParmVarDecl>(D)) {
1294 VarDeclBits.addBit(D->isExceptionVariable());
1295 VarDeclBits.addBit(D->isNRVOVariable());
1296 VarDeclBits.addBit(D->isCXXForRangeDecl());
1297
1298 VarDeclBits.addBit(D->isInline());
1299 VarDeclBits.addBit(D->isInlineSpecified());
1300 VarDeclBits.addBit(D->isConstexpr());
1301 VarDeclBits.addBit(D->isInitCapture());
1302 VarDeclBits.addBit(D->isPreviousDeclInSameBlockScope());
1303
1304 VarDeclBits.addBit(D->isEscapingByref());
1305 HasDeducedType = D->getType()->getContainedDeducedType();
1306 VarDeclBits.addBit(HasDeducedType);
1307
1308 if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
1309 VarDeclBits.addBits(llvm::to_underlying(IPD->getParameterKind()),
1310 /*Width=*/3);
1311 else
1312 VarDeclBits.addBits(0, /*Width=*/3);
1313
1314 VarDeclBits.addBit(D->isObjCForDecl());
1315 VarDeclBits.addBit(D->isCXXForRangeImplicitVar());
1316 }
1317
1318 Record.push_back(VarDeclBits);
1319
1320 if (ModulesCodegen)
1321 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1322
1323 if (D->hasAttr<BlocksAttr>()) {
1324 BlockVarCopyInit Init = Record.getASTContext().getBlockVarCopyInit(D);
1325 Record.AddStmt(Init.getCopyExpr());
1326 if (Init.getCopyExpr())
1327 Record.push_back(Init.canThrow());
1328 }
1329
1330 enum {
1331 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1332 };
1333 if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
1334 Record.push_back(VarTemplate);
1335 Record.AddDeclRef(TemplD);
1336 } else if (MemberSpecializationInfo *SpecInfo
1338 Record.push_back(StaticDataMemberSpecialization);
1339 Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
1340 Record.push_back(SpecInfo->getTemplateSpecializationKind());
1341 Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
1342 } else {
1343 Record.push_back(VarNotTemplate);
1344 }
1345
1346 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1350 !D->hasExtInfo() && D->getFirstDecl() == D->getMostRecentDecl() &&
1351 D->getKind() == Decl::Var && !D->isInline() && !D->isConstexpr() &&
1353 !D->hasInitWithSideEffects() && !D->isEscapingByref() &&
1354 !HasDeducedType && D->getStorageDuration() != SD_Static &&
1357 !D->isEscapingByref())
1358 AbbrevToUse = Writer.getDeclVarAbbrev();
1359
1361}
1362
1367
1369 VisitVarDecl(D);
1370
1371 // See the implementation of `ParmVarDecl::getParameterIndex()`, which may
1372 // exceed the size of the normal bitfield. So it may be better to not pack
1373 // these bits.
1374 Record.push_back(D->getFunctionScopeIndex());
1375
1376 BitsPacker ParmVarDeclBits;
1377 ParmVarDeclBits.addBit(D->isObjCMethodParameter());
1378 ParmVarDeclBits.addBits(D->getFunctionScopeDepth(), /*BitsWidth=*/7);
1379 // FIXME: stable encoding
1380 ParmVarDeclBits.addBits(D->getObjCDeclQualifier(), /*BitsWidth=*/7);
1381 ParmVarDeclBits.addBit(D->isKNRPromoted());
1382 ParmVarDeclBits.addBit(D->hasInheritedDefaultArg());
1383 ParmVarDeclBits.addBit(D->hasUninstantiatedDefaultArg());
1384 ParmVarDeclBits.addBit(D->getExplicitObjectParamThisLoc().isValid());
1385 Record.push_back(ParmVarDeclBits);
1386
1388 Record.AddStmt(D->getUninstantiatedDefaultArg());
1390 Record.AddSourceLocation(D->getExplicitObjectParamThisLoc());
1392
1393 // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1394 // we dynamically check for the properties that we optimize for, but don't
1395 // know are true of all PARM_VAR_DECLs.
1396 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1397 !D->hasExtInfo() && D->getStorageClass() == 0 && !D->isInvalidDecl() &&
1399 D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1400 D->getInit() == nullptr) // No default expr.
1401 AbbrevToUse = Writer.getDeclParmVarAbbrev();
1402
1403 // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1404 // just us assuming it.
1405 assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1407 && "PARM_VAR_DECL can't be demoted definition.");
1408 assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1409 assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1410 assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1411 assert(!D->isStaticDataMember() &&
1412 "PARM_VAR_DECL can't be static data member");
1413}
1414
1416 // Record the number of bindings first to simplify deserialization.
1417 Record.push_back(D->bindings().size());
1418
1419 VisitVarDecl(D);
1420 for (auto *B : D->bindings())
1421 Record.AddDeclRef(B);
1423}
1424
1426 VisitValueDecl(D);
1427 Record.AddStmt(D->getBinding());
1429}
1430
1432 VisitDecl(D);
1433 Record.AddStmt(D->getAsmStringExpr());
1434 Record.AddSourceLocation(D->getRParenLoc());
1436}
1437
1439 VisitDecl(D);
1440 Record.push_back(D->getOrdinal());
1441 Record.AddStmt(D->getStmt());
1443}
1444
1449
1452 VisitDecl(D);
1453 Record.AddDeclRef(D->getExtendingDecl());
1454 Record.AddStmt(D->getTemporaryExpr());
1455 Record.push_back(static_cast<bool>(D->getValue()));
1456 if (D->getValue())
1457 Record.AddAPValue(*D->getValue());
1458 Record.push_back(D->getManglingNumber());
1460}
1462 VisitDecl(D);
1463 Record.AddStmt(D->getBody());
1464 Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1465 Record.push_back(D->param_size());
1466 for (ParmVarDecl *P : D->parameters())
1467 Record.AddDeclRef(P);
1468 Record.push_back(D->isVariadic());
1469 Record.push_back(D->blockMissingReturnType());
1470 Record.push_back(D->isConversionFromLambda());
1471 Record.push_back(D->doesNotEscape());
1472 Record.push_back(D->canAvoidCopyToHeap());
1473 Record.push_back(D->capturesCXXThis());
1474 Record.push_back(D->getNumCaptures());
1475 for (const auto &capture : D->captures()) {
1476 Record.AddDeclRef(capture.getVariable());
1477
1478 unsigned flags = 0;
1479 if (capture.isByRef()) flags |= 1;
1480 if (capture.isNested()) flags |= 2;
1481 if (capture.hasCopyExpr()) flags |= 4;
1482 Record.push_back(flags);
1483
1484 if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1485 }
1486
1488}
1489
1491 Record.push_back(D->getNumParams());
1492 VisitDecl(D);
1493 for (unsigned I = 0; I < D->getNumParams(); ++I)
1494 Record.AddDeclRef(D->getParam(I));
1495 Record.push_back(D->isNothrow() ? 1 : 0);
1496 Record.AddStmt(D->getBody());
1498}
1499
1501 Record.push_back(CD->getNumParams());
1502 VisitDecl(CD);
1503 Record.push_back(CD->getContextParamPosition());
1504 Record.push_back(CD->isNothrow() ? 1 : 0);
1505 // Body is stored by VisitCapturedStmt.
1506 for (unsigned I = 0; I < CD->getNumParams(); ++I)
1507 Record.AddDeclRef(CD->getParam(I));
1509}
1510
1512 static_assert(DeclContext::NumLinkageSpecDeclBits == 17,
1513 "You need to update the serializer after you change the"
1514 "LinkageSpecDeclBits");
1515
1516 VisitDecl(D);
1517 Record.push_back(llvm::to_underlying(D->getLanguage()));
1518 Record.AddSourceLocation(D->getExternLoc());
1519 Record.AddSourceLocation(D->getRBraceLoc());
1521}
1522
1524 VisitDecl(D);
1525 Record.AddSourceLocation(D->getRBraceLoc());
1527}
1528
1530 VisitNamedDecl(D);
1531 Record.AddSourceLocation(D->getBeginLoc());
1533}
1534
1535
1538 VisitNamedDecl(D);
1539
1540 BitsPacker NamespaceDeclBits;
1541 NamespaceDeclBits.addBit(D->isInline());
1542 NamespaceDeclBits.addBit(D->isNested());
1543 Record.push_back(NamespaceDeclBits);
1544
1545 Record.AddSourceLocation(D->getBeginLoc());
1546 Record.AddSourceLocation(D->getRBraceLoc());
1547
1548 if (D->isFirstDecl())
1549 Record.AddDeclRef(D->getAnonymousNamespace());
1551
1552 if (Writer.hasChain() && D->isAnonymousNamespace() &&
1553 D == D->getMostRecentDecl()) {
1554 // This is a most recent reopening of the anonymous namespace. If its parent
1555 // is in a previous PCH (or is the TU), mark that parent for update, because
1556 // the original namespace always points to the latest re-opening of its
1557 // anonymous namespace.
1558 Decl *Parent = cast<Decl>(
1560 if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1561 Writer.DeclUpdates[Parent].push_back(
1562 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, D));
1563 }
1564 }
1565}
1566
1569 VisitNamedDecl(D);
1570 Record.AddSourceLocation(D->getNamespaceLoc());
1571 Record.AddSourceLocation(D->getTargetNameLoc());
1572 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1573 Record.AddDeclRef(D->getNamespace());
1575}
1576
1578 VisitNamedDecl(D);
1579 Record.AddSourceLocation(D->getUsingLoc());
1580 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1581 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1582 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1583 Record.push_back(D->hasTypename());
1584 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingDecl(D));
1586}
1587
1589 VisitNamedDecl(D);
1590 Record.AddSourceLocation(D->getUsingLoc());
1591 Record.AddSourceLocation(D->getEnumLoc());
1592 Record.AddTypeSourceInfo(D->getEnumType());
1593 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1594 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingEnumDecl(D));
1596}
1597
1599 Record.push_back(D->NumExpansions);
1600 VisitNamedDecl(D);
1601 Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1602 for (auto *E : D->expansions())
1603 Record.AddDeclRef(E);
1605}
1606
1609 VisitNamedDecl(D);
1610 Record.AddDeclRef(D->getTargetDecl());
1611 Record.push_back(D->getIdentifierNamespace());
1612 Record.AddDeclRef(D->UsingOrNextShadow);
1613 Record.AddDeclRef(
1614 Record.getASTContext().getInstantiatedFromUsingShadowDecl(D));
1615
1616 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1617 D->getFirstDecl() == D->getMostRecentDecl() && !D->hasAttrs() &&
1620 AbbrevToUse = Writer.getDeclUsingShadowAbbrev();
1621
1623}
1624
1628 Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1629 Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1630 Record.push_back(D->IsVirtual);
1632}
1633
1635 VisitNamedDecl(D);
1636 Record.AddSourceLocation(D->getUsingLoc());
1637 Record.AddSourceLocation(D->getNamespaceKeyLocation());
1638 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1639 Record.AddDeclRef(D->getNominatedNamespace());
1640 Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1642}
1643
1645 VisitValueDecl(D);
1646 Record.AddSourceLocation(D->getUsingLoc());
1647 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1648 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1649 Record.AddSourceLocation(D->getEllipsisLoc());
1651}
1652
1655 VisitTypeDecl(D);
1656 Record.AddSourceLocation(D->getTypenameLoc());
1657 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1658 Record.AddSourceLocation(D->getEllipsisLoc());
1660}
1661
1667
1669 VisitRecordDecl(D);
1670
1671 enum {
1672 CXXRecNotTemplate = 0,
1673 CXXRecTemplate,
1674 CXXRecMemberSpecialization,
1675 CXXLambda
1676 };
1677 if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1678 Record.push_back(CXXRecTemplate);
1679 Record.AddDeclRef(TemplD);
1680 } else if (MemberSpecializationInfo *MSInfo
1682 Record.push_back(CXXRecMemberSpecialization);
1683 Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1684 Record.push_back(MSInfo->getTemplateSpecializationKind());
1685 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1686 } else if (D->isLambda()) {
1687 // For a lambda, we need some information early for merging.
1688 Record.push_back(CXXLambda);
1689 if (auto *Context = D->getLambdaContextDecl()) {
1690 Record.AddDeclRef(Context);
1691 Record.push_back(D->getLambdaIndexInContext());
1692 } else {
1693 Record.push_back(0);
1694 }
1695 // For lambdas inside template functions, remember the mapping to
1696 // deserialize them together.
1697 if (auto *FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
1698 FD && isDefinitionInDependentContext(FD)) {
1699 Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
1700 Writer.GetDeclRef(D->getLambdaCallOperator()));
1701 }
1702 } else {
1703 Record.push_back(CXXRecNotTemplate);
1704 }
1705
1706 Record.push_back(D->isThisDeclarationADefinition());
1708 Record.AddCXXDefinitionData(D);
1709
1710 if (D->isCompleteDefinition() && D->isInNamedModule())
1711 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1712
1713 // Store (what we currently believe to be) the key function to avoid
1714 // deserializing every method so we can compute it.
1715 //
1716 // FIXME: Avoid adding the key function if the class is defined in
1717 // module purview since in that case the key function is meaningless.
1718 if (D->isCompleteDefinition())
1719 Record.AddDeclRef(Record.getASTContext().getCurrentKeyFunction(D));
1720
1722}
1723
1726 if (D->isCanonicalDecl()) {
1727 Record.push_back(D->size_overridden_methods());
1728 for (const CXXMethodDecl *MD : D->overridden_methods())
1729 Record.AddDeclRef(MD);
1730 } else {
1731 // We only need to record overridden methods once for the canonical decl.
1732 Record.push_back(0);
1733 }
1734
1735 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1736 D->getFirstDecl() == D->getMostRecentDecl() && !D->isInvalidDecl() &&
1737 !D->hasAttrs() && !D->isTopLevelDeclInObjCContainer() &&
1739 !D->hasExtInfo() && !D->isExplicitlyDefaulted()) {
1744 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1745 else if (D->getTemplatedKind() ==
1749
1750 if (FTSInfo->TemplateArguments->size() == 1) {
1751 const TemplateArgument &TA = FTSInfo->TemplateArguments->get(0);
1752 if (TA.getKind() == TemplateArgument::Type &&
1753 !FTSInfo->TemplateArgumentsAsWritten &&
1754 !FTSInfo->getMemberSpecializationInfo())
1755 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1756 }
1757 } else if (D->getTemplatedKind() ==
1761 if (!DFTSInfo->TemplateArgumentsAsWritten)
1762 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1763 }
1764 }
1765
1767}
1768
1770 static_assert(DeclContext::NumCXXConstructorDeclBits == 64,
1771 "You need to update the serializer after you change the "
1772 "CXXConstructorDeclBits");
1773
1774 Record.push_back(D->getTrailingAllocKind());
1775 addExplicitSpecifier(D->getExplicitSpecifierInternal(), Record);
1776 if (auto Inherited = D->getInheritedConstructor()) {
1777 Record.AddDeclRef(Inherited.getShadowDecl());
1778 Record.AddDeclRef(Inherited.getConstructor());
1779 }
1780
1781 ArrayRef<CXXDefaultArgExpr *> CtorClosureDefaultArgs =
1783 Record.push_back((unsigned)CtorClosureDefaultArgs.size());
1784 for (CXXDefaultArgExpr *Arg : CtorClosureDefaultArgs)
1785 Record.writeStmtRef(Arg);
1786
1789}
1790
1793
1794 Record.AddDeclRef(D->getOperatorDelete());
1795 if (D->getOperatorDelete())
1796 Record.AddStmt(D->getOperatorDeleteThisArg());
1797 Record.AddDeclRef(D->getOperatorGlobalDelete());
1798 Record.AddDeclRef(D->getArrayOperatorDelete());
1799 Record.AddDeclRef(D->getGlobalArrayOperatorDelete());
1800
1802}
1803
1809
1811 VisitDecl(D);
1812 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1813 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1814 Record.push_back(!IdentifierLocs.empty());
1815 if (IdentifierLocs.empty()) {
1816 Record.AddSourceLocation(D->getEndLoc());
1817 Record.push_back(1);
1818 } else {
1819 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1820 Record.AddSourceLocation(IdentifierLocs[I]);
1821 Record.push_back(IdentifierLocs.size());
1822 }
1823 // Note: the number of source locations must always be the last element in
1824 // the record.
1826}
1827
1829 VisitDecl(D);
1830 Record.AddSourceLocation(D->getColonLoc());
1832}
1833
1835 VisitDecl(D);
1836 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1837 Record.push_back(hasFriendDecl);
1838 if (hasFriendDecl)
1839 Record.AddDeclRef(D->getFriendDecl());
1840 else
1841 Record.AddTypeSourceInfo(D->getFriendType());
1842 Record.AddDeclRef(D->getNextFriend());
1843 Record.AddSourceLocation(D->FriendLoc);
1844 Record.AddSourceLocation(D->EllipsisLoc);
1846}
1847
1849 // Record the number of template parameter lists here to simplify memory
1850 // allocation during deserialization.
1851 Record.push_back(D->NumTPLists);
1852 VisitDecl(D);
1854 Record.AddTemplateParameterList(TPL);
1856 if (D->getFriendType()) {
1857 Kind = D->Template.isNull() ? FTDK_Type : FTDK_Dependent;
1858 } else if (D->Template.isNull()) {
1859 assert(D->getFriendDecl());
1860 Kind = FTDK_Decl;
1861 } else {
1862 Kind = FTDK_Template;
1863 }
1864 Record.push_back(Kind);
1865 switch (Kind) {
1866 case FTDK_Type:
1867 Record.AddTypeSourceInfo(D->getFriendType());
1868 break;
1869 case FTDK_Dependent:
1870 Record.AddTypeSourceInfo(D->getFriendType());
1871 Record.AddTemplateName(D->Template);
1872 break;
1873 case FTDK_Decl:
1874 Record.AddDeclRef(D->getFriendDecl());
1875 break;
1876 case FTDK_Template:
1877 Record.AddTemplateName(D->Template);
1878 break;
1879 }
1880 Record.AddDeclRef(D->getNextFriend());
1881 Record.AddSourceLocation(D->FriendLoc);
1882 Record.AddSourceLocation(D->EllipsisLoc);
1884}
1885
1887 VisitNamedDecl(D);
1888
1889 Record.AddTemplateParameterList(D->getTemplateParameters());
1890 Record.AddDeclRef(D->getTemplatedDecl());
1891}
1892
1898
1901 Record.push_back(D->getTemplateArguments().size());
1902 VisitDecl(D);
1903 for (const TemplateArgument &Arg : D->getTemplateArguments())
1904 Record.AddTemplateArgument(Arg);
1906}
1907
1911
1914
1915 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1916 // getCommonPtr() can be used while this is still initializing.
1917 if (D->isFirstDecl()) {
1918 // This declaration owns the 'common' pointer, so serialize that data now.
1919 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1921 Record.push_back(D->isMemberSpecialization());
1922 }
1923
1925 Record.push_back(D->getIdentifierNamespace());
1926}
1927
1930
1931 if (D->isFirstDecl())
1933
1934 // Force emitting the corresponding deduction guide in reduced BMI mode.
1935 // Otherwise, the deduction guide may be optimized out incorrectly.
1936 if (Writer.isGeneratingReducedBMI()) {
1937 auto Name =
1938 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1939 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1940 Writer.GetDeclRef(DG->getCanonicalDecl());
1941 }
1942
1944}
1945
1949
1951
1952 llvm::PointerUnion<ClassTemplateDecl *,
1955 if (Decl *InstFromD = dyn_cast<ClassTemplateDecl *>(InstFrom)) {
1956 Record.AddDeclRef(InstFromD);
1957 } else {
1958 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1959 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1960 }
1961
1962 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1963 Record.AddSourceLocation(D->getPointOfInstantiation());
1964 Record.push_back(D->getSpecializationKind());
1965 Record.push_back(D->hasStrictPackMatch());
1966 Record.push_back(D->isCanonicalDecl());
1967
1968 if (D->isCanonicalDecl()) {
1969 // When reading, we'll add it to the folding set of the following template.
1970 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1971 }
1972
1977 Record.push_back(ExplicitInstantiation);
1979 Record.AddSourceLocation(D->getExternKeywordLoc());
1980 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1981 }
1982
1983 const ASTTemplateArgumentListInfo *ArgsWritten =
1985 Record.push_back(!!ArgsWritten);
1986 if (ArgsWritten)
1987 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1988
1989 // Mention the implicitly generated C++ deduction guide to make sure the
1990 // deduction guide will be rewritten as expected.
1991 //
1992 // FIXME: Would it be more efficient to add a callback register function
1993 // in sema to register the deduction guide?
1994 if (Writer.isWritingStdCXXNamedModules()) {
1995 auto Name =
1996 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
1998 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1999 Writer.GetDeclRef(DG->getCanonicalDecl());
2000 }
2001
2002 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
2003 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
2004 Writer.GetDeclRef(EID);
2005
2007}
2008
2011 Record.AddTemplateParameterList(D->getTemplateParameters());
2012
2014
2015 // These are read/set from/to the first declaration.
2016 if (D->getPreviousDecl() == nullptr) {
2017 Record.AddDeclRef(D->getInstantiatedFromMember());
2018 Record.push_back(D->isMemberSpecialization());
2019 }
2020
2022}
2023
2031
2035
2036 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2037 InstFrom = D->getSpecializedTemplateOrPartial();
2038 if (Decl *InstFromD = dyn_cast<VarTemplateDecl *>(InstFrom)) {
2039 Record.AddDeclRef(InstFromD);
2040 } else {
2041 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
2042 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
2043 }
2044
2049 Record.push_back(ExplicitInstantiation);
2051 Record.AddSourceLocation(D->getExternKeywordLoc());
2052 Record.AddSourceLocation(D->getTemplateKeywordLoc());
2053 }
2054
2055 const ASTTemplateArgumentListInfo *ArgsWritten =
2057 Record.push_back(!!ArgsWritten);
2058 if (ArgsWritten)
2059 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
2060
2061 Record.AddTemplateArgumentList(&D->getTemplateArgs());
2062 Record.AddSourceLocation(D->getPointOfInstantiation());
2063 Record.push_back(D->getSpecializationKind());
2064 Record.push_back(D->IsCompleteDefinition);
2065
2066 VisitVarDecl(D);
2067
2068 Record.push_back(D->isCanonicalDecl());
2069
2070 if (D->isCanonicalDecl()) {
2071 // When reading, we'll add it to the folding set of the following template.
2072 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
2073 }
2074
2075 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
2076 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
2077 Writer.GetDeclRef(EID);
2078
2080}
2081
2084 Record.AddTemplateParameterList(D->getTemplateParameters());
2085
2087
2088 // These are read/set from/to the first declaration.
2089 if (D->getPreviousDecl() == nullptr) {
2090 Record.AddDeclRef(D->getInstantiatedFromMember());
2091 Record.push_back(D->isMemberSpecialization());
2092 }
2093
2095}
2096
2104
2106 Record.push_back(D->hasTypeConstraint());
2107 VisitTypeDecl(D);
2108
2109 Record.push_back(D->wasDeclaredWithTypename());
2110
2111 const TypeConstraint *TC = D->getTypeConstraint();
2112 if (D->hasTypeConstraint())
2113 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
2114 if (TC) {
2115 auto *CR = TC->getConceptReference();
2116 Record.push_back(CR != nullptr);
2117 if (CR)
2118 Record.AddConceptReference(CR);
2119 Record.AddStmt(TC->getImmediatelyDeclaredConstraint());
2120 Record.writeUnsignedOrNone(TC->getArgPackSubstIndex());
2121 Record.writeUnsignedOrNone(D->getNumExpansionParameters());
2122 }
2123
2124 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2126 Record.push_back(OwnsDefaultArg);
2127 if (OwnsDefaultArg)
2128 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2129
2130 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
2132 !D->isInvalidDecl() && !D->hasAttrs() &&
2135 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
2136
2138}
2139
2141 // For an expanded parameter pack, record the number of expansion types here
2142 // so that it's easier for deserialization to allocate the right amount of
2143 // memory.
2144 Record.push_back(D->hasPlaceholderTypeConstraint());
2145 if (D->isExpandedParameterPack())
2146 Record.push_back(D->getNumExpansionTypes());
2147
2149 // TemplateParmPosition.
2150 Record.push_back(D->getDepth());
2151 Record.push_back(D->getPosition());
2152
2154 Record.AddStmt(D->getPlaceholderTypeConstraint());
2155
2156 if (D->isExpandedParameterPack()) {
2157 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2158 Record.AddTypeRef(D->getExpansionType(I));
2159 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2160 }
2161
2163 } else {
2164 // Rest of NonTypeTemplateParmDecl.
2165 Record.push_back(D->isParameterPack());
2166 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2168 Record.push_back(OwnsDefaultArg);
2169 if (OwnsDefaultArg)
2170 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2172 }
2173}
2174
2176 // For an expanded parameter pack, record the number of expansion types here
2177 // so that it's easier for deserialization to allocate the right amount of
2178 // memory.
2179 if (D->isExpandedParameterPack())
2180 Record.push_back(D->getNumExpansionTemplateParameters());
2181
2183 Record.push_back(D->templateParameterKind());
2184 Record.push_back(D->wasDeclaredWithTypename());
2185 // TemplateParmPosition.
2186 Record.push_back(D->getDepth());
2187 Record.push_back(D->getPosition());
2188
2189 if (D->isExpandedParameterPack()) {
2190 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2191 I != N; ++I)
2192 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2194 } else {
2195 // Rest of TemplateTemplateParmDecl.
2196 Record.push_back(D->isParameterPack());
2197 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2199 Record.push_back(OwnsDefaultArg);
2200 if (OwnsDefaultArg)
2201 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2203 }
2204}
2205
2210
2212 VisitDecl(D);
2213 Record.AddStmt(D->getAssertExpr());
2214 Record.push_back(D->isFailed());
2215 Record.AddStmt(D->getMessage());
2216 Record.AddSourceLocation(D->getRParenLoc());
2218}
2219
2222 // Trailing-object flags must be the first thing written so the reader can
2223 // allocate the right amount of trailing storage in CreateDeserialized.
2224 unsigned Flags = 0;
2225 if (D->hasTrailingQualifier())
2226 Flags |= ExplicitInstantiationDecl::HasQualifierFlag;
2227 if (D->hasTrailingArgsAsWritten())
2228 Flags |= ExplicitInstantiationDecl::HasArgsAsWrittenFlag;
2229 Record.push_back(Flags);
2230
2231 VisitDecl(D);
2232 Record.AddDeclRef(D->getSpecialization());
2233 Record.AddSourceLocation(D->getExternLoc());
2234 Record.AddSourceLocation(D->getNameLoc());
2235 Record.AddTypeSourceInfo(D->getRawTypeSourceInfo());
2236 Record.push_back(D->getTemplateSpecializationKind());
2237 // Trailing objects.
2238 if (D->hasTrailingQualifier())
2239 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
2240 if (const auto *Args = D->getTrailingArgsInfo())
2241 Record.AddASTTemplateArgumentListInfo(Args);
2243}
2244
2246 VisitDecl(D);
2247 Record.AddStmt(D->getExpansionPattern());
2248 Record.AddStmt(D->getInstantiations());
2249 Record.AddDeclRef(D->getIndexTemplateParm());
2251}
2252
2253/// Emit the DeclContext part of a declaration context decl.
2255 static_assert(DeclContext::NumDeclContextBits == 13,
2256 "You need to update the serializer after you change the "
2257 "DeclContextBits");
2258 LookupBlockOffsets Offsets;
2259
2260 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2261 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2262 // In reduced BMI, delay writing lexical and visible block for namespace
2263 // in the global module fragment. See the comments of DelayedNamespace for
2264 // details.
2265 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2266 } else {
2267 Offsets.LexicalOffset =
2268 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2269 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC, Offsets);
2270 }
2271
2272 Record.AddLookupOffsets(Offsets);
2273}
2274
2276 assert(IsLocalDecl(D) && "expected a local declaration");
2277
2278 const Decl *Canon = D->getCanonicalDecl();
2279 if (IsLocalDecl(Canon))
2280 return Canon;
2281
2282 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2283 if (CacheEntry)
2284 return CacheEntry;
2285
2286 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2287 if (IsLocalDecl(Redecl))
2288 D = Redecl;
2289 return CacheEntry = D;
2290}
2291
2292template <typename T>
2294 T *First = D->getFirstDecl();
2295 T *MostRecent = First->getMostRecentDecl();
2296 T *DAsT = static_cast<T *>(D);
2297 if (MostRecent != First) {
2298 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2299 "Not considered redeclarable?");
2300
2301 Record.AddDeclRef(First);
2302
2303 // Write out a list of local redeclarations of this declaration if it's the
2304 // first local declaration in the chain.
2305 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2306 if (DAsT == FirstLocal) {
2307 // Emit a list of all imported first declarations so that we can be sure
2308 // that all redeclarations visible to this module are before D in the
2309 // redecl chain.
2310 unsigned I = Record.size();
2311 Record.push_back(0);
2312 if (Writer.Chain)
2313 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2314 // This is the number of imported first declarations + 1.
2315 Record[I] = Record.size() - I;
2316
2317 // Collect the set of local redeclarations of this declaration, from
2318 // newest to oldest.
2319 ASTWriter::RecordData LocalRedecls;
2320 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2321 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2322 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2323 if (!Prev->isFromASTFile())
2324 LocalRedeclWriter.AddDeclRef(Prev);
2325
2326 // If we have any redecls, write them now as a separate record preceding
2327 // the declaration itself.
2328 if (LocalRedecls.empty())
2329 Record.push_back(0);
2330 else
2331 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2332 } else {
2333 Record.push_back(0);
2334 Record.AddDeclRef(FirstLocal);
2335 }
2336
2337 // Make sure that we serialize both the previous and the most-recent
2338 // declarations, which (transitively) ensures that all declarations in the
2339 // chain get serialized.
2340 //
2341 // FIXME: This is not correct; when we reach an imported declaration we
2342 // won't emit its previous declaration.
2343 (void)Writer.GetDeclRef(D->getPreviousDecl());
2344 (void)Writer.GetDeclRef(MostRecent);
2345 } else {
2346 // We use the sentinel value 0 to indicate an only declaration.
2347 Record.push_back(0);
2348 }
2349}
2350
2352 VisitNamedDecl(D);
2354 Record.push_back(D->isCBuffer());
2355 Record.AddSourceLocation(D->getLocStart());
2356 Record.AddSourceLocation(D->getLBraceLoc());
2357 Record.AddSourceLocation(D->getRBraceLoc());
2358
2360}
2361
2363 Record.writeOMPChildren(D->Data);
2364 VisitDecl(D);
2366}
2367
2369 Record.writeOMPChildren(D->Data);
2370 VisitDecl(D);
2372}
2373
2375 Record.writeOMPChildren(D->Data);
2376 VisitDecl(D);
2378}
2379
2382 "You need to update the serializer after you change the "
2383 "NumOMPDeclareReductionDeclBits");
2384
2385 VisitValueDecl(D);
2386 Record.AddSourceLocation(D->getBeginLoc());
2387 Record.AddStmt(D->getCombinerIn());
2388 Record.AddStmt(D->getCombinerOut());
2389 Record.AddStmt(D->getCombiner());
2390 Record.AddStmt(D->getInitOrig());
2391 Record.AddStmt(D->getInitPriv());
2392 Record.AddStmt(D->getInitializer());
2393 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2394 Record.AddDeclRef(D->getPrevDeclInScope());
2396}
2397
2399 Record.writeOMPChildren(D->Data);
2400 VisitValueDecl(D);
2401 Record.AddDeclarationName(D->getVarName());
2402 Record.AddDeclRef(D->getPrevDeclInScope());
2404}
2405
2410
2412 Record.writeUInt32(D->clauses().size());
2413 VisitDecl(D);
2414 Record.writeEnum(D->DirKind);
2415 Record.AddSourceLocation(D->DirectiveLoc);
2416 Record.AddSourceLocation(D->EndLoc);
2417 Record.writeOpenACCClauseList(D->clauses());
2419}
2421 Record.writeUInt32(D->clauses().size());
2422 VisitDecl(D);
2423 Record.writeEnum(D->DirKind);
2424 Record.AddSourceLocation(D->DirectiveLoc);
2425 Record.AddSourceLocation(D->EndLoc);
2426 Record.AddSourceRange(D->ParensLoc);
2427 Record.AddStmt(D->FuncRef);
2428 Record.writeOpenACCClauseList(D->clauses());
2430}
2431
2432//===----------------------------------------------------------------------===//
2433// ASTWriter Implementation
2434//===----------------------------------------------------------------------===//
2435
2436namespace {
2437template <FunctionDecl::TemplatedKind Kind>
2438std::shared_ptr<llvm::BitCodeAbbrev>
2439getFunctionDeclAbbrev(serialization::DeclCode Code) {
2440 using namespace llvm;
2441
2442 auto Abv = std::make_shared<BitCodeAbbrev>();
2443 Abv->Add(BitCodeAbbrevOp(Code));
2444 // RedeclarableDecl
2445 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2446 Abv->Add(BitCodeAbbrevOp(Kind));
2447 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2448
2449 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2450 // DescribedFunctionTemplate
2451 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2452 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2453 // Instantiated From Decl
2454 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2455 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2456 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2457 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2458 3)); // TemplateSpecializationKind
2459 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2460 } else if constexpr (Kind ==
2462 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2463 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2464 3)); // TemplateSpecializationKind
2465 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2466 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2467 Abv->Add(
2468 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2469 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2470 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2471 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2472 Abv->Add(BitCodeAbbrevOp(0));
2473 Abv->Add(
2474 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2475 } else if constexpr (Kind == FunctionDecl::
2476 TK_DependentFunctionTemplateSpecialization) {
2477 // Candidates of specialization
2478 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2479 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2480 } else {
2481 llvm_unreachable("Unknown templated kind?");
2482 }
2483 // Decl
2484 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2485 8)); // Packed DeclBits: ModuleOwnershipKind,
2486 // isUsed, isReferenced, AccessSpecifier,
2487 // isImplicit
2488 //
2489 // The following bits should be 0:
2490 // HasStandaloneLexicalDC, HasAttrs,
2491 // TopLevelDeclInObjCContainer,
2492 // isInvalidDecl
2493 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2494 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2495 // NamedDecl
2496 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2497 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2498 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2499 // ValueDecl
2500 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2501 // DeclaratorDecl
2502 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2503 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2504 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2505 // FunctionDecl
2506 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2507 Abv->Add(BitCodeAbbrevOp(
2508 BitCodeAbbrevOp::Fixed,
2509 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2510 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2511 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2512 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2513 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2514 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2515 // ShouldSkipCheckingODR
2516 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2517 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2518 // This Array slurps the rest of the record. Fortunately we want to encode
2519 // (nearly) all the remaining (variable number of) fields in the same way.
2520 //
2521 // This is:
2522 // NumParams and Params[] from FunctionDecl, and
2523 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2524 //
2525 // Add an AbbrevOp for 'size then elements' and use it here.
2526 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2527 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2528 return Abv;
2529}
2530
2531template <FunctionDecl::TemplatedKind Kind>
2532std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2533 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2534}
2535} // namespace
2536
2537void ASTWriter::WriteDeclAbbrevs() {
2538 using namespace llvm;
2539
2540 std::shared_ptr<BitCodeAbbrev> Abv;
2541
2542 // Abbreviation for DECL_FIELD
2543 Abv = std::make_shared<BitCodeAbbrev>();
2544 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2545 // Decl
2546 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2547 7)); // Packed DeclBits: ModuleOwnershipKind,
2548 // isUsed, isReferenced, AccessSpecifier,
2549 //
2550 // The following bits should be 0:
2551 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2552 // TopLevelDeclInObjCContainer,
2553 // isInvalidDecl
2554 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2555 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2556 // NamedDecl
2557 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2558 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2559 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2560 // ValueDecl
2561 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2562 // DeclaratorDecl
2563 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2564 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2565 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2566 // FieldDecl
2567 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2568 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2569 // Type Source Info
2570 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2571 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2572 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2573
2574 // Abbreviation for DECL_OBJC_IVAR
2575 Abv = std::make_shared<BitCodeAbbrev>();
2576 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2577 // Decl
2578 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2579 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2580 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2581 // isReferenced, TopLevelDeclInObjCContainer,
2582 // AccessSpecifier, ModuleOwnershipKind
2583 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2584 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2585 // NamedDecl
2586 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2587 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2588 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2589 // ValueDecl
2590 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2591 // DeclaratorDecl
2592 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2593 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2594 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2595 // FieldDecl
2596 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2597 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2598 // ObjC Ivar
2599 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2600 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2601 // Type Source Info
2602 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2603 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2604 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2605
2606 // Abbreviation for DECL_ENUM
2607 Abv = std::make_shared<BitCodeAbbrev>();
2608 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2609 // Redeclarable
2610 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2611 // Decl
2612 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2613 7)); // Packed DeclBits: ModuleOwnershipKind,
2614 // isUsed, isReferenced, AccessSpecifier,
2615 //
2616 // The following bits should be 0:
2617 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2618 // TopLevelDeclInObjCContainer,
2619 // isInvalidDecl
2620 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2621 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2622 // NamedDecl
2623 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2624 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2625 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2626 // TypeDecl
2627 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2628 // TagDecl
2629 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2630 Abv->Add(BitCodeAbbrevOp(
2631 BitCodeAbbrevOp::Fixed,
2632 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2633 // EmbeddedInDeclarator, IsFreeStanding,
2634 // isCompleteDefinitionRequired, ExtInfoKind
2635 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2636 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2637 // EnumDecl
2638 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2639 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2640 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2641 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2642 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2643 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2644 // DC
2645 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2646 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2647 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2648 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2649 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2650
2651 // Abbreviation for DECL_RECORD
2652 Abv = std::make_shared<BitCodeAbbrev>();
2653 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2654 // Redeclarable
2655 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2656 // Decl
2657 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2658 7)); // Packed DeclBits: ModuleOwnershipKind,
2659 // isUsed, isReferenced, AccessSpecifier,
2660 //
2661 // The following bits should be 0:
2662 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2663 // TopLevelDeclInObjCContainer,
2664 // isInvalidDecl
2665 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2666 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2667 // NamedDecl
2668 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2669 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2670 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2671 // TypeDecl
2672 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2673 // TagDecl
2674 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2675 Abv->Add(BitCodeAbbrevOp(
2676 BitCodeAbbrevOp::Fixed,
2677 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2678 // EmbeddedInDeclarator, IsFreeStanding,
2679 // isCompleteDefinitionRequired, ExtInfoKind
2680 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2681 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2682 // RecordDecl
2683 Abv->Add(BitCodeAbbrevOp(
2684 BitCodeAbbrevOp::Fixed,
2685 14)); // Packed Record Decl Bits: FlexibleArrayMember,
2686 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2687 // isNonTrivialToPrimitiveDefaultInitialize,
2688 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2689 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2690 // hasNonTrivialToPrimitiveDestructCUnion,
2691 // hasNonTrivialToPrimitiveCopyCUnion,
2692 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2693 // getArgPassingRestrictions
2694 // ODRHash
2695 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2696
2697 // DC
2698 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2699 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2700 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2701 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2702 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2703
2704 // Abbreviation for DECL_PARM_VAR
2705 Abv = std::make_shared<BitCodeAbbrev>();
2706 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2707 // Redeclarable
2708 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2709 // Decl
2710 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2711 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2712 // isReferenced, AccessSpecifier,
2713 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2714 // TopLevelDeclInObjCContainer,
2715 // isInvalidDecl,
2716 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2717 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2718 // NamedDecl
2719 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2720 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2721 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2722 // ValueDecl
2723 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2724 // DeclaratorDecl
2725 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2726 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2727 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2728 // VarDecl
2729 Abv->Add(
2730 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2731 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2732 // isARCPseudoStrong, Linkage, ModulesCodegen
2733 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2734 // ParmVarDecl
2735 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2736 Abv->Add(BitCodeAbbrevOp(
2737 BitCodeAbbrevOp::Fixed,
2738 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2739 // ObjCDeclQualifier, KNRPromoted,
2740 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2741 // Type Source Info
2742 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2743 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2744 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2745
2746 // Abbreviation for DECL_TYPEDEF
2747 Abv = std::make_shared<BitCodeAbbrev>();
2748 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2749 // Redeclarable
2750 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2751 // Decl
2752 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2753 7)); // Packed DeclBits: ModuleOwnershipKind,
2754 // isReferenced, isUsed, AccessSpecifier. Other
2755 // higher bits should be 0: isImplicit,
2756 // HasStandaloneLexicalDC, HasAttrs,
2757 // TopLevelDeclInObjCContainer, isInvalidDecl
2758 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2759 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2760 // NamedDecl
2761 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2762 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2763 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2764 // TypeDecl
2765 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2766 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2767 // TypedefDecl
2768 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2769 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2770 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2771
2772 // Abbreviation for DECL_VAR
2773 Abv = std::make_shared<BitCodeAbbrev>();
2774 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2775 // Redeclarable
2776 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2777 // Decl
2778 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2779 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2780 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2781 // isReferenced, TopLevelDeclInObjCContainer,
2782 // AccessSpecifier, ModuleOwnershipKind
2783 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2784 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2785 // NamedDecl
2786 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2787 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2788 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2789 // ValueDecl
2790 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2791 // DeclaratorDecl
2792 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2793 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2794 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2795 // VarDecl
2796 Abv->Add(BitCodeAbbrevOp(
2797 BitCodeAbbrevOp::Fixed,
2798 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2799 // SClass, TSCSpec, InitStyle,
2800 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2801 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2802 // isInline, isInlineSpecified, isConstexpr,
2803 // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
2804 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2805 // IsCXXForRangeImplicitVar
2806 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2807 // Type Source Info
2808 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2809 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2810 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2811
2812 // Abbreviation for DECL_CXX_METHOD
2813 DeclCXXMethodAbbrev =
2814 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2815 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2816 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2817 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2818 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2819 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2820 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2821 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2822 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2823 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2824 getCXXMethodAbbrev<
2826
2827 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2828 Abv = std::make_shared<BitCodeAbbrev>();
2829 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2830 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2831 // Decl
2832 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2833 7)); // Packed DeclBits: ModuleOwnershipKind,
2834 // isReferenced, isUsed, AccessSpecifier. Other
2835 // higher bits should be 0: isImplicit,
2836 // HasStandaloneLexicalDC, HasAttrs,
2837 // TopLevelDeclInObjCContainer, isInvalidDecl
2838 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2839 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2840 // NamedDecl
2841 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2842 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2843 Abv->Add(BitCodeAbbrevOp(0));
2844 // TypeDecl
2845 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2846 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2847 // TemplateTypeParmDecl
2848 Abv->Add(
2849 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2850 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2851 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2852
2853 // Abbreviation for DECL_USING_SHADOW
2854 Abv = std::make_shared<BitCodeAbbrev>();
2855 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2856 // Redeclarable
2857 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2858 // Decl
2859 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2860 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2861 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2862 // isReferenced, TopLevelDeclInObjCContainer,
2863 // AccessSpecifier, ModuleOwnershipKind
2864 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2865 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2866 // NamedDecl
2867 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2868 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2869 Abv->Add(BitCodeAbbrevOp(0));
2870 // UsingShadowDecl
2871 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2872 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2873 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2874 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2875 6)); // InstantiatedFromUsingShadowDecl
2876 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2877
2878 // Abbreviation for EXPR_DECL_REF
2879 Abv = std::make_shared<BitCodeAbbrev>();
2880 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2881 // Stmt
2882 // Expr
2883 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2884 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2885 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2886 // DeclRefExpr
2887 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2888 // IsImmediateEscalating, NonOdrUseReason.
2889 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2890 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2891 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2892 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2893 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2894
2895 // Abbreviation for EXPR_INTEGER_LITERAL
2896 Abv = std::make_shared<BitCodeAbbrev>();
2897 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2898 //Stmt
2899 // Expr
2900 // DependenceKind, ValueKind, ObjectKind
2901 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2902 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2903 // Integer Literal
2904 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2905 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2906 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2907 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2908
2909 // Abbreviation for EXPR_CHARACTER_LITERAL
2910 Abv = std::make_shared<BitCodeAbbrev>();
2911 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2912 //Stmt
2913 // Expr
2914 // DependenceKind, ValueKind, ObjectKind
2915 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2916 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2917 // Character Literal
2918 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2919 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2920 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2921 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2922
2923 // Abbreviation for EXPR_IMPLICIT_CAST
2924 Abv = std::make_shared<BitCodeAbbrev>();
2925 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2926 // Stmt
2927 // Expr
2928 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2929 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2930 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2931 // CastExpr
2932 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2933 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2934 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2935 // ImplicitCastExpr
2936 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2937
2938 // Abbreviation for EXPR_BINARY_OPERATOR
2939 Abv = std::make_shared<BitCodeAbbrev>();
2940 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2941 // Stmt
2942 // Expr
2943 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2944 // be 0 in this case.
2945 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2946 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2947 // BinaryOperator
2948 Abv->Add(
2949 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2950 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2951 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2952
2953 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2954 Abv = std::make_shared<BitCodeAbbrev>();
2955 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2956 // Stmt
2957 // Expr
2958 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2959 // be 0 in this case.
2960 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2961 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2962 // BinaryOperator
2963 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2964 Abv->Add(
2965 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2966 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2967 // CompoundAssignOperator
2968 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2969 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2970 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2971
2972 // Abbreviation for EXPR_CALL
2973 Abv = std::make_shared<BitCodeAbbrev>();
2974 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2975 // Stmt
2976 // Expr
2977 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2978 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2979 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2980 // CallExpr
2981 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2982 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2983 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2984 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2985
2986 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2987 Abv = std::make_shared<BitCodeAbbrev>();
2988 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2989 // Stmt
2990 // Expr
2991 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2992 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2993 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2994 // CallExpr
2995 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2996 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2997 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2998 // CXXOperatorCallExpr
2999 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
3000 Abv->Add(BitCodeAbbrevOp(0)); // IsReversed
3001 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3002 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
3003
3004 // Abbreviation for EXPR_CXX_MEMBER_CALL
3005 Abv = std::make_shared<BitCodeAbbrev>();
3006 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
3007 // Stmt
3008 // Expr
3009 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
3010 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
3011 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
3012 // CallExpr
3013 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
3014 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
3015 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3016 // CXXMemberCallExpr
3017 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
3018
3019 // Abbreviation for STMT_COMPOUND
3020 Abv = std::make_shared<BitCodeAbbrev>();
3021 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
3022 // Stmt
3023 // CompoundStmt
3024 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
3025 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
3026 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3027 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3028 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
3029
3030 Abv = std::make_shared<BitCodeAbbrev>();
3031 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
3032 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3033 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
3034
3035 Abv = std::make_shared<BitCodeAbbrev>();
3036 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
3037 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3038 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3039
3040 Abv = std::make_shared<BitCodeAbbrev>();
3041 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
3042 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3043 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3044
3045 Abv = std::make_shared<BitCodeAbbrev>();
3046 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
3047 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3048 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3049
3050 Abv = std::make_shared<BitCodeAbbrev>();
3051 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
3052 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3053 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
3054
3055 Abv = std::make_shared<BitCodeAbbrev>();
3056 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
3057 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3058 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
3059}
3060
3061/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
3062/// consumers of the AST.
3063///
3064/// Such decls will always be deserialized from the AST file, so we would like
3065/// this to be as restrictive as possible. Currently the predicate is driven by
3066/// code generation requirements, if other clients have a different notion of
3067/// what is "required" then we may have to consider an alternate scheme where
3068/// clients can iterate over the top-level decls and get information on them,
3069/// without necessary deserializing them. We could explicitly require such
3070/// clients to use a separate API call to "realize" the decl. This should be
3071/// relatively painless since they would presumably only do it for top-level
3072/// decls.
3073static bool isRequiredDecl(const Decl *D, ASTContext &Context,
3074 Module *WritingModule) {
3075 // Named modules have different semantics than header modules. Every named
3076 // module units owns a translation unit. So the importer of named modules
3077 // doesn't need to deserilize everything ahead of time.
3078 if (WritingModule && WritingModule->isNamedModule()) {
3079 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
3080 // And the behavior of MSVC for such cases will leak this to the module
3081 // users. Given pragma is not a standard thing, the compiler has the space
3082 // to do their own decision. Let's follow MSVC here.
3084 return true;
3085 return false;
3086 }
3087
3088 // An ObjCMethodDecl is never considered as "required" because its
3089 // implementation container always is.
3090
3091 // File scoped assembly or obj-c or OMP declare target implementation must be
3092 // seen.
3094 return true;
3095
3096 if (WritingModule && isPartOfPerModuleInitializer(D)) {
3097 // These declarations are part of the module initializer, and are emitted
3098 // if and when the module is imported, rather than being emitted eagerly.
3099 return false;
3100 }
3101
3102 return Context.DeclMustBeEmitted(D);
3103}
3104
3105void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
3106 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
3107 "serializing");
3108
3109 // Determine the ID for this declaration.
3110 LocalDeclID ID;
3111 assert(!D->isFromASTFile() && "should not be emitting imported decl");
3112 LocalDeclID &IDR = DeclIDs[D];
3113 if (IDR.isInvalid())
3114 IDR = NextDeclID++;
3115
3116 ID = IDR;
3117
3118 assert(ID >= FirstDeclID && "invalid decl ID");
3119
3121 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
3122
3123 // Build a record for this declaration
3124 W.Visit(D);
3125
3126 // Emit this declaration to the bitstream.
3127 uint64_t Offset = W.Emit(D);
3128
3129 // Record the offset for this declaration
3130 SourceLocation Loc = D->getLocation();
3132 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
3133
3134 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
3135 if (DeclOffsets.size() == Index)
3136 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
3137 else if (DeclOffsets.size() < Index) {
3138 // FIXME: Can/should this happen?
3139 DeclOffsets.resize(Index+1);
3140 DeclOffsets[Index].setRawLoc(RawLoc);
3141 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
3142 } else {
3143 llvm_unreachable("declarations should be emitted in ID order");
3144 }
3145
3146 SourceManager &SM = Context.getSourceManager();
3147 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
3148 associateDeclWithFile(D, ID);
3149
3150 // Note declarations that should be deserialized eagerly so that we can add
3151 // them to a record in the AST file later.
3152 if (isRequiredDecl(D, Context, WritingModule))
3153 AddDeclRef(D, EagerlyDeserializedDecls);
3154}
3155
3157 // Switch case IDs are per function body.
3158 Writer->ClearSwitchCaseIDs();
3159
3160 assert(FD->doesThisDeclarationHaveABody());
3161 bool ModulesCodegen = shouldFunctionGenerateHereOnly(FD);
3162 Record->push_back(ModulesCodegen);
3163 if (ModulesCodegen)
3164 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3165 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3166 Record->push_back(CD->getNumCtorInitializers());
3167 if (CD->getNumCtorInitializers())
3168 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3169 }
3170 AddStmt(FD->getBody());
3171}
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
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:239
SourceManager & getSourceManager()
Definition ASTContext.h:911
const LangOptions & getLangOpts() const
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 VisitCXXExpansionStmtDecl(CXXExpansionStmtDecl *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:98
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:807
SmallVectorImpl< uint64_t > RecordDataImpl
Definition ASTWriter.h:104
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc)
Return the raw encodings for source locations.
friend class ASTDeclWriter
Definition ASTWriter.h:100
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:103
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:4215
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition DeclCXX.h:4241
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
Definition ASTWriter.h:1108
void addBit(bool Value)
Definition ASTWriter.h:1128
void addBits(uint32_t Value, uint32_t BitsWidth)
Definition ASTWriter.h:1129
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4810
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition Decl.h:4933
bool canAvoidCopyToHeap() const
Definition Decl.h:4964
size_t param_size() const
Definition Decl.h:4912
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:4889
ArrayRef< Capture > captures() const
Definition Decl.h:4937
bool blockMissingReturnType() const
Definition Decl.h:4945
bool capturesCXXThis() const
Definition Decl.h:4942
bool doesNotEscape() const
Definition Decl.h:4961
bool isConversionFromLambda() const
Definition Decl.h:4953
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:4896
bool isVariadic() const
Definition Decl.h:4885
TypeSourceInfo * getSignatureAsWritten() const
Definition Decl.h:4893
Represents a C++ constructor within a class.
Definition DeclCXX.h:2642
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition DeclCXX.h:2877
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs() const
Definition DeclCXX.cpp:3139
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2977
ExplicitSpecifier getExplicitSpecifier() const
Definition DeclCXX.h:3004
Represents a C++ deduction guide declaration.
Definition DeclCXX.h:2001
ExplicitSpecifier getExplicitSpecifier() const
Definition DeclCXX.h:2059
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:2076
DeductionCandidate getDeductionCandidateKind() const
Definition DeclCXX.h:2096
SourceDeductionGuideKind getSourceDeductionGuideKind() const
Definition DeclCXX.h:2084
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1275
Represents a C++ destructor within a class.
Definition DeclCXX.h:2907
const FunctionDecl * getOperatorGlobalDelete() const
Definition DeclCXX.cpp:3235
const FunctionDecl * getGlobalArrayOperatorDelete() const
Definition DeclCXX.cpp:3245
const FunctionDecl * getOperatorDelete() const
Definition DeclCXX.cpp:3230
Expr * getOperatorDeleteThisArg() const
Definition DeclCXX.h:2946
const FunctionDecl * getArrayOperatorDelete() const
Definition DeclCXX.cpp:3240
Represents a C++26 expansion statement declaration.
CXXExpansionStmtPattern * getExpansionPattern()
CXXExpansionStmtInstantiation * getInstantiations()
NonTypeTemplateParmDecl * getIndexTemplateParm()
Represents a static or instance method of a struct/union/class.
Definition DeclCXX.h:2150
CXXMethodDecl * getMostRecentDecl()
Definition DeclCXX.h:2270
overridden_method_range overridden_methods() const
Definition DeclCXX.cpp:2828
unsigned size_overridden_methods() const
Definition DeclCXX.cpp:2822
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:1836
unsigned getLambdaIndexInContext() const
Retrieve the index of this lambda within the context declaration returned by getLambdaContextDecl().
Definition DeclCXX.h:1817
bool isLambda() const
Determine whether this class describes a lambda function object.
Definition DeclCXX.h:1028
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition DeclCXX.cpp:2062
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition DeclCXX.cpp:2054
static bool classofKind(Kind K)
Definition DeclCXX.h:1941
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
Definition DeclCXX.cpp:2039
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Definition DeclCXX.cpp:1744
CXXRecordDecl * getPreviousDecl()
Definition DeclCXX.h:531
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:5082
unsigned getNumParams() const
Definition Decl.h:5120
unsigned getContextParamPosition() const
Definition Decl.h:5149
bool isNothrow() const
Definition Decl.cpp:5777
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5122
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:3707
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:1466
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2126
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Definition DeclBase.h:2142
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:126
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:1078
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition DeclBase.h:1093
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:1243
bool hasAttrs() const
Definition DeclBase.h:526
ASTContext & getASTContext() const LLVM_READONLY
Definition DeclBase.cpp:550
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:100
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
Definition DeclBase.h:893
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition DeclBase.cpp:604
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition DeclBase.h:1001
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:854
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition DeclBase.h:805
bool isInvalidDecl() const
Definition DeclBase.h:596
unsigned getIdentifierNamespace() const
Definition DeclBase.h:906
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:579
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:935
bool hasAttr() const
Definition DeclBase.h:585
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:995
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:781
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:823
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:810
A decomposition declaration.
Definition DeclCXX.h:4279
ArrayRef< BindingDecl * > bindings() const
Definition DeclCXX.h:4319
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:5317
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3558
llvm::APSInt getInitVal() const
Definition Decl.h:3578
const Expr * getInitExpr() const
Definition Decl.h:3576
Represents an enum.
Definition Decl.h:4146
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition Decl.h:4418
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4364
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition Decl.h:4356
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4367
unsigned getODRHash()
Definition Decl.cpp:5238
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Definition Decl.h:4335
EnumDecl * getMostRecentDecl()
Definition Decl.h:4251
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition Decl.h:4373
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition Decl.h:4319
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
Definition Decl.h:4345
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition Decl.h:4311
Represents an explicit instantiation of a template entity in source code.
TemplateSpecializationKind getTemplateSpecializationKind() const
SourceLocation getExternLoc() const
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:1949
ExplicitSpecKind getKind() const
Definition DeclCXX.h:1957
const Expr * getExpr() const
Definition DeclCXX.h:1958
Represents a standard C++ module export declaration.
Definition Decl.h:5270
SourceLocation getRBraceLoc() const
Definition Decl.h:5289
This represents one expression.
Definition Expr.h:113
Represents a member of a struct/union/class.
Definition Decl.h:3295
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition Decl.h:3395
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition Decl.h:3475
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition Decl.h:3514
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
Definition Decl.h:3411
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition Decl.h:3519
const Expr * getAsmStringExpr() const
Definition Decl.h:4755
SourceLocation getRParenLoc() const
Definition Decl.h:4749
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition DeclFriend.h:46
FriendUnion Friend
Definition DeclFriend.h:63
virtual NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition DeclFriend.h:102
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition DeclFriend.h:96
FriendDecl * getNextFriend()
Definition DeclFriend.h:74
Declaration of a friend template.
NamedDecl * getFriendDecl() const override
If this friend declaration doesn't name a type, return the inner declaration.
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
Represents a function declaration or definition.
Definition Decl.h:2059
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Definition Decl.h:2820
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition Decl.cpp:3266
bool isTrivialForCall() const
Definition Decl.h:2507
ConstexprSpecKind getConstexprKind() const
Definition Decl.h:2603
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
Definition Decl.cpp:3181
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition Decl.cpp:4232
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
Definition Decl.cpp:3593
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
Definition Decl.h:3052
SourceLocation getDefaultLoc() const
Definition Decl.h:2525
bool usesSEHTry() const
Indicates the function uses __try.
Definition Decl.h:2645
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2905
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
Definition Decl.h:2516
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition Decl.h:2504
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Definition Decl.h:2575
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
Definition Decl.cpp:4211
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition Decl.cpp:4362
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition Decl.h:2440
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition Decl.cpp:4428
unsigned getODRHash()
Returns ODRHash of the function.
Definition Decl.cpp:4744
@ TK_FunctionTemplateSpecialization
Definition Decl.h:2075
@ TK_DependentFunctionTemplateSpecialization
Definition Decl.h:2078
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:3019
bool FriendConstraintRefersToEnclosingTemplate() const
Definition Decl.h:2838
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition Decl.cpp:4183
bool isDeletedAsWritten() const
Definition Decl.h:2671
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
Definition Decl.h:2480
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition Decl.h:2484
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
Definition Decl.h:2555
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Definition Decl.h:2810
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
Definition Decl.cpp:3601
bool isDefaulted() const
Whether this function is defaulted.
Definition Decl.h:2512
bool isIneligibleOrNotSelected() const
Definition Decl.h:2545
FunctionDecl * getInstantiatedFromDecl() const
Definition Decl.cpp:4256
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition Decl.h:2471
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition Decl.h:2586
size_t param_size() const
Definition Decl.h:2921
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition Decl.h:3030
bool isInstantiatedFromMemberTemplate() const
Definition Decl.h:2493
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:5332
bool isCBuffer() const
Definition Decl.h:5376
SourceLocation getLBraceLoc() const
Definition Decl.h:5373
SourceLocation getLocStart() const LLVM_READONLY
Definition Decl.h:5372
SourceLocation getRBraceLoc() const
Definition Decl.h:5374
ArrayRef< TemplateArgument > getTemplateArguments() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5191
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:6148
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition Decl.h:5249
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3602
unsigned getChainingSize() const
Definition Decl.h:3627
ArrayRef< NamedDecl * > chain() const
Definition Decl.h:3623
Represents the declaration of a label.
Definition Decl.h:525
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition DeclCXX.h:3338
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition DeclCXX.h:3384
Represents a linkage specification.
Definition DeclCXX.h:3045
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition DeclCXX.h:3068
SourceLocation getExternLoc() const
Definition DeclCXX.h:3084
SourceLocation getRBraceLoc() const
Definition DeclCXX.h:3085
A global _GUID constant.
Definition DeclCXX.h:4451
Parts getParts() const
Get the decomposed parts of this declaration.
Definition DeclCXX.h:4481
MSGuidDeclParts Parts
Definition DeclCXX.h:4453
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4397
IdentifierInfo * getGetterId() const
Definition DeclCXX.h:4419
IdentifierInfo * getSetterId() const
Definition DeclCXX.h:4421
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:340
bool isInterfaceOrPartition() const
Definition Module.h:889
bool isNamedModule() const
Does this Module is a named module of a standard named module?
Definition Module.h:423
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
Definition Module.h:940
This represents a decl that may have a name.
Definition Decl.h:275
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:1183
bool isPlaceholderVar(const LangOptions &LangOpts) const
Definition Decl.cpp:1096
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:341
Represents a C++ namespace alias.
Definition DeclCXX.h:3231
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3292
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3317
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition DeclCXX.h:3320
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition DeclCXX.h:3301
Represent a C++ namespace.
Definition Decl.h:593
SourceLocation getRBraceLoc() const
Definition Decl.h:693
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:692
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition Decl.h:644
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition Decl.h:649
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
Definition Decl.h:676
bool isNested() const
Returns true if this is a nested namespace declaration.
Definition Decl.h:658
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:2036
static bool classofKind(Kind K)
Definition DeclObjC.h:2057
ObjCCategoryDecl - Represents a category declaration.
Definition DeclObjC.h:2335
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:2423
unsigned protocol_size() const
Definition DeclObjC.h:2418
ObjCInterfaceDecl * getClassInterface()
Definition DeclObjC.h:2378
SourceLocation getIvarLBraceLoc() const
Definition DeclObjC.h:2470
SourceLocation getIvarRBraceLoc() const
Definition DeclObjC.h:2472
protocol_range protocols() const
Definition DeclObjC.h:2409
SourceLocation getCategoryNameLoc() const
Definition DeclObjC.h:2466
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition DeclObjC.h:2551
SourceLocation getCategoryNameLoc() const
Definition DeclObjC.h:2578
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition DeclObjC.h:2781
const ObjCInterfaceDecl * getClassInterface() const
Definition DeclObjC.h:2799
ObjCContainerDecl - Represents a container for method declarations.
Definition DeclObjC.h:954
SourceRange getAtEndRange() const
Definition DeclObjC.h:1109
SourceLocation getAtStartLoc() const
Definition DeclObjC.h:1102
const ObjCInterfaceDecl * getClassInterface() const
Definition DeclObjC.h:2492
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition DeclObjC.h:2603
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition DeclObjC.h:2684
SourceLocation getIvarRBraceLoc() const
Definition DeclObjC.h:2750
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition DeclObjC.h:2708
SourceLocation getSuperClassLoc() const
Definition DeclObjC.h:2743
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction?
Definition DeclObjC.h:2713
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition DeclObjC.h:2675
const ObjCInterfaceDecl * getSuperClass() const
Definition DeclObjC.h:2741
SourceLocation getIvarLBraceLoc() const
Definition DeclObjC.h:2748
Represents an ObjC class declaration.
Definition DeclObjC.h:1160
protocol_range protocols() const
Definition DeclObjC.h:1365
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition DeclObjC.cpp:788
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:1394
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition DeclObjC.h:1791
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition DeclObjC.h:1529
const Type * getTypeForDecl() const
Definition DeclObjC.h:1925
SourceLocation getEndOfDefinitionLoc() const
Definition DeclObjC.h:1884
TypeSourceInfo * getSuperClassTInfo() const
Definition DeclObjC.h:1579
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1958
AccessControl getAccessControl() const
Definition DeclObjC.h:2006
bool getSynthesize() const
Definition DeclObjC.h:2013
static bool classofKind(Kind K)
Definition DeclObjC.h:2021
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:421
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
Definition DeclObjC.h:465
ObjCDeclQualifier getObjCDeclQualifier() const
Definition DeclObjC.h:246
ArrayRef< ParmVarDecl * > parameters() const
Definition DeclObjC.h:376
unsigned param_size() const
Definition DeclObjC.h:350
bool isPropertyAccessor() const
Definition DeclObjC.h:439
bool isVariadic() const
Definition DeclObjC.h:434
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition DeclObjC.cpp:927
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition DeclObjC.h:346
bool hasRedeclaration() const
True if redeclared in the same interface.
Definition DeclObjC.h:274
bool isSynthesizedAccessorStub() const
Definition DeclObjC.h:447
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
Definition DeclObjC.h:259
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
Definition DeclObjC.h:269
ImplicitParamDecl * getCmdDecl() const
Definition DeclObjC.h:423
bool isInstanceMethod() const
Definition DeclObjC.h:429
bool isDefined() const
Definition DeclObjC.h:455
QualType getReturnType() const
Definition DeclObjC.h:332
ObjCImplementationControl getImplementationControl() const
Definition DeclObjC.h:503
bool hasSkippedBody() const
True if the method was a definition but its body was skipped.
Definition DeclObjC.h:480
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:734
SourceLocation getGetterNameLoc() const
Definition DeclObjC.h:892
ObjCMethodDecl * getGetterMethodDecl() const
Definition DeclObjC.h:907
ObjCMethodDecl * getSetterMethodDecl() const
Definition DeclObjC.h:910
SourceLocation getSetterNameLoc() const
Definition DeclObjC.h:900
SourceLocation getAtLoc() const
Definition DeclObjC.h:802
ObjCIvarDecl * getPropertyIvarDecl() const
Definition DeclObjC.h:930
Selector getSetterName() const
Definition DeclObjC.h:899
TypeSourceInfo * getTypeSourceInfo() const
Definition DeclObjC.h:808
QualType getType() const
Definition DeclObjC.h:810
Selector getGetterName() const
Definition DeclObjC.h:891
SourceLocation getLParenLoc() const
Definition DeclObjC.h:805
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
Definition DeclObjC.h:833
ObjCPropertyAttribute::Kind getPropertyAttributes() const
Definition DeclObjC.h:821
PropertyControl getPropertyImplementation() const
Definition DeclObjC.h:918
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition DeclObjC.h:2811
ObjCIvarDecl * getPropertyIvarDecl() const
Definition DeclObjC.h:2885
SourceLocation getPropertyIvarDeclLoc() const
Definition DeclObjC.h:2888
Expr * getSetterCXXAssignment() const
Definition DeclObjC.h:2921
ObjCPropertyDecl * getPropertyDecl() const
Definition DeclObjC.h:2876
Expr * getGetterCXXConstructor() const
Definition DeclObjC.h:2913
ObjCMethodDecl * getSetterMethodDecl() const
Definition DeclObjC.h:2910
SourceLocation getBeginLoc() const LLVM_READONLY
Definition DeclObjC.h:2873
ObjCMethodDecl * getGetterMethodDecl() const
Definition DeclObjC.h:2907
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2090
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition DeclObjC.h:2267
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:2188
protocol_range protocols() const
Definition DeclObjC.h:2167
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
unsigned protocol_size() const
Definition DeclObjC.h:2206
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:581
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition DeclObjC.h:665
unsigned size() const
Determine the number of type parameters in this list.
Definition DeclObjC.h:692
SourceLocation getRAngleLoc() const
Definition DeclObjC.h:714
SourceLocation getLAngleLoc() const
Definition DeclObjC.h:713
ArrayRef< const OpenACCClause * > clauses() const
Definition DeclOpenACC.h:62
Represents a partial function definition.
Definition Decl.h:5017
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5049
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:5748
unsigned getNumParams() const
Definition Decl.h:5047
Represents a parameter to a function.
Definition Decl.h:1820
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion:
Definition Decl.h:1901
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1880
SourceLocation getExplicitObjectParamThisLoc() const
Definition Decl.h:1916
bool isObjCMethodParameter() const
Definition Decl.h:1863
ObjCDeclQualifier getObjCDeclQualifier() const
Definition Decl.h:1884
bool hasUninstantiatedDefaultArg() const
Definition Decl.h:1953
bool hasInheritedDefaultArg() const
Definition Decl.h:1965
Expr * getUninstantiatedDefaultArg()
Definition Decl.cpp:3038
unsigned getFunctionScopeDepth() const
Definition Decl.h:1870
Represents a #pragma comment line.
Definition Decl.h:168
StringRef getArg() const
Definition Decl.h:191
PragmaMSCommentKind getCommentKind() const
Definition Decl.h:189
Represents a #pragma detect_mismatch line.
Definition Decl.h:202
StringRef getName() const
Definition Decl.h:223
StringRef getValue() const
Definition Decl.h:224
A (possibly-)qualified type.
Definition TypeBase.h:938
Represents a struct/union/class.
Definition Decl.h:4460
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition Decl.cpp:5489
bool hasNonTrivialToPrimitiveDestructCUnion() const
Definition Decl.h:4570
bool hasNonTrivialToPrimitiveCopyCUnion() const
Definition Decl.h:4578
RecordArgPassingKind getArgPassingRestrictions() const
Definition Decl.h:4601
bool hasVolatileMember() const
Definition Decl.h:4523
bool hasFlexibleArrayMember() const
Definition Decl.h:4493
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Definition Decl.h:4562
bool hasObjectMember() const
Definition Decl.h:4520
bool isNonTrivialToPrimitiveDestroy() const
Definition Decl.h:4554
bool isNonTrivialToPrimitiveCopy() const
Definition Decl.h:4546
bool isParamDestroyedInCallee() const
Definition Decl.h:4610
RecordDecl * getMostRecentDecl()
Definition Decl.h:4486
bool hasUninitializedExplicitInitFields() const
Definition Decl.h:4586
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition Decl.h:4538
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition Decl.h:4512
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:2119
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isLocalSourceLocation(SourceLocation Loc) const
Returns true if Loc did not come from a PCH/Module.
Represents a C++11 static_assert declaration.
Definition DeclCXX.h:4166
bool isFailed() const
Definition DeclCXX.h:4195
SourceLocation getRParenLoc() const
Definition DeclCXX.h:4197
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1819
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3852
SourceRange getBraceRange() const
Definition Decl.h:3929
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition Decl.h:3948
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:3977
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:3953
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition Decl.h:4089
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition Decl.h:3962
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
Definition Decl.h:3988
TagKind getTagKind() const
Definition Decl.h:4052
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.
bool isNull() const
Determine whether this template name is NULL.
A template parameter object.
const APValue & getValue() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
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:4770
unsigned getOrdinal() const
Definition Decl.h:4794
The top declaration context.
Definition Decl.h:106
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition Decl.h:3823
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition Decl.h:3841
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:3648
const Type * getTypeForDecl() const
Definition Decl.h:3673
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:3682
QualType getType() const
Return the type wrapped by this type source info.
Definition TypeBase.h:8428
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition Type.cpp:2233
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3802
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3697
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:3747
TypedefNameDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isModed() const
Definition Decl.h:3743
QualType getUnderlyingType() const
Definition Decl.h:3752
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
Definition Decl.cpp:5846
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4508
const APValue & getValue() const
Definition DeclCXX.h:4534
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition DeclCXX.h:4148
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4067
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition DeclCXX.h:4097
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4101
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4118
Represents a dependent using declaration which was not marked with typename.
Definition DeclCXX.h:3970
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition DeclCXX.h:4001
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4011
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4028
Represents a C++ using-declaration.
Definition DeclCXX.h:3621
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition DeclCXX.h:3670
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3655
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition DeclCXX.h:3648
Represents C++ using-directive.
Definition DeclCXX.h:3126
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition DeclCXX.h:3197
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition DeclCXX.cpp:3357
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition DeclCXX.h:3193
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3201
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3171
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3822
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
Definition DeclCXX.h:3846
TypeSourceInfo * getEnumType() const
Definition DeclCXX.h:3858
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Definition DeclCXX.h:3842
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition DeclCXX.h:3903
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition DeclCXX.h:3932
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition DeclCXX.h:3936
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3429
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:3493
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:713
QualType getType() const
Definition Decl.h:724
Represents a variable declaration or definition.
Definition Decl.h:933
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition Decl.cpp:2780
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition Decl.h:1594
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition Decl.h:1491
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition Decl.h:1603
@ CInit
C-style initialization with assignment.
Definition Decl.h:938
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C.
Definition Decl.h:1557
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
Definition Decl.cpp:2424
bool isInlineSpecified() const
Definition Decl.h:1579
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition Decl.h:1307
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
Definition Decl.h:1547
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition Decl.h:1537
bool isCXXForRangeImplicitVar() const
Whether this variable is the implicit '__range' variable in C++ range-based for loops.
Definition Decl.h:1647
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition Decl.h:1519
bool isInline() const
Whether this variable is (C++1z) inline.
Definition Decl.h:1576
ThreadStorageClassSpecifier getTSCSpec() const
Definition Decl.h:1184
const Expr * getInit() const
Definition Decl.h:1392
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition Decl.h:1572
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition Decl.h:1251
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1175
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
Definition Decl.cpp:2681
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition Decl.h:1501
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition Decl.h:1613
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:2749
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Definition Decl.cpp:2868
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.
FriendTemplateDeclKind
Kinds of friend payloads owned by FriendTemplateDecl.
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_EXPANSION_STMT
A C++ expansion statement.
@ 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
Top level wrappers for InstallAPI frontend operations.
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:131
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:344
@ SD_Static
Static storage duration.
Definition Specifiers.h:345
const FunctionProtoType * T
@ 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:579
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:210
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition Specifiers.h:206
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:89
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:90
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition Expr.h:6768
Data that is common to all of the declarations of a given function template.
uint16_t Part2
...-89ab-...
Definition DeclCXX.h:4430
uint32_t Part1
{01234567-...
Definition DeclCXX.h:4428
uint16_t Part3
...-cdef-...
Definition DeclCXX.h:4432
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition DeclCXX.h:4434
static DeclType * getDecl(EntryType *D)