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 // Functions excluded from explicit instantiation are emitted by every user
399 // instead, as they are usually hidden and the module's object file may be
400 // linked into a different shared library.
401 if (!FD->hasAttr<AlwaysInlineAttr>() &&
402 !FD->hasAttr<ExcludeFromExplicitInstantiationAttr>() &&
404 return true;
405
406 Module *M = FD->getOwningModule();
407 if (!M)
408 return false;
409
410 M = M->getTopLevelModule();
411 if (M->isInterfaceOrPartition())
413 return true;
414
415 return false;
416}
417
419 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
420 if (FD->isInlined() || FD->isConstexpr() || FD->isConsteval())
421 return false;
422
423 // If the function should be generated somewhere else, we shouldn't elide
424 // it.
426 return false;
427 }
428
429 if (auto *VD = dyn_cast<VarDecl>(D)) {
430 if (VD->getDeclContext()->isDependentContext())
431 return false;
432
433 // Constant initialized variable may not affect the ABI, but they
434 // may be used in constant evaluation in the frontend, so we have
435 // to remain them.
436 if (VD->hasConstantInitialization() || VD->isConstexpr())
437 return false;
438
439 // If the variable should be generated somewhere else, we shouldn't elide
440 // it.
442 return false;
443 }
444
445 return true;
446}
447
450
451 // Source locations require array (variable-length) abbreviations. The
452 // abbreviation infrastructure requires that arrays are encoded last, so
453 // we handle it here in the case of those classes derived from DeclaratorDecl
454 if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
455 if (auto *TInfo = DD->getTypeSourceInfo())
456 Record.AddTypeLoc(TInfo->getTypeLoc());
457 }
458
459 // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
460 // have been written. We want it last because we will not read it back when
461 // retrieving it from the AST, we'll just lazily set the offset.
462 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
463 if (!GeneratingReducedBMI || !CanElideDeclDef(FD)) {
464 Record.push_back(FD->doesThisDeclarationHaveABody());
465 if (FD->doesThisDeclarationHaveABody())
466 Record.AddFunctionDefinition(FD);
467 } else
468 Record.push_back(0);
469 }
470
471 // Similar to FunctionDecls, handle VarDecl's initializer here and write it
472 // after all other Stmts/Exprs. We will not read the initializer until after
473 // we have finished recursive deserialization, because it can recursively
474 // refer back to the variable.
475 if (auto *VD = dyn_cast<VarDecl>(D)) {
476 if (!GeneratingReducedBMI || !CanElideDeclDef(VD))
477 Record.AddVarDeclInit(VD);
478 else
479 Record.push_back(0);
480 }
481
482 // And similarly for FieldDecls. We already serialized whether there is a
483 // default member initializer.
484 if (auto *FD = dyn_cast<FieldDecl>(D)) {
485 if (FD->hasInClassInitializer()) {
486 if (Expr *Init = FD->getInClassInitializer()) {
487 Record.push_back(1);
488 Record.AddStmt(Init);
489 } else {
490 Record.push_back(0);
491 // Initializer has not been instantiated yet.
492 }
493 }
494 }
495
496 // If this declaration is also a DeclContext, write blocks for the
497 // declarations that lexically stored inside its context and those
498 // declarations that are visible from its context.
499 if (auto *DC = dyn_cast<DeclContext>(D))
501}
502
504 BitsPacker DeclBits;
505
506 // The order matters here. It will be better to put the bit with higher
507 // probability to be 0 in the end of the bits.
508 //
509 // Since we're using VBR6 format to store it.
510 // It will be pretty effient if all the higher bits are 0.
511 // For example, if we need to pack 8 bits into a value and the stored value
512 // is 0xf0, the actual stored value will be 0b000111'110000, which takes 12
513 // bits actually. However, if we changed the order to be 0x0f, then we can
514 // store it as 0b001111, which takes 6 bits only now.
515 DeclBits.addBits((uint64_t)D->getModuleOwnershipKind(), /*BitWidth=*/3);
516 DeclBits.addBit(D->isThisDeclarationReferenced());
517 // If we're writing a BMI for a named module unit, we can treat all decls as in
518 // the BMI as used. Otherwise, the consumer need to mark it as used again, this
519 // simply waste time.
520 DeclBits.addBit(Writer.isWritingStdCXXNamedModules() ? true : D->isUsed(false));
521 DeclBits.addBits(D->getAccess(), /*BitWidth=*/2);
522 DeclBits.addBit(D->isImplicit());
523 DeclBits.addBit(D->getDeclContext() != D->getLexicalDeclContext());
524 DeclBits.addBit(D->hasAttrs());
526 DeclBits.addBit(D->isInvalidDecl());
527 Record.push_back(DeclBits);
528
529 Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
530 if (D->getDeclContext() != D->getLexicalDeclContext())
531 Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
532
533 if (D->hasAttrs())
534 Record.AddAttributes(D->getAttrs());
535
536 Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
537
538 // If this declaration injected a name into a context different from its
539 // lexical context, and that context is an imported namespace, we need to
540 // update its visible declarations to include this name.
541 //
542 // This happens when we instantiate a class with a friend declaration or a
543 // function with a local extern declaration, for instance.
544 //
545 // FIXME: Can we handle this in AddedVisibleDecl instead?
546 if (D->isOutOfLine()) {
547 auto *DC = D->getDeclContext();
548 while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
549 if (!NS->isFromASTFile())
550 break;
551 Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
552 if (!NS->isInlineNamespace())
553 break;
554 DC = NS->getParent();
555 }
556 }
557}
558
560 StringRef Arg = D->getArg();
561 Record.push_back(Arg.size());
562 VisitDecl(D);
563 Record.AddSourceLocation(D->getBeginLoc());
564 Record.push_back(D->getCommentKind());
565 Record.AddString(Arg);
567}
568
571 StringRef Name = D->getName();
572 StringRef Value = D->getValue();
573 Record.push_back(Name.size() + 1 + Value.size());
574 VisitDecl(D);
575 Record.AddSourceLocation(D->getBeginLoc());
576 Record.AddString(Name);
577 Record.AddString(Value);
579}
580
582 llvm_unreachable("Translation units aren't directly serialized");
583}
584
586 VisitDecl(D);
587 Record.AddDeclarationName(D->getDeclName());
588 Record.push_back(needsAnonymousDeclarationNumber(D)
589 ? Writer.getAnonymousDeclarationNumber(D)
590 : 0);
591}
592
595 Record.AddSourceLocation(D->getBeginLoc());
597 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
598}
599
602 VisitTypeDecl(D);
603 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
604 Record.push_back(D->isModed());
605 if (D->isModed())
606 Record.AddTypeRef(D->getUnderlyingType());
607 Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
608}
609
612 if (D->getDeclContext() == D->getLexicalDeclContext() &&
613 !D->hasAttrs() &&
614 !D->isImplicit() &&
615 D->getFirstDecl() == D->getMostRecentDecl() &&
616 !D->isInvalidDecl() &&
618 !D->isModulePrivate() &&
621 AbbrevToUse = Writer.getDeclTypedefAbbrev();
622
624}
625
631
633 static_assert(DeclContext::NumTagDeclBits == 22,
634 "You need to update the serializer after you change the "
635 "TagDeclBits");
636
638 VisitTypeDecl(D);
639 Record.push_back(D->getIdentifierNamespace());
640
641 BitsPacker TagDeclBits;
642 TagDeclBits.addBits(llvm::to_underlying(D->getTagKind()), /*BitWidth=*/3);
643 TagDeclBits.addBit(!isa<CXXRecordDecl>(D) ? D->isCompleteDefinition() : 0);
644 TagDeclBits.addBit(D->isEmbeddedInDeclarator());
645 TagDeclBits.addBit(D->isFreeStanding());
646 TagDeclBits.addBit(D->isCompleteDefinitionRequired());
647 TagDeclBits.addBits(
648 D->hasExtInfo() ? 1 : (D->getTypedefNameForAnonDecl() ? 2 : 0),
649 /*BitWidth=*/2);
650 Record.push_back(TagDeclBits);
651
652 Record.AddSourceRange(D->getBraceRange());
653
654 if (D->hasExtInfo()) {
655 Record.AddQualifierInfo(*D->getExtInfo());
656 } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
657 Record.AddDeclRef(TD);
658 Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
659 }
660}
661
663 static_assert(DeclContext::NumEnumDeclBits == 42,
664 "You need to update the serializer after you change the "
665 "EnumDeclBits");
666
667 VisitTagDecl(D);
668 Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
669 if (!D->getIntegerTypeSourceInfo())
670 Record.AddTypeRef(D->getIntegerType());
671 Record.AddTypeRef(D->getPromotionType());
672
673 BitsPacker EnumDeclBits;
674 EnumDeclBits.addBits(D->getNumPositiveBits(), /*BitWidth=*/8);
675 EnumDeclBits.addBits(D->getNumNegativeBits(), /*BitWidth=*/8);
676 EnumDeclBits.addBit(D->isScoped());
677 EnumDeclBits.addBit(D->isScopedUsingClassTag());
678 EnumDeclBits.addBit(D->isFixed());
679 Record.push_back(EnumDeclBits);
680
681 Record.push_back(D->getODRHash());
682
684 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
685 Record.push_back(MemberInfo->getTemplateSpecializationKind());
686 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
687 } else {
688 Record.AddDeclRef(nullptr);
689 }
690
691 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
692 !D->isInvalidDecl() && !D->isImplicit() && !D->hasExtInfo() &&
694 D->getFirstDecl() == D->getMostRecentDecl() &&
700 AbbrevToUse = Writer.getDeclEnumAbbrev();
701
703}
704
706 static_assert(DeclContext::NumRecordDeclBits == 63,
707 "You need to update the serializer after you change the "
708 "RecordDeclBits");
709
710 VisitTagDecl(D);
711
712 BitsPacker RecordDeclBits;
713 RecordDeclBits.addBit(D->hasFlexibleArrayMember());
714 RecordDeclBits.addBit(D->isAnonymousStructOrUnion());
715 RecordDeclBits.addBit(D->hasObjectMember());
716 RecordDeclBits.addBit(D->hasVolatileMember());
718 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveCopy());
719 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDestroy());
722 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveCopyCUnion());
723 RecordDeclBits.addBit(D->hasUninitializedExplicitInitFields());
724 RecordDeclBits.addBit(D->isParamDestroyedInCallee());
725 RecordDeclBits.addBits(llvm::to_underlying(D->getArgPassingRestrictions()), 2);
726 Record.push_back(RecordDeclBits);
727
728 // Only compute this for C/Objective-C, in C++ this is computed as part
729 // of CXXRecordDecl.
730 if (!isa<CXXRecordDecl>(D))
731 Record.push_back(D->getODRHash());
732
733 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
734 !D->isImplicit() && !D->isInvalidDecl() && !D->hasExtInfo() &&
736 D->getFirstDecl() == D->getMostRecentDecl() &&
741 AbbrevToUse = Writer.getDeclRecordAbbrev();
742
744}
745
748 Record.AddTypeRef(D->getType());
749}
750
753 Record.push_back(D->getInitExpr()? 1 : 0);
754 if (D->getInitExpr())
755 Record.AddStmt(D->getInitExpr());
756 Record.AddAPSInt(D->getInitVal());
757
759}
760
763 Record.AddSourceLocation(D->getInnerLocStart());
764 Record.push_back(D->hasExtInfo());
765 if (D->hasExtInfo()) {
766 DeclaratorDecl::ExtInfo *Info = D->getExtInfo();
767 Record.AddQualifierInfo(*Info);
768 Record.AddStmt(
769 const_cast<Expr *>(Info->TrailingRequiresClause.ConstraintExpr));
770 Record.writeUnsignedOrNone(Info->TrailingRequiresClause.ArgPackSubstIndex);
771 }
772 // The location information is deferred until the end of the record.
773 Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType()
774 : QualType());
775}
776
778 static_assert(DeclContext::NumFunctionDeclBits == 42,
779 "You need to update the serializer after you change the "
780 "FunctionDeclBits");
781
783
784 Record.push_back(D->getTemplatedKind());
785 switch (D->getTemplatedKind()) {
787 break;
789 Record.AddDeclRef(D->getInstantiatedFromDecl());
790 break;
792 Record.AddDeclRef(D->getDescribedFunctionTemplate());
793 break;
796 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
797 Record.push_back(MemberInfo->getTemplateSpecializationKind());
798 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
799 break;
800 }
803 FTSInfo = D->getTemplateSpecializationInfo();
804
806
807 Record.AddDeclRef(FTSInfo->getTemplate());
808 Record.push_back(FTSInfo->getTemplateSpecializationKind());
809
810 // Template arguments.
811 Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
812
813 // Template args as written.
814 Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
815 if (FTSInfo->TemplateArgumentsAsWritten)
816 Record.AddASTTemplateArgumentListInfo(
818
819 Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
820
821 if (MemberSpecializationInfo *MemberInfo =
822 FTSInfo->getMemberSpecializationInfo()) {
823 Record.push_back(1);
824 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
825 Record.push_back(MemberInfo->getTemplateSpecializationKind());
826 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
827 } else {
828 Record.push_back(0);
829 }
830
831 if (D->isCanonicalDecl()) {
832 // Write the template that contains the specializations set. We will
833 // add a FunctionTemplateSpecializationInfo to it when reading.
834 Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
835 }
836 break;
837 }
840 DFTSInfo = D->getDependentSpecializationInfo();
841
842 // Candidates.
843 Record.push_back(DFTSInfo->getCandidates().size());
844 for (FunctionTemplateDecl *FTD : DFTSInfo->getCandidates())
845 Record.AddDeclRef(FTD);
846
847 // Templates args.
848 Record.push_back(DFTSInfo->TemplateArgumentsAsWritten != nullptr);
849 if (DFTSInfo->TemplateArgumentsAsWritten)
850 Record.AddASTTemplateArgumentListInfo(
852 break;
853 }
854 }
855
857 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
858 Record.push_back(D->getIdentifierNamespace());
859
860 // The order matters here. It will be better to put the bit with higher
861 // probability to be 0 in the end of the bits. See the comments in VisitDecl
862 // for details.
863 BitsPacker FunctionDeclBits;
864 // FIXME: stable encoding
865 FunctionDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()), 3);
866 FunctionDeclBits.addBits((uint32_t)D->getStorageClass(), /*BitWidth=*/3);
867 FunctionDeclBits.addBit(D->isInlineSpecified());
868 FunctionDeclBits.addBit(D->isInlined());
869 FunctionDeclBits.addBit(D->hasSkippedBody());
870 FunctionDeclBits.addBit(D->isVirtualAsWritten());
871 FunctionDeclBits.addBit(D->isPureVirtual());
872 FunctionDeclBits.addBit(D->hasInheritedPrototype());
873 FunctionDeclBits.addBit(D->hasWrittenPrototype());
874 FunctionDeclBits.addBit(D->isDeletedBit());
875 FunctionDeclBits.addBit(D->isTrivial());
876 FunctionDeclBits.addBit(D->isTrivialForCall());
877 FunctionDeclBits.addBit(D->isDefaulted());
878 FunctionDeclBits.addBit(D->isExplicitlyDefaulted());
879 FunctionDeclBits.addBit(D->isIneligibleOrNotSelected());
880 FunctionDeclBits.addBits((uint64_t)(D->getConstexprKind()), /*BitWidth=*/2);
881 FunctionDeclBits.addBit(D->hasImplicitReturnZero());
882 FunctionDeclBits.addBit(D->isMultiVersion());
883 FunctionDeclBits.addBit(D->isLateTemplateParsed());
884 FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate());
886 FunctionDeclBits.addBit(D->usesSEHTry());
887 FunctionDeclBits.addBit(D->isDestroyingOperatorDelete());
888 FunctionDeclBits.addBit(D->isTypeAwareOperatorNewOrDelete());
889 Record.push_back(FunctionDeclBits);
890
891 Record.AddSourceLocation(D->getEndLoc());
892 if (D->isExplicitlyDefaulted())
893 Record.AddSourceLocation(D->getDefaultLoc());
894
895 Record.push_back(D->getODRHash());
896
897 if (D->isDefaulted() || D->isDeletedAsWritten()) {
898 if (auto *FDI = D->getDefaultedOrDeletedInfo()) {
899 // Store both that there is an DefaultedOrDeletedInfo and whether it
900 // contains a DeletedMessage.
901 StringLiteral *DeletedMessage = FDI->getDeletedMessage();
902 Record.push_back(1 | (DeletedMessage ? 2 : 0));
903 if (DeletedMessage)
904 Record.AddStmt(DeletedMessage);
905
906 Record.push_back(FDI->getFPFeatures().getAsOpaqueInt());
907
908 Record.push_back(FDI->getUnqualifiedLookups().size());
909 for (DeclAccessPair P : FDI->getUnqualifiedLookups()) {
910 Record.AddDeclRef(P.getDecl());
911 Record.push_back(P.getAccess());
912 }
913 } else {
914 Record.push_back(0);
915 }
916 }
917
918 if (D->getFriendObjectKind()) {
919 // For a friend function defined inline within a class template, we have to
920 // force the definition to be the one inside the definition of the template
921 // class. Remember this relation to deserialize them together.
922 if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent());
923 RD && isDefinitionInDependentContext(RD)) {
924 Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
925 Writer.GetDeclRef(D));
926 }
927 }
928
929 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
930 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
931 Writer.GetDeclRef(EID);
932
933 Record.push_back(D->param_size());
934 for (auto *P : D->parameters())
935 Record.AddDeclRef(P);
937}
938
941 uint64_t Kind = static_cast<uint64_t>(ES.getKind());
942 Kind = Kind << 1 | static_cast<bool>(ES.getExpr());
943 Record.push_back(Kind);
944 if (ES.getExpr()) {
945 Record.AddStmt(ES.getExpr());
946 }
947}
948
951 Record.AddDeclRef(D->getCorrespondingConstructor());
953 Record.push_back(static_cast<unsigned char>(D->getDeductionCandidateKind()));
954 Record.AddDeclRef(D->getSourceDeductionGuide());
955 Record.push_back(
956 static_cast<unsigned char>(D->getSourceDeductionGuideKind()));
958}
959
961 static_assert(DeclContext::NumObjCMethodDeclBits == 36,
962 "You need to update the serializer after you change the "
963 "ObjCMethodDeclBits");
964
966 // FIXME: convert to LazyStmtPtr?
967 // Unlike C/C++, method bodies will never be in header files.
968 bool HasBodyStuff = D->getBody() != nullptr;
969 Record.push_back(HasBodyStuff);
970 if (HasBodyStuff) {
971 Record.AddStmt(D->getBody());
972 }
973 Record.AddDeclRef(D->getSelfDecl());
974 Record.AddDeclRef(D->getCmdDecl());
975 Record.push_back(D->isInstanceMethod());
976 Record.push_back(D->isVariadic());
977 Record.push_back(D->isPropertyAccessor());
978 Record.push_back(D->isSynthesizedAccessorStub());
979 Record.push_back(D->isDefined());
980 Record.push_back(D->isOverriding());
981 Record.push_back(D->hasSkippedBody());
982
983 Record.push_back(D->isRedeclaration());
984 Record.push_back(D->hasRedeclaration());
985 if (D->hasRedeclaration()) {
986 assert(Record.getASTContext().getObjCMethodRedeclaration(D));
987 Record.AddDeclRef(Record.getASTContext().getObjCMethodRedeclaration(D));
988 }
989
990 // FIXME: stable encoding for @required/@optional
991 Record.push_back(llvm::to_underlying(D->getImplementationControl()));
992 // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
993 Record.push_back(D->getObjCDeclQualifier());
994 Record.push_back(D->hasRelatedResultType());
995 Record.AddTypeRef(D->getReturnType());
996 Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
997 Record.AddSourceLocation(D->getEndLoc());
998 Record.push_back(D->param_size());
999 for (const auto *P : D->parameters())
1000 Record.AddDeclRef(P);
1001
1002 Record.push_back(D->getSelLocsKind());
1003 unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
1004 SourceLocation *SelLocs = D->getStoredSelLocs();
1005 Record.push_back(NumStoredSelLocs);
1006 for (unsigned i = 0; i != NumStoredSelLocs; ++i)
1007 Record.AddSourceLocation(SelLocs[i]);
1008
1010}
1011
1014 Record.push_back(D->Variance);
1015 Record.push_back(D->Index);
1016 Record.AddSourceLocation(D->VarianceLoc);
1017 Record.AddSourceLocation(D->ColonLoc);
1018
1020}
1021
1023 static_assert(DeclContext::NumObjCContainerDeclBits == 64,
1024 "You need to update the serializer after you change the "
1025 "ObjCContainerDeclBits");
1026
1027 VisitNamedDecl(D);
1028 Record.AddSourceLocation(D->getAtStartLoc());
1029 Record.AddSourceRange(D->getAtEndRange());
1030 // Abstract class (no need to define a stable serialization::DECL code).
1031}
1032
1036 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
1037 AddObjCTypeParamList(D->TypeParamList);
1038
1039 Record.push_back(D->isThisDeclarationADefinition());
1041 // Write the DefinitionData
1042 ObjCInterfaceDecl::DefinitionData &Data = D->data();
1043
1044 Record.AddTypeSourceInfo(D->getSuperClassTInfo());
1045 Record.AddSourceLocation(D->getEndOfDefinitionLoc());
1046 Record.push_back(Data.HasDesignatedInitializers);
1047 Record.push_back(D->getODRHash());
1048
1049 // Write out the protocols that are directly referenced by the @interface.
1050 Record.push_back(Data.ReferencedProtocols.size());
1051 for (const auto *P : D->protocols())
1052 Record.AddDeclRef(P);
1053 for (const auto &PL : D->protocol_locs())
1054 Record.AddSourceLocation(PL);
1055
1056 // Write out the protocols that are transitively referenced.
1057 Record.push_back(Data.AllReferencedProtocols.size());
1059 P = Data.AllReferencedProtocols.begin(),
1060 PEnd = Data.AllReferencedProtocols.end();
1061 P != PEnd; ++P)
1062 Record.AddDeclRef(*P);
1063
1064
1065 if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
1066 // Ensure that we write out the set of categories for this class.
1067 Writer.ObjCClassesWithCategories.insert(D);
1068
1069 // Make sure that the categories get serialized.
1070 for (; Cat; Cat = Cat->getNextClassCategoryRaw())
1071 (void)Writer.GetDeclRef(Cat);
1072 }
1073 }
1074
1076}
1077
1079 VisitFieldDecl(D);
1080 // FIXME: stable encoding for @public/@private/@protected/@package
1081 Record.push_back(D->getAccessControl());
1082 Record.push_back(D->getSynthesize());
1083
1084 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1085 !D->hasAttrs() &&
1086 !D->isImplicit() &&
1087 !D->isUsed(false) &&
1088 !D->isInvalidDecl() &&
1089 !D->isReferenced() &&
1090 !D->isModulePrivate() &&
1091 !D->getBitWidth() &&
1092 !D->hasExtInfo() &&
1093 D->getDeclName())
1094 AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
1095
1097}
1098
1102
1103 Record.push_back(D->isThisDeclarationADefinition());
1105 Record.push_back(D->protocol_size());
1106 for (const auto *I : D->protocols())
1107 Record.AddDeclRef(I);
1108 for (const auto &PL : D->protocol_locs())
1109 Record.AddSourceLocation(PL);
1110 Record.push_back(D->getODRHash());
1111 }
1112
1114}
1115
1120
1123 Record.AddSourceLocation(D->getCategoryNameLoc());
1124 Record.AddSourceLocation(D->getIvarLBraceLoc());
1125 Record.AddSourceLocation(D->getIvarRBraceLoc());
1126 Record.AddDeclRef(D->getClassInterface());
1127 AddObjCTypeParamList(D->TypeParamList);
1128 Record.push_back(D->protocol_size());
1129 for (const auto *I : D->protocols())
1130 Record.AddDeclRef(I);
1131 for (const auto &PL : D->protocol_locs())
1132 Record.AddSourceLocation(PL);
1134}
1135
1141
1143 VisitNamedDecl(D);
1144 Record.AddSourceLocation(D->getAtLoc());
1145 Record.AddSourceLocation(D->getLParenLoc());
1146 Record.AddTypeRef(D->getType());
1147 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
1148 // FIXME: stable encoding
1149 Record.push_back((unsigned)D->getPropertyAttributes());
1150 Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
1151 // FIXME: stable encoding
1152 Record.push_back((unsigned)D->getPropertyImplementation());
1153 Record.AddDeclarationName(D->getGetterName());
1154 Record.AddSourceLocation(D->getGetterNameLoc());
1155 Record.AddDeclarationName(D->getSetterName());
1156 Record.AddSourceLocation(D->getSetterNameLoc());
1157 Record.AddDeclRef(D->getGetterMethodDecl());
1158 Record.AddDeclRef(D->getSetterMethodDecl());
1159 Record.AddDeclRef(D->getPropertyIvarDecl());
1161}
1162
1165 Record.AddDeclRef(D->getClassInterface());
1166 // Abstract class (no need to define a stable serialization::DECL code).
1167}
1168
1174
1177 Record.AddDeclRef(D->getSuperClass());
1178 Record.AddSourceLocation(D->getSuperClassLoc());
1179 Record.AddSourceLocation(D->getIvarLBraceLoc());
1180 Record.AddSourceLocation(D->getIvarRBraceLoc());
1181 Record.push_back(D->hasNonZeroConstructors());
1182 Record.push_back(D->hasDestructors());
1183 Record.push_back(D->NumIvarInitializers);
1184 if (D->NumIvarInitializers)
1185 Record.AddCXXCtorInitializers(
1186 llvm::ArrayRef(D->init_begin(), D->init_end()));
1188}
1189
1191 VisitDecl(D);
1192 Record.AddSourceLocation(D->getBeginLoc());
1193 Record.AddDeclRef(D->getPropertyDecl());
1194 Record.AddDeclRef(D->getPropertyIvarDecl());
1195 Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
1196 Record.AddDeclRef(D->getGetterMethodDecl());
1197 Record.AddDeclRef(D->getSetterMethodDecl());
1198 Record.AddStmt(D->getGetterCXXConstructor());
1199 Record.AddStmt(D->getSetterCXXAssignment());
1201}
1202
1205 Record.push_back(D->isMutable());
1206
1207 Record.push_back((D->StorageKind << 1) | D->BitField);
1208 if (D->StorageKind == FieldDecl::ISK_CapturedVLAType)
1209 Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
1210 else if (D->BitField)
1211 Record.AddStmt(D->getBitWidth());
1212
1213 if (!D->getDeclName() || D->isPlaceholderVar(Writer.getLangOpts()))
1214 Record.AddDeclRef(
1215 Record.getASTContext().getInstantiatedFromUnnamedFieldDecl(D));
1216
1217 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1218 !D->hasAttrs() &&
1219 !D->isImplicit() &&
1220 !D->isUsed(false) &&
1221 !D->isInvalidDecl() &&
1222 !D->isReferenced() &&
1224 !D->isModulePrivate() &&
1225 !D->getBitWidth() &&
1226 !D->hasInClassInitializer() &&
1227 !D->hasCapturedVLAType() &&
1228 !D->hasExtInfo() &&
1231 D->getDeclName())
1232 AbbrevToUse = Writer.getDeclFieldAbbrev();
1233
1235}
1236
1239 Record.AddIdentifierRef(D->getGetterId());
1240 Record.AddIdentifierRef(D->getSetterId());
1242}
1243
1245 VisitValueDecl(D);
1246 MSGuidDecl::Parts Parts = D->getParts();
1247 Record.push_back(Parts.Part1);
1248 Record.push_back(Parts.Part2);
1249 Record.push_back(Parts.Part3);
1250 Record.append(std::begin(Parts.Part4And5), std::end(Parts.Part4And5));
1252}
1253
1260
1266
1268 VisitValueDecl(D);
1269 Record.push_back(D->getChainingSize());
1270
1271 for (const auto *P : D->chain())
1272 Record.AddDeclRef(P);
1274}
1275
1279
1280 // The order matters here. It will be better to put the bit with higher
1281 // probability to be 0 in the end of the bits. See the comments in VisitDecl
1282 // for details.
1283 BitsPacker VarDeclBits;
1284 VarDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()),
1285 /*BitWidth=*/3);
1286
1287 bool ModulesCodegen = shouldVarGenerateHereOnly(D);
1288 VarDeclBits.addBit(ModulesCodegen);
1289
1290 VarDeclBits.addBits(D->getStorageClass(), /*BitWidth=*/3);
1291 VarDeclBits.addBits(D->getTSCSpec(), /*BitWidth=*/2);
1292 VarDeclBits.addBits(D->getInitStyle(), /*BitWidth=*/2);
1293 VarDeclBits.addBit(D->isARCPseudoStrong());
1294
1295 bool HasDeducedType = false;
1296 if (!isa<ParmVarDecl>(D)) {
1298 VarDeclBits.addBit(D->isExceptionVariable());
1299 VarDeclBits.addBit(D->isNRVOVariable());
1300 VarDeclBits.addBit(D->isCXXForRangeDecl());
1301
1302 VarDeclBits.addBit(D->isInline());
1303 VarDeclBits.addBit(D->isInlineSpecified());
1304 VarDeclBits.addBit(D->isConstexpr());
1305 VarDeclBits.addBit(D->isInitCapture());
1306 VarDeclBits.addBit(D->isPreviousDeclInSameBlockScope());
1307
1308 VarDeclBits.addBit(D->isEscapingByref());
1309 HasDeducedType = D->getType()->getContainedDeducedType();
1310 VarDeclBits.addBit(HasDeducedType);
1311
1312 if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
1313 VarDeclBits.addBits(llvm::to_underlying(IPD->getParameterKind()),
1314 /*Width=*/3);
1315 else
1316 VarDeclBits.addBits(0, /*Width=*/3);
1317
1318 VarDeclBits.addBit(D->isObjCForDecl());
1319 VarDeclBits.addBit(D->isCXXForRangeImplicitVar());
1320 }
1321
1322 Record.push_back(VarDeclBits);
1323
1324 if (ModulesCodegen)
1325 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1326
1327 if (D->hasAttr<BlocksAttr>()) {
1328 BlockVarCopyInit Init = Record.getASTContext().getBlockVarCopyInit(D);
1329 Record.AddStmt(Init.getCopyExpr());
1330 if (Init.getCopyExpr())
1331 Record.push_back(Init.canThrow());
1332 }
1333
1334 enum {
1335 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1336 };
1337 if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
1338 Record.push_back(VarTemplate);
1339 Record.AddDeclRef(TemplD);
1340 } else if (MemberSpecializationInfo *SpecInfo
1342 Record.push_back(StaticDataMemberSpecialization);
1343 Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
1344 Record.push_back(SpecInfo->getTemplateSpecializationKind());
1345 Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
1346 } else {
1347 Record.push_back(VarNotTemplate);
1348 }
1349
1350 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1354 !D->hasExtInfo() && D->getFirstDecl() == D->getMostRecentDecl() &&
1355 D->getKind() == Decl::Var && !D->isInline() && !D->isConstexpr() &&
1357 !D->hasInitWithSideEffects() && !D->isEscapingByref() &&
1358 !HasDeducedType && D->getStorageDuration() != SD_Static &&
1361 !D->isEscapingByref())
1362 AbbrevToUse = Writer.getDeclVarAbbrev();
1363
1365}
1366
1371
1373 VisitVarDecl(D);
1374
1375 // See the implementation of `ParmVarDecl::getParameterIndex()`, which may
1376 // exceed the size of the normal bitfield. So it may be better to not pack
1377 // these bits.
1378 Record.push_back(D->getFunctionScopeIndex());
1379
1380 BitsPacker ParmVarDeclBits;
1381 ParmVarDeclBits.addBit(D->isObjCMethodParameter());
1382 ParmVarDeclBits.addBits(D->getFunctionScopeDepth(), /*BitsWidth=*/7);
1383 // FIXME: stable encoding
1384 ParmVarDeclBits.addBits(D->getObjCDeclQualifier(), /*BitsWidth=*/7);
1385 ParmVarDeclBits.addBit(D->isKNRPromoted());
1386 ParmVarDeclBits.addBit(D->hasInheritedDefaultArg());
1387 ParmVarDeclBits.addBit(D->hasUninstantiatedDefaultArg());
1388 ParmVarDeclBits.addBit(D->getExplicitObjectParamThisLoc().isValid());
1389 Record.push_back(ParmVarDeclBits);
1390
1392 Record.AddStmt(D->getUninstantiatedDefaultArg());
1394 Record.AddSourceLocation(D->getExplicitObjectParamThisLoc());
1396
1397 // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1398 // we dynamically check for the properties that we optimize for, but don't
1399 // know are true of all PARM_VAR_DECLs.
1400 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1401 !D->hasExtInfo() && D->getStorageClass() == 0 && !D->isInvalidDecl() &&
1403 D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1404 D->getInit() == nullptr) // No default expr.
1405 AbbrevToUse = Writer.getDeclParmVarAbbrev();
1406
1407 // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1408 // just us assuming it.
1409 assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1411 && "PARM_VAR_DECL can't be demoted definition.");
1412 assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1413 assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1414 assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1415 assert(!D->isStaticDataMember() &&
1416 "PARM_VAR_DECL can't be static data member");
1417}
1418
1420 // Record the number of bindings first to simplify deserialization.
1421 Record.push_back(D->bindings().size());
1422
1423 VisitVarDecl(D);
1424 for (auto *B : D->bindings())
1425 Record.AddDeclRef(B);
1427}
1428
1430 VisitValueDecl(D);
1431 Record.AddStmt(D->getBinding());
1433}
1434
1436 VisitDecl(D);
1437 Record.AddStmt(D->getAsmStringExpr());
1438 Record.AddSourceLocation(D->getRParenLoc());
1440}
1441
1443 VisitDecl(D);
1444 Record.push_back(D->getOrdinal());
1445 Record.AddStmt(D->getStmt());
1447}
1448
1453
1456 VisitDecl(D);
1457 Record.AddDeclRef(D->getExtendingDecl());
1458 Record.AddStmt(D->getTemporaryExpr());
1459 Record.push_back(static_cast<bool>(D->getValue()));
1460 if (D->getValue())
1461 Record.AddAPValue(*D->getValue());
1462 Record.push_back(D->getManglingNumber());
1464}
1466 VisitDecl(D);
1467 Record.AddStmt(D->getBody());
1468 Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1469 Record.push_back(D->param_size());
1470 for (ParmVarDecl *P : D->parameters())
1471 Record.AddDeclRef(P);
1472 Record.push_back(D->isVariadic());
1473 Record.push_back(D->blockMissingReturnType());
1474 Record.push_back(D->isConversionFromLambda());
1475 Record.push_back(D->doesNotEscape());
1476 Record.push_back(D->canAvoidCopyToHeap());
1477 Record.push_back(D->capturesCXXThis());
1478 Record.push_back(D->getNumCaptures());
1479 for (const auto &capture : D->captures()) {
1480 Record.AddDeclRef(capture.getVariable());
1481
1482 unsigned flags = 0;
1483 if (capture.isByRef()) flags |= 1;
1484 if (capture.isNested()) flags |= 2;
1485 if (capture.hasCopyExpr()) flags |= 4;
1486 Record.push_back(flags);
1487
1488 if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1489 }
1490
1492}
1493
1495 Record.push_back(D->getNumParams());
1496 VisitDecl(D);
1497 for (unsigned I = 0; I < D->getNumParams(); ++I)
1498 Record.AddDeclRef(D->getParam(I));
1499 Record.push_back(D->isNothrow() ? 1 : 0);
1500 Record.AddStmt(D->getBody());
1502}
1503
1505 Record.push_back(CD->getNumParams());
1506 VisitDecl(CD);
1507 Record.push_back(CD->getContextParamPosition());
1508 Record.push_back(CD->isNothrow() ? 1 : 0);
1509 // Body is stored by VisitCapturedStmt.
1510 for (unsigned I = 0; I < CD->getNumParams(); ++I)
1511 Record.AddDeclRef(CD->getParam(I));
1513}
1514
1516 static_assert(DeclContext::NumLinkageSpecDeclBits == 16,
1517 "You need to update the serializer after you change the"
1518 "LinkageSpecDeclBits");
1519
1520 VisitDecl(D);
1521 Record.push_back(llvm::to_underlying(D->getLanguage()));
1522 Record.AddSourceLocation(D->getExternLoc());
1523 Record.AddSourceLocation(D->getRBraceLoc());
1525}
1526
1528 VisitDecl(D);
1529 Record.AddSourceLocation(D->getRBraceLoc());
1531}
1532
1534 VisitNamedDecl(D);
1535 Record.AddSourceLocation(D->getBeginLoc());
1537}
1538
1539
1542 VisitNamedDecl(D);
1543
1544 BitsPacker NamespaceDeclBits;
1545 NamespaceDeclBits.addBit(D->isInline());
1546 NamespaceDeclBits.addBit(D->isNested());
1547 Record.push_back(NamespaceDeclBits);
1548
1549 Record.AddSourceLocation(D->getBeginLoc());
1550 Record.AddSourceLocation(D->getRBraceLoc());
1551
1552 if (D->isFirstDecl())
1553 Record.AddDeclRef(D->getAnonymousNamespace());
1555
1556 if (Writer.hasChain() && D->isAnonymousNamespace() &&
1557 D == D->getMostRecentDecl()) {
1558 // This is a most recent reopening of the anonymous namespace. If its parent
1559 // is in a previous PCH (or is the TU), mark that parent for update, because
1560 // the original namespace always points to the latest re-opening of its
1561 // anonymous namespace.
1562 Decl *Parent = cast<Decl>(
1564 if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1565 Writer.DeclUpdates[Parent].push_back(
1566 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, D));
1567 }
1568 }
1569}
1570
1573 VisitNamedDecl(D);
1574 Record.AddSourceLocation(D->getNamespaceLoc());
1575 Record.AddSourceLocation(D->getTargetNameLoc());
1576 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1577 Record.AddDeclRef(D->getNamespace());
1579}
1580
1582 VisitNamedDecl(D);
1583 Record.AddSourceLocation(D->getUsingLoc());
1584 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1585 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1586 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1587 Record.push_back(D->hasTypename());
1588 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingDecl(D));
1590}
1591
1593 VisitNamedDecl(D);
1594 Record.AddSourceLocation(D->getUsingLoc());
1595 Record.AddSourceLocation(D->getEnumLoc());
1596 Record.AddTypeSourceInfo(D->getEnumType());
1597 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1598 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingEnumDecl(D));
1600}
1601
1603 Record.push_back(D->NumExpansions);
1604 VisitNamedDecl(D);
1605 Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1606 for (auto *E : D->expansions())
1607 Record.AddDeclRef(E);
1609}
1610
1613 VisitNamedDecl(D);
1614 Record.AddDeclRef(D->getTargetDecl());
1615 Record.push_back(D->getIdentifierNamespace());
1616 Record.AddDeclRef(D->UsingOrNextShadow);
1617 Record.AddDeclRef(
1618 Record.getASTContext().getInstantiatedFromUsingShadowDecl(D));
1619
1620 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1621 D->getFirstDecl() == D->getMostRecentDecl() && !D->hasAttrs() &&
1624 AbbrevToUse = Writer.getDeclUsingShadowAbbrev();
1625
1627}
1628
1632 Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1633 Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1634 Record.push_back(D->IsVirtual);
1636}
1637
1639 VisitNamedDecl(D);
1640 Record.AddSourceLocation(D->getUsingLoc());
1641 Record.AddSourceLocation(D->getNamespaceKeyLocation());
1642 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1643 Record.AddDeclRef(D->getNominatedNamespace());
1644 Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1646}
1647
1649 VisitValueDecl(D);
1650 Record.AddSourceLocation(D->getUsingLoc());
1651 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1652 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1653 Record.AddSourceLocation(D->getEllipsisLoc());
1655}
1656
1659 VisitTypeDecl(D);
1660 Record.AddSourceLocation(D->getTypenameLoc());
1661 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1662 Record.AddSourceLocation(D->getEllipsisLoc());
1664}
1665
1671
1673 VisitRecordDecl(D);
1674
1675 enum {
1676 CXXRecNotTemplate = 0,
1677 CXXRecTemplate,
1678 CXXRecMemberSpecialization,
1679 CXXLambda
1680 };
1681 if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1682 Record.push_back(CXXRecTemplate);
1683 Record.AddDeclRef(TemplD);
1684 } else if (MemberSpecializationInfo *MSInfo
1686 Record.push_back(CXXRecMemberSpecialization);
1687 Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1688 Record.push_back(MSInfo->getTemplateSpecializationKind());
1689 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1690 } else if (D->isLambda()) {
1691 // For a lambda, we need some information early for merging.
1692 Record.push_back(CXXLambda);
1693 if (auto *Context = D->getLambdaContextDecl()) {
1694 Record.AddDeclRef(Context);
1695 Record.push_back(D->getLambdaIndexInContext());
1696 } else {
1697 Record.push_back(0);
1698 }
1699 // For lambdas inside template functions, remember the mapping to
1700 // deserialize them together.
1701 if (auto *FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
1702 FD && isDefinitionInDependentContext(FD)) {
1703 Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
1704 Writer.GetDeclRef(D->getLambdaCallOperator()));
1705 }
1706 } else {
1707 Record.push_back(CXXRecNotTemplate);
1708 }
1709
1710 Record.push_back(D->isThisDeclarationADefinition());
1712 Record.AddCXXDefinitionData(D);
1713
1714 if (D->isCompleteDefinition() && D->isInNamedModule())
1715 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1716
1717 // Store (what we currently believe to be) the key function to avoid
1718 // deserializing every method so we can compute it.
1719 //
1720 // FIXME: Avoid adding the key function if the class is defined in
1721 // module purview since in that case the key function is meaningless.
1722 if (D->isCompleteDefinition())
1723 Record.AddDeclRef(Record.getASTContext().getCurrentKeyFunction(D));
1724
1726}
1727
1730 if (D->isCanonicalDecl()) {
1731 Record.push_back(D->size_overridden_methods());
1732 for (const CXXMethodDecl *MD : D->overridden_methods())
1733 Record.AddDeclRef(MD);
1734 } else {
1735 // We only need to record overridden methods once for the canonical decl.
1736 Record.push_back(0);
1737 }
1738
1739 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1740 D->getFirstDecl() == D->getMostRecentDecl() && !D->isInvalidDecl() &&
1741 !D->hasAttrs() && !D->isTopLevelDeclInObjCContainer() &&
1743 !D->hasExtInfo() && !D->isExplicitlyDefaulted()) {
1748 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1749 else if (D->getTemplatedKind() ==
1753
1754 if (FTSInfo->TemplateArguments->size() == 1) {
1755 const TemplateArgument &TA = FTSInfo->TemplateArguments->get(0);
1756 if (TA.getKind() == TemplateArgument::Type &&
1757 !FTSInfo->TemplateArgumentsAsWritten &&
1758 !FTSInfo->getMemberSpecializationInfo())
1759 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1760 }
1761 } else if (D->getTemplatedKind() ==
1765 if (!DFTSInfo->TemplateArgumentsAsWritten)
1766 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1767 }
1768 }
1769
1771}
1772
1774 static_assert(DeclContext::NumCXXConstructorDeclBits == 45,
1775 "You need to update the serializer after you change the "
1776 "CXXConstructorDeclBits");
1777
1778 Record.push_back(D->getTrailingAllocKind());
1779 addExplicitSpecifier(D->getExplicitSpecifierInternal(), Record);
1780 if (auto Inherited = D->getInheritedConstructor()) {
1781 Record.AddDeclRef(Inherited.getShadowDecl());
1782 Record.AddDeclRef(Inherited.getConstructor());
1783 }
1784
1785 ArrayRef<CXXDefaultArgExpr *> CtorClosureDefaultArgs =
1787 Record.push_back((unsigned)CtorClosureDefaultArgs.size());
1788 for (CXXDefaultArgExpr *Arg : CtorClosureDefaultArgs)
1789 Record.writeStmtRef(Arg);
1790
1793}
1794
1797
1798 Record.AddDeclRef(D->getOperatorDelete());
1799 if (D->getOperatorDelete())
1800 Record.AddStmt(D->getOperatorDeleteThisArg());
1801 Record.AddDeclRef(D->getOperatorGlobalDelete());
1802 Record.AddDeclRef(D->getArrayOperatorDelete());
1803 Record.AddDeclRef(D->getGlobalArrayOperatorDelete());
1804
1806}
1807
1813
1815 VisitDecl(D);
1816 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1817 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1818 Record.push_back(!IdentifierLocs.empty());
1819 if (IdentifierLocs.empty()) {
1820 Record.AddSourceLocation(D->getEndLoc());
1821 Record.push_back(1);
1822 } else {
1823 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1824 Record.AddSourceLocation(IdentifierLocs[I]);
1825 Record.push_back(IdentifierLocs.size());
1826 }
1827 // Note: the number of source locations must always be the last element in
1828 // the record.
1830}
1831
1833 VisitDecl(D);
1834 Record.AddSourceLocation(D->getColonLoc());
1836}
1837
1839 VisitDecl(D);
1840 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1841 Record.push_back(hasFriendDecl);
1842 if (hasFriendDecl)
1843 Record.AddDeclRef(D->getFriendDecl());
1844 else
1845 Record.AddTypeSourceInfo(D->getFriendType());
1846 Record.AddDeclRef(D->getNextFriend());
1847 Record.AddSourceLocation(D->FriendLoc);
1848 Record.AddSourceLocation(D->EllipsisLoc);
1850}
1851
1853 // Record the number of template parameter lists here to simplify memory
1854 // allocation during deserialization.
1855 Record.push_back(D->NumTPLists);
1856 VisitDecl(D);
1858 Record.AddTemplateParameterList(TPL);
1860 if (D->getFriendType()) {
1861 Kind = D->Template.isNull() ? FTDK_Type : FTDK_Dependent;
1862 } else if (D->Template.isNull()) {
1863 assert(D->getFriendDecl());
1864 Kind = FTDK_Decl;
1865 } else {
1866 Kind = FTDK_Template;
1867 }
1868 Record.push_back(Kind);
1869 switch (Kind) {
1870 case FTDK_Type:
1871 Record.AddTypeSourceInfo(D->getFriendType());
1872 break;
1873 case FTDK_Dependent:
1874 Record.AddTypeSourceInfo(D->getFriendType());
1875 Record.AddTemplateName(D->Template);
1876 break;
1877 case FTDK_Decl:
1878 Record.AddDeclRef(D->getFriendDecl());
1879 break;
1880 case FTDK_Template:
1881 Record.AddTemplateName(D->Template);
1882 break;
1883 }
1884 Record.AddDeclRef(D->getNextFriend());
1885 Record.AddSourceLocation(D->FriendLoc);
1886 Record.AddSourceLocation(D->EllipsisLoc);
1888}
1889
1891 VisitNamedDecl(D);
1892
1893 Record.AddTemplateParameterList(D->getTemplateParameters());
1894 Record.AddDeclRef(D->getTemplatedDecl());
1895}
1896
1902
1905 Record.push_back(D->getTemplateArguments().size());
1906 VisitDecl(D);
1907 for (const TemplateArgument &Arg : D->getTemplateArguments())
1908 Record.AddTemplateArgument(Arg);
1910}
1911
1915
1918
1919 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1920 // getCommonPtr() can be used while this is still initializing.
1921 if (D->isFirstDecl()) {
1922 // This declaration owns the 'common' pointer, so serialize that data now.
1923 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1925 Record.push_back(D->isMemberSpecialization());
1926 }
1927
1929 Record.push_back(D->getIdentifierNamespace());
1930}
1931
1934
1935 if (D->isFirstDecl())
1937
1938 // Force emitting the corresponding deduction guide in reduced BMI mode.
1939 // Otherwise, the deduction guide may be optimized out incorrectly.
1940 if (Writer.isGeneratingReducedBMI()) {
1941 auto Name =
1942 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1943 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1944 Writer.GetDeclRef(DG->getCanonicalDecl());
1945 }
1946
1948}
1949
1953
1955
1956 llvm::PointerUnion<ClassTemplateDecl *,
1959 if (Decl *InstFromD = dyn_cast<ClassTemplateDecl *>(InstFrom)) {
1960 Record.AddDeclRef(InstFromD);
1961 } else {
1962 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1963 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1964 }
1965
1966 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1967 Record.AddSourceLocation(D->getPointOfInstantiation());
1968 Record.push_back(D->getSpecializationKind());
1969 Record.push_back(D->hasStrictPackMatch());
1970 Record.push_back(D->isCanonicalDecl());
1971
1972 if (D->isCanonicalDecl()) {
1973 // When reading, we'll add it to the folding set of the following template.
1974 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1975 }
1976
1981 Record.push_back(ExplicitInstantiation);
1983 Record.AddSourceLocation(D->getExternKeywordLoc());
1984 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1985 }
1986
1987 const ASTTemplateArgumentListInfo *ArgsWritten =
1989 Record.push_back(!!ArgsWritten);
1990 if (ArgsWritten)
1991 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1992
1993 // Mention the implicitly generated C++ deduction guide to make sure the
1994 // deduction guide will be rewritten as expected.
1995 //
1996 // FIXME: Would it be more efficient to add a callback register function
1997 // in sema to register the deduction guide?
1998 if (Writer.isWritingStdCXXNamedModules()) {
1999 auto Name =
2000 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
2002 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
2003 Writer.GetDeclRef(DG->getCanonicalDecl());
2004 }
2005
2006 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
2007 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
2008 Writer.GetDeclRef(EID);
2009
2011}
2012
2015 Record.AddTemplateParameterList(D->getTemplateParameters());
2016
2018
2019 // These are read/set from/to the first declaration.
2020 if (D->getPreviousDecl() == nullptr) {
2021 Record.AddDeclRef(D->getInstantiatedFromMember());
2022 Record.push_back(D->isMemberSpecialization());
2023 }
2024
2026}
2027
2035
2039
2040 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2041 InstFrom = D->getSpecializedTemplateOrPartial();
2042 if (Decl *InstFromD = dyn_cast<VarTemplateDecl *>(InstFrom)) {
2043 Record.AddDeclRef(InstFromD);
2044 } else {
2045 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
2046 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
2047 }
2048
2053 Record.push_back(ExplicitInstantiation);
2055 Record.AddSourceLocation(D->getExternKeywordLoc());
2056 Record.AddSourceLocation(D->getTemplateKeywordLoc());
2057 }
2058
2059 const ASTTemplateArgumentListInfo *ArgsWritten =
2061 Record.push_back(!!ArgsWritten);
2062 if (ArgsWritten)
2063 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
2064
2065 Record.AddTemplateArgumentList(&D->getTemplateArgs());
2066 Record.AddSourceLocation(D->getPointOfInstantiation());
2067 Record.push_back(D->getSpecializationKind());
2068 Record.push_back(D->IsCompleteDefinition);
2069
2070 VisitVarDecl(D);
2071
2072 Record.push_back(D->isCanonicalDecl());
2073
2074 if (D->isCanonicalDecl()) {
2075 // When reading, we'll add it to the folding set of the following template.
2076 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
2077 }
2078
2079 // Ensure associated ExplicitInstantiationDecls survive reduced BMI.
2080 for (auto *EID : Record.getASTContext().getExplicitInstantiationDecls(D))
2081 Writer.GetDeclRef(EID);
2082
2084}
2085
2088 Record.AddTemplateParameterList(D->getTemplateParameters());
2089
2091
2092 // These are read/set from/to the first declaration.
2093 if (D->getPreviousDecl() == nullptr) {
2094 Record.AddDeclRef(D->getInstantiatedFromMember());
2095 Record.push_back(D->isMemberSpecialization());
2096 }
2097
2099}
2100
2108
2110 Record.push_back(D->hasTypeConstraint());
2111 VisitTypeDecl(D);
2112
2113 Record.push_back(D->wasDeclaredWithTypename());
2114
2115 const TypeConstraint *TC = D->getTypeConstraint();
2116 if (D->hasTypeConstraint())
2117 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
2118 if (TC) {
2119 auto *CR = TC->getConceptReference();
2120 Record.push_back(CR != nullptr);
2121 if (CR)
2122 Record.AddConceptReference(CR);
2123 Record.AddStmt(TC->getImmediatelyDeclaredConstraint());
2124 Record.writeUnsignedOrNone(TC->getArgPackSubstIndex());
2125 Record.writeUnsignedOrNone(D->getNumExpansionParameters());
2126 }
2127
2128 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2130 Record.push_back(OwnsDefaultArg);
2131 if (OwnsDefaultArg)
2132 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2133
2134 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
2136 !D->isInvalidDecl() && !D->hasAttrs() &&
2139 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
2140
2142}
2143
2145 // For an expanded parameter pack, record the number of expansion types here
2146 // so that it's easier for deserialization to allocate the right amount of
2147 // memory.
2148 Record.push_back(D->hasPlaceholderTypeConstraint());
2149 if (D->isExpandedParameterPack())
2150 Record.push_back(D->getNumExpansionTypes());
2151
2153 // TemplateParmPosition.
2154 Record.push_back(D->getDepth());
2155 Record.push_back(D->getPosition());
2156
2158 Record.AddStmt(D->getPlaceholderTypeConstraint());
2159
2160 if (D->isExpandedParameterPack()) {
2161 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2162 Record.AddTypeRef(D->getExpansionType(I));
2163 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2164 }
2165
2167 } else {
2168 // Rest of NonTypeTemplateParmDecl.
2169 Record.push_back(D->isParameterPack());
2170 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2172 Record.push_back(OwnsDefaultArg);
2173 if (OwnsDefaultArg)
2174 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2176 }
2177}
2178
2180 // For an expanded parameter pack, record the number of expansion types here
2181 // so that it's easier for deserialization to allocate the right amount of
2182 // memory.
2183 if (D->isExpandedParameterPack())
2184 Record.push_back(D->getNumExpansionTemplateParameters());
2185
2187 Record.push_back(D->templateParameterKind());
2188 Record.push_back(D->wasDeclaredWithTypename());
2189 // TemplateParmPosition.
2190 Record.push_back(D->getDepth());
2191 Record.push_back(D->getPosition());
2192
2193 if (D->isExpandedParameterPack()) {
2194 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2195 I != N; ++I)
2196 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2198 } else {
2199 // Rest of TemplateTemplateParmDecl.
2200 Record.push_back(D->isParameterPack());
2201 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2203 Record.push_back(OwnsDefaultArg);
2204 if (OwnsDefaultArg)
2205 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2207 }
2208}
2209
2214
2216 VisitDecl(D);
2217 Record.AddStmt(D->getAssertExpr());
2218 Record.push_back(D->isFailed());
2219 Record.AddStmt(D->getMessage());
2220 Record.AddSourceLocation(D->getRParenLoc());
2222}
2223
2226 // Trailing-object flags must be the first thing written so the reader can
2227 // allocate the right amount of trailing storage in CreateDeserialized.
2228 unsigned Flags = 0;
2229 if (D->hasTrailingQualifier())
2230 Flags |= ExplicitInstantiationDecl::HasQualifierFlag;
2231 if (D->hasTrailingArgsAsWritten())
2232 Flags |= ExplicitInstantiationDecl::HasArgsAsWrittenFlag;
2233 Record.push_back(Flags);
2234
2235 VisitDecl(D);
2236 Record.AddDeclRef(D->getSpecialization());
2237 Record.AddSourceLocation(D->getExternLoc());
2238 Record.AddSourceLocation(D->getNameLoc());
2239 Record.AddTypeSourceInfo(D->getRawTypeSourceInfo());
2240 Record.push_back(D->getTemplateSpecializationKind());
2241 // Trailing objects.
2242 if (D->hasTrailingQualifier())
2243 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
2244 if (const auto *Args = D->getTrailingArgsInfo())
2245 Record.AddASTTemplateArgumentListInfo(Args);
2247}
2248
2250 VisitDecl(D);
2251 Record.AddStmt(D->getExpansionPattern());
2252 Record.AddStmt(D->getInstantiations());
2253 Record.AddDeclRef(D->getIndexTemplateParm());
2255}
2256
2257/// Emit the DeclContext part of a declaration context decl.
2259 static_assert(DeclContext::NumDeclContextBits == 12,
2260 "You need to update the serializer after you change the "
2261 "DeclContextBits");
2262 LookupBlockOffsets Offsets;
2263
2264 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2265 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2266 // In reduced BMI, delay writing lexical and visible block for namespace
2267 // in the global module fragment. See the comments of DelayedNamespace for
2268 // details.
2269 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2270 } else {
2271 Offsets.LexicalOffset =
2272 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2273 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC, Offsets);
2274 }
2275
2276 Record.AddLookupOffsets(Offsets);
2277}
2278
2280 assert(IsLocalDecl(D) && "expected a local declaration");
2281
2282 const Decl *Canon = D->getCanonicalDecl();
2283 if (IsLocalDecl(Canon))
2284 return Canon;
2285
2286 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2287 if (CacheEntry)
2288 return CacheEntry;
2289
2290 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2291 if (IsLocalDecl(Redecl))
2292 D = Redecl;
2293 return CacheEntry = D;
2294}
2295
2296template <typename T>
2298 T *First = D->getFirstDecl();
2299 T *MostRecent = First->getMostRecentDecl();
2300 T *DAsT = static_cast<T *>(D);
2301 if (MostRecent != First) {
2302 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2303 "Not considered redeclarable?");
2304
2305 Record.AddDeclRef(First);
2306
2307 // Write out a list of local redeclarations of this declaration if it's the
2308 // first local declaration in the chain.
2309 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2310 if (DAsT == FirstLocal) {
2311 // Emit a list of all imported first declarations so that we can be sure
2312 // that all redeclarations visible to this module are before D in the
2313 // redecl chain.
2314 unsigned I = Record.size();
2315 Record.push_back(0);
2316 if (Writer.Chain)
2317 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2318 // This is the number of imported first declarations + 1.
2319 Record[I] = Record.size() - I;
2320
2321 // Collect the set of local redeclarations of this declaration, from
2322 // newest to oldest.
2323 ASTWriter::RecordData LocalRedecls;
2324 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2325 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2326 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2327 if (!Prev->isFromASTFile())
2328 LocalRedeclWriter.AddDeclRef(Prev);
2329
2330 // If we have any redecls, write them now as a separate record preceding
2331 // the declaration itself.
2332 if (LocalRedecls.empty())
2333 Record.push_back(0);
2334 else
2335 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2336 } else {
2337 Record.push_back(0);
2338 Record.AddDeclRef(FirstLocal);
2339 }
2340
2341 // Make sure that we serialize both the previous and the most-recent
2342 // declarations, which (transitively) ensures that all declarations in the
2343 // chain get serialized.
2344 //
2345 // FIXME: This is not correct; when we reach an imported declaration we
2346 // won't emit its previous declaration.
2347 (void)Writer.GetDeclRef(D->getPreviousDecl());
2348 (void)Writer.GetDeclRef(MostRecent);
2349 } else {
2350 // We use the sentinel value 0 to indicate an only declaration.
2351 Record.push_back(0);
2352 }
2353}
2354
2356 VisitNamedDecl(D);
2358 Record.push_back(D->isCBuffer());
2359 Record.AddSourceLocation(D->getLocStart());
2360 Record.AddSourceLocation(D->getLBraceLoc());
2361 Record.AddSourceLocation(D->getRBraceLoc());
2362
2364}
2365
2367 Record.writeOMPChildren(D->Data);
2368 VisitDecl(D);
2370}
2371
2373 Record.writeOMPChildren(D->Data);
2374 VisitDecl(D);
2376}
2377
2379 Record.writeOMPChildren(D->Data);
2380 VisitDecl(D);
2382}
2383
2386 "You need to update the serializer after you change the "
2387 "NumOMPDeclareReductionDeclBits");
2388
2389 VisitValueDecl(D);
2390 Record.AddSourceLocation(D->getBeginLoc());
2391 Record.AddStmt(D->getCombinerIn());
2392 Record.AddStmt(D->getCombinerOut());
2393 Record.AddStmt(D->getCombiner());
2394 Record.AddStmt(D->getInitOrig());
2395 Record.AddStmt(D->getInitPriv());
2396 Record.AddStmt(D->getInitializer());
2397 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2398 Record.AddDeclRef(D->getPrevDeclInScope());
2400}
2401
2403 Record.writeOMPChildren(D->Data);
2404 VisitValueDecl(D);
2405 Record.AddDeclarationName(D->getVarName());
2406 Record.AddDeclRef(D->getPrevDeclInScope());
2408}
2409
2414
2416 Record.writeUInt32(D->clauses().size());
2417 VisitDecl(D);
2418 Record.writeEnum(D->DirKind);
2419 Record.AddSourceLocation(D->DirectiveLoc);
2420 Record.AddSourceLocation(D->EndLoc);
2421 Record.writeOpenACCClauseList(D->clauses());
2423}
2425 Record.writeUInt32(D->clauses().size());
2426 VisitDecl(D);
2427 Record.writeEnum(D->DirKind);
2428 Record.AddSourceLocation(D->DirectiveLoc);
2429 Record.AddSourceLocation(D->EndLoc);
2430 Record.AddSourceRange(D->ParensLoc);
2431 Record.AddStmt(D->FuncRef);
2432 Record.writeOpenACCClauseList(D->clauses());
2434}
2435
2436//===----------------------------------------------------------------------===//
2437// ASTWriter Implementation
2438//===----------------------------------------------------------------------===//
2439
2440namespace {
2441template <FunctionDecl::TemplatedKind Kind>
2442std::shared_ptr<llvm::BitCodeAbbrev>
2443getFunctionDeclAbbrev(serialization::DeclCode Code) {
2444 using namespace llvm;
2445
2446 auto Abv = std::make_shared<BitCodeAbbrev>();
2447 Abv->Add(BitCodeAbbrevOp(Code));
2448 // RedeclarableDecl
2449 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2450 Abv->Add(BitCodeAbbrevOp(Kind));
2451 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2452
2453 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2454 // DescribedFunctionTemplate
2455 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2456 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2457 // Instantiated From Decl
2458 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2459 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2460 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2461 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2462 3)); // TemplateSpecializationKind
2463 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2464 } else if constexpr (Kind ==
2466 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2467 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2468 3)); // TemplateSpecializationKind
2469 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2470 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2471 Abv->Add(
2472 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2473 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2474 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2475 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2476 Abv->Add(BitCodeAbbrevOp(0));
2477 Abv->Add(
2478 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2479 } else if constexpr (Kind == FunctionDecl::
2480 TK_DependentFunctionTemplateSpecialization) {
2481 // Candidates of specialization
2482 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2483 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2484 } else {
2485 llvm_unreachable("Unknown templated kind?");
2486 }
2487 // Decl
2488 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2489 8)); // Packed DeclBits: ModuleOwnershipKind,
2490 // isUsed, isReferenced, AccessSpecifier,
2491 // isImplicit
2492 //
2493 // The following bits should be 0:
2494 // HasStandaloneLexicalDC, HasAttrs,
2495 // TopLevelDeclInObjCContainer,
2496 // isInvalidDecl
2497 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2498 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2499 // NamedDecl
2500 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2501 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2502 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2503 // ValueDecl
2504 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2505 // DeclaratorDecl
2506 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2507 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2508 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2509 // FunctionDecl
2510 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2511 Abv->Add(BitCodeAbbrevOp(
2512 BitCodeAbbrevOp::Fixed,
2513 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2514 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2515 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2516 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2517 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2518 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2519 // ShouldSkipCheckingODR
2520 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2521 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2522 // This Array slurps the rest of the record. Fortunately we want to encode
2523 // (nearly) all the remaining (variable number of) fields in the same way.
2524 //
2525 // This is:
2526 // NumParams and Params[] from FunctionDecl, and
2527 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2528 //
2529 // Add an AbbrevOp for 'size then elements' and use it here.
2530 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2531 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2532 return Abv;
2533}
2534
2535template <FunctionDecl::TemplatedKind Kind>
2536std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2537 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2538}
2539} // namespace
2540
2541void ASTWriter::WriteDeclAbbrevs() {
2542 using namespace llvm;
2543
2544 std::shared_ptr<BitCodeAbbrev> Abv;
2545
2546 // Abbreviation for DECL_FIELD
2547 Abv = std::make_shared<BitCodeAbbrev>();
2548 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2549 // Decl
2550 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2551 7)); // Packed DeclBits: ModuleOwnershipKind,
2552 // isUsed, isReferenced, AccessSpecifier,
2553 //
2554 // The following bits should be 0:
2555 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2556 // TopLevelDeclInObjCContainer,
2557 // isInvalidDecl
2558 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2559 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2560 // NamedDecl
2561 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2562 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2563 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2564 // ValueDecl
2565 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2566 // DeclaratorDecl
2567 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2568 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2569 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2570 // FieldDecl
2571 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2572 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2573 // Type Source Info
2574 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2575 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2576 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2577
2578 // Abbreviation for DECL_OBJC_IVAR
2579 Abv = std::make_shared<BitCodeAbbrev>();
2580 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2581 // Decl
2582 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2583 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2584 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2585 // isReferenced, TopLevelDeclInObjCContainer,
2586 // AccessSpecifier, ModuleOwnershipKind
2587 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2588 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2589 // NamedDecl
2590 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2591 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2592 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2593 // ValueDecl
2594 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2595 // DeclaratorDecl
2596 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2597 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2598 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2599 // FieldDecl
2600 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2601 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2602 // ObjC Ivar
2603 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2604 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2605 // Type Source Info
2606 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2607 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2608 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2609
2610 // Abbreviation for DECL_ENUM
2611 Abv = std::make_shared<BitCodeAbbrev>();
2612 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2613 // Redeclarable
2614 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2615 // Decl
2616 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2617 7)); // Packed DeclBits: ModuleOwnershipKind,
2618 // isUsed, isReferenced, AccessSpecifier,
2619 //
2620 // The following bits should be 0:
2621 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2622 // TopLevelDeclInObjCContainer,
2623 // isInvalidDecl
2624 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2625 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2626 // NamedDecl
2627 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2628 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2629 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2630 // TypeDecl
2631 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2632 // TagDecl
2633 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2634 Abv->Add(BitCodeAbbrevOp(
2635 BitCodeAbbrevOp::Fixed,
2636 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2637 // EmbeddedInDeclarator, IsFreeStanding,
2638 // isCompleteDefinitionRequired, ExtInfoKind
2639 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2640 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2641 // EnumDecl
2642 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2643 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2644 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2645 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2646 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2647 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2648 // DC
2649 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2650 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2651 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2652 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2653 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2654
2655 // Abbreviation for DECL_RECORD
2656 Abv = std::make_shared<BitCodeAbbrev>();
2657 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2658 // Redeclarable
2659 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2660 // Decl
2661 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2662 7)); // Packed DeclBits: ModuleOwnershipKind,
2663 // isUsed, isReferenced, AccessSpecifier,
2664 //
2665 // The following bits should be 0:
2666 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2667 // TopLevelDeclInObjCContainer,
2668 // isInvalidDecl
2669 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2670 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2671 // NamedDecl
2672 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2673 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2674 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2675 // TypeDecl
2676 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2677 // TagDecl
2678 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2679 Abv->Add(BitCodeAbbrevOp(
2680 BitCodeAbbrevOp::Fixed,
2681 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2682 // EmbeddedInDeclarator, IsFreeStanding,
2683 // isCompleteDefinitionRequired, ExtInfoKind
2684 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2685 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2686 // RecordDecl
2687 Abv->Add(BitCodeAbbrevOp(
2688 BitCodeAbbrevOp::Fixed,
2689 14)); // Packed Record Decl Bits: FlexibleArrayMember,
2690 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2691 // isNonTrivialToPrimitiveDefaultInitialize,
2692 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2693 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2694 // hasNonTrivialToPrimitiveDestructCUnion,
2695 // hasNonTrivialToPrimitiveCopyCUnion,
2696 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2697 // getArgPassingRestrictions
2698 // ODRHash
2699 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2700
2701 // DC
2702 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2703 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2704 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2705 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2706 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2707
2708 // Abbreviation for DECL_PARM_VAR
2709 Abv = std::make_shared<BitCodeAbbrev>();
2710 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2711 // Redeclarable
2712 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2713 // Decl
2714 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2715 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2716 // isReferenced, AccessSpecifier,
2717 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2718 // TopLevelDeclInObjCContainer,
2719 // isInvalidDecl,
2720 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2721 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2722 // NamedDecl
2723 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2724 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2725 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2726 // ValueDecl
2727 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2728 // DeclaratorDecl
2729 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2730 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2731 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2732 // VarDecl
2733 Abv->Add(
2734 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2735 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2736 // isARCPseudoStrong, Linkage, ModulesCodegen
2737 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2738 // ParmVarDecl
2739 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2740 Abv->Add(BitCodeAbbrevOp(
2741 BitCodeAbbrevOp::Fixed,
2742 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2743 // ObjCDeclQualifier, KNRPromoted,
2744 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2745 // Type Source Info
2746 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2747 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2748 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2749
2750 // Abbreviation for DECL_TYPEDEF
2751 Abv = std::make_shared<BitCodeAbbrev>();
2752 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2753 // Redeclarable
2754 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2755 // Decl
2756 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2757 7)); // Packed DeclBits: ModuleOwnershipKind,
2758 // isReferenced, isUsed, AccessSpecifier. Other
2759 // higher bits should be 0: isImplicit,
2760 // HasStandaloneLexicalDC, HasAttrs,
2761 // TopLevelDeclInObjCContainer, isInvalidDecl
2762 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2763 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2764 // NamedDecl
2765 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2766 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2767 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2768 // TypeDecl
2769 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2770 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2771 // TypedefDecl
2772 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2773 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2774 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2775
2776 // Abbreviation for DECL_VAR
2777 Abv = std::make_shared<BitCodeAbbrev>();
2778 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2779 // Redeclarable
2780 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2781 // Decl
2782 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2783 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2784 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2785 // isReferenced, TopLevelDeclInObjCContainer,
2786 // AccessSpecifier, ModuleOwnershipKind
2787 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2788 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2789 // NamedDecl
2790 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2791 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2792 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2793 // ValueDecl
2794 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2795 // DeclaratorDecl
2796 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2797 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2798 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2799 // VarDecl
2800 Abv->Add(BitCodeAbbrevOp(
2801 BitCodeAbbrevOp::Fixed,
2802 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2803 // SClass, TSCSpec, InitStyle,
2804 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2805 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2806 // isInline, isInlineSpecified, isConstexpr,
2807 // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
2808 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2809 // IsCXXForRangeImplicitVar
2810 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2811 // Type Source Info
2812 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2813 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2814 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2815
2816 // Abbreviation for DECL_CXX_METHOD
2817 DeclCXXMethodAbbrev =
2818 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2819 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2820 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2821 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2822 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2823 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2824 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2825 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2826 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2827 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2828 getCXXMethodAbbrev<
2830
2831 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2832 Abv = std::make_shared<BitCodeAbbrev>();
2833 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2834 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2835 // Decl
2836 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2837 7)); // Packed DeclBits: ModuleOwnershipKind,
2838 // isReferenced, isUsed, AccessSpecifier. Other
2839 // higher bits should be 0: isImplicit,
2840 // HasStandaloneLexicalDC, HasAttrs,
2841 // TopLevelDeclInObjCContainer, isInvalidDecl
2842 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2843 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2844 // NamedDecl
2845 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2846 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2847 Abv->Add(BitCodeAbbrevOp(0));
2848 // TypeDecl
2849 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2850 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2851 // TemplateTypeParmDecl
2852 Abv->Add(
2853 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2854 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2855 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2856
2857 // Abbreviation for DECL_USING_SHADOW
2858 Abv = std::make_shared<BitCodeAbbrev>();
2859 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2860 // Redeclarable
2861 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2862 // Decl
2863 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2864 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2865 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2866 // isReferenced, TopLevelDeclInObjCContainer,
2867 // AccessSpecifier, ModuleOwnershipKind
2868 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2869 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2870 // NamedDecl
2871 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2872 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2873 Abv->Add(BitCodeAbbrevOp(0));
2874 // UsingShadowDecl
2875 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2876 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2877 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2878 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2879 6)); // InstantiatedFromUsingShadowDecl
2880 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2881
2882 // Abbreviation for EXPR_DECL_REF
2883 Abv = std::make_shared<BitCodeAbbrev>();
2884 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2885 // Stmt
2886 // Expr
2887 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2888 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2889 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2890 // DeclRefExpr
2891 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2892 // IsImmediateEscalating, NonOdrUseReason.
2893 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2894 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2895 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2896 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2897 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2898
2899 // Abbreviation for EXPR_INTEGER_LITERAL
2900 Abv = std::make_shared<BitCodeAbbrev>();
2901 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2902 //Stmt
2903 // Expr
2904 // DependenceKind, ValueKind, ObjectKind
2905 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2906 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2907 // Integer Literal
2908 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2909 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2910 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2911 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2912
2913 // Abbreviation for EXPR_CHARACTER_LITERAL
2914 Abv = std::make_shared<BitCodeAbbrev>();
2915 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2916 //Stmt
2917 // Expr
2918 // DependenceKind, ValueKind, ObjectKind
2919 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2920 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2921 // Character Literal
2922 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2923 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2924 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2925 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2926
2927 // Abbreviation for EXPR_IMPLICIT_CAST
2928 Abv = std::make_shared<BitCodeAbbrev>();
2929 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2930 // Stmt
2931 // Expr
2932 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2933 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2934 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2935 // CastExpr
2936 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2937 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2938 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2939 // ImplicitCastExpr
2940 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2941
2942 // Abbreviation for EXPR_BINARY_OPERATOR
2943 Abv = std::make_shared<BitCodeAbbrev>();
2944 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2945 // Stmt
2946 // Expr
2947 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2948 // be 0 in this case.
2949 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2950 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2951 // BinaryOperator
2952 Abv->Add(
2953 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2954 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2955 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2956
2957 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2958 Abv = std::make_shared<BitCodeAbbrev>();
2959 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2960 // Stmt
2961 // Expr
2962 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2963 // be 0 in this case.
2964 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2965 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2966 // BinaryOperator
2967 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2968 Abv->Add(
2969 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2970 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2971 // CompoundAssignOperator
2972 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2973 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2974 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2975
2976 // Abbreviation for EXPR_CALL
2977 Abv = std::make_shared<BitCodeAbbrev>();
2978 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2979 // Stmt
2980 // Expr
2981 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2982 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2983 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2984 // CallExpr
2985 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2986 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2987 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2988 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2989
2990 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2991 Abv = std::make_shared<BitCodeAbbrev>();
2992 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2993 // Stmt
2994 // Expr
2995 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2996 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2997 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2998 // CallExpr
2999 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
3000 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
3001 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3002 // CXXOperatorCallExpr
3003 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
3004 Abv->Add(BitCodeAbbrevOp(0)); // IsReversed
3005 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3006 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
3007
3008 // Abbreviation for EXPR_CXX_MEMBER_CALL
3009 Abv = std::make_shared<BitCodeAbbrev>();
3010 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
3011 // Stmt
3012 // Expr
3013 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
3014 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
3015 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
3016 // CallExpr
3017 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
3018 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
3019 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3020 // CXXMemberCallExpr
3021 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
3022
3023 // Abbreviation for STMT_COMPOUND
3024 Abv = std::make_shared<BitCodeAbbrev>();
3025 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
3026 // Stmt
3027 // CompoundStmt
3028 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
3029 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
3030 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3031 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
3032 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
3033
3034 Abv = std::make_shared<BitCodeAbbrev>();
3035 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
3036 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3037 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
3038
3039 Abv = std::make_shared<BitCodeAbbrev>();
3040 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
3041 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3042 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3043
3044 Abv = std::make_shared<BitCodeAbbrev>();
3045 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
3046 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3047 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3048
3049 Abv = std::make_shared<BitCodeAbbrev>();
3050 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
3051 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3052 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
3053
3054 Abv = std::make_shared<BitCodeAbbrev>();
3055 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
3056 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3057 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
3058
3059 Abv = std::make_shared<BitCodeAbbrev>();
3060 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
3061 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
3062 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
3063}
3064
3065/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
3066/// consumers of the AST.
3067///
3068/// Such decls will always be deserialized from the AST file, so we would like
3069/// this to be as restrictive as possible. Currently the predicate is driven by
3070/// code generation requirements, if other clients have a different notion of
3071/// what is "required" then we may have to consider an alternate scheme where
3072/// clients can iterate over the top-level decls and get information on them,
3073/// without necessary deserializing them. We could explicitly require such
3074/// clients to use a separate API call to "realize" the decl. This should be
3075/// relatively painless since they would presumably only do it for top-level
3076/// decls.
3077static bool isRequiredDecl(const Decl *D, ASTContext &Context,
3078 Module *WritingModule) {
3079 // Named modules have different semantics than header modules. Every named
3080 // module units owns a translation unit. So the importer of named modules
3081 // doesn't need to deserilize everything ahead of time.
3082 if (WritingModule && WritingModule->isNamedModule()) {
3083 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
3084 // And the behavior of MSVC for such cases will leak this to the module
3085 // users. Given pragma is not a standard thing, the compiler has the space
3086 // to do their own decision. Let's follow MSVC here.
3088 return true;
3089 return false;
3090 }
3091
3092 // An ObjCMethodDecl is never considered as "required" because its
3093 // implementation container always is.
3094
3095 // File scoped assembly or obj-c or OMP declare target implementation must be
3096 // seen.
3098 return true;
3099
3100 if (WritingModule && isPartOfPerModuleInitializer(D)) {
3101 // These declarations are part of the module initializer, and are emitted
3102 // if and when the module is imported, rather than being emitted eagerly.
3103 return false;
3104 }
3105
3106 return Context.DeclMustBeEmitted(D);
3107}
3108
3109void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
3110 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
3111 "serializing");
3112
3113 // Determine the ID for this declaration.
3114 LocalDeclID ID;
3115 assert(!D->isFromASTFile() && "should not be emitting imported decl");
3116 LocalDeclID &IDR = DeclIDs[D];
3117 if (IDR.isInvalid())
3118 IDR = NextDeclID++;
3119
3120 ID = IDR;
3121
3122 assert(ID >= FirstDeclID && "invalid decl ID");
3123
3125 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
3126
3127 // Build a record for this declaration
3128 W.Visit(D);
3129
3130 // Emit this declaration to the bitstream.
3131 uint64_t Offset = W.Emit(D);
3132
3133 // Record the offset for this declaration
3134 SourceLocation Loc = D->getLocation();
3136 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
3137
3138 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
3139 if (DeclOffsets.size() == Index)
3140 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
3141 else if (DeclOffsets.size() < Index) {
3142 // FIXME: Can/should this happen?
3143 DeclOffsets.resize(Index+1);
3144 DeclOffsets[Index].setRawLoc(RawLoc);
3145 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
3146 } else {
3147 llvm_unreachable("declarations should be emitted in ID order");
3148 }
3149
3150 SourceManager &SM = Context.getSourceManager();
3151 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
3152 associateDeclWithFile(D, ID);
3153
3154 // Note declarations that should be deserialized eagerly so that we can add
3155 // them to a record in the AST file later.
3156 if (isRequiredDecl(D, Context, WritingModule))
3157 AddDeclRef(D, EagerlyDeserializedDecls);
3158}
3159
3161 // Switch case IDs are per function body.
3162 Writer->ClearSwitchCaseIDs();
3163
3164 assert(FD->doesThisDeclarationHaveABody());
3165 bool ModulesCodegen = shouldFunctionGenerateHereOnly(FD);
3166 Record->push_back(ModulesCodegen);
3167 if (ModulesCodegen)
3168 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3169 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3170 Record->push_back(CD->getNumCtorInitializers());
3171 if (CD->getNumCtorInitializers())
3172 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3173 }
3174 AddStmt(FD->getBody());
3175}
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:245
SourceManager & getSourceManager()
Definition ASTContext.h:913
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:4232
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition DeclCXX.h:4258
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:4858
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition Decl.h:4981
bool canAvoidCopyToHeap() const
Definition Decl.h:5012
size_t param_size() const
Definition Decl.h:4960
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:4937
ArrayRef< Capture > captures() const
Definition Decl.h:4985
bool blockMissingReturnType() const
Definition Decl.h:4993
bool capturesCXXThis() const
Definition Decl.h:4990
bool doesNotEscape() const
Definition Decl.h:5009
bool isConversionFromLambda() const
Definition Decl.h:5001
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:4944
bool isVariadic() const
Definition Decl.h:4933
TypeSourceInfo * getSignatureAsWritten() const
Definition Decl.h:4941
Represents a C++ constructor within a class.
Definition DeclCXX.h:2645
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Definition DeclCXX.h:2894
ArrayRef< CXXDefaultArgExpr * > getCtorClosureDefaultArgs() const
Definition DeclCXX.cpp:3139
Represents a C++ conversion function within a class.
Definition DeclCXX.h:2994
ExplicitSpecifier getExplicitSpecifier() const
Definition DeclCXX.h:3021
Represents a C++ deduction guide declaration.
Definition DeclCXX.h:2001
ExplicitSpecifier getExplicitSpecifier() const
Definition DeclCXX.h:2061
CXXConstructorDecl * getCorrespondingConstructor() const
Get the constructor from which this deduction guide was generated, if this is an implicit deduction g...
Definition DeclCXX.h:2073
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:2080
DeductionCandidate getDeductionCandidateKind() const
Definition DeclCXX.h:2100
SourceDeductionGuideKind getSourceDeductionGuideKind() const
Definition DeclCXX.h:2088
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1275
Represents a C++ destructor within a class.
Definition DeclCXX.h:2924
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:2963
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:2153
CXXMethodDecl * getMostRecentDecl()
Definition DeclCXX.h:2273
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:5130
unsigned getNumParams() const
Definition Decl.h:5168
unsigned getContextParamPosition() const
Definition Decl.h:5197
bool isNothrow() const
Definition Decl.cpp:5842
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5170
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:3724
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:1467
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2108
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Definition DeclBase.h:2124
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:1079
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition DeclBase.h:1094
SourceLocation getEndLoc() const LLVM_READONLY
Definition DeclBase.h:444
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Definition DeclBase.h:1244
bool hasAttrs() const
Definition DeclBase.h:527
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:602
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:101
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
Definition DeclBase.h:894
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:1002
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition DeclBase.h:855
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition DeclBase.h:806
bool isInvalidDecl() const
Definition DeclBase.h:597
unsigned getIdentifierNamespace() const
Definition DeclBase.h:907
SourceLocation getLocation() const
Definition DeclBase.h:448
const char * getDeclKindName() const
Definition DeclBase.cpp:169
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
Definition DeclBase.h:630
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc....
Definition DeclBase.h:643
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:457
AccessSpecifier getAccess() const
Definition DeclBase.h:516
SourceLocation getBeginLoc() const LLVM_READONLY
Definition DeclBase.h:440
AttrVec & getAttrs()
Definition DeclBase.h:533
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition DeclBase.h:936
bool hasAttr() const
Definition DeclBase.h:586
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition DeclBase.h:996
Kind getKind() const
Definition DeclBase.h:451
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:782
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:824
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:811
A decomposition declaration.
Definition DeclCXX.h:4296
ArrayRef< BindingDecl * > bindings() const
Definition DeclCXX.h:4336
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:5365
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3606
llvm::APSInt getInitVal() const
Definition Decl.h:3626
const Expr * getInitExpr() const
Definition Decl.h:3624
Represents an enum.
Definition Decl.h:4194
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition Decl.h:4466
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4412
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition Decl.h:4404
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4415
unsigned getODRHash()
Definition Decl.cpp:5303
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Definition Decl.h:4383
EnumDecl * getMostRecentDecl()
Definition Decl.h:4299
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition Decl.h:4421
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition Decl.h:4367
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
Definition Decl.h:4393
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition Decl.h:4359
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:5318
SourceLocation getRBraceLoc() const
Definition Decl.h:5337
This represents one expression.
Definition Expr.h:114
Represents a member of a struct/union/class.
Definition Decl.h:3341
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition Decl.h:3441
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition Decl.h:3521
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition Decl.h:3562
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
Definition Decl.h:3457
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition Decl.h:3567
const Expr * getAsmStringExpr() const
Definition Decl.h:4803
SourceLocation getRParenLoc() const
Definition Decl.h:4797
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:2082
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Definition Decl.h:2862
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition Decl.cpp:3284
bool isTrivialForCall() const
Definition Decl.h:2549
ConstexprSpecKind getConstexprKind() const
Definition Decl.h:2645
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
Definition Decl.cpp:3199
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition Decl.cpp:4268
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
Definition Decl.cpp:3624
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
Definition Decl.h:3098
SourceLocation getDefaultLoc() const
Definition Decl.h:2567
bool usesSEHTry() const
Indicates the function uses __try.
Definition Decl.h:2687
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2947
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
Definition Decl.h:2558
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition Decl.h:2546
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Definition Decl.h:2617
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
Definition Decl.cpp:4247
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition Decl.cpp:4398
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition Decl.h:2482
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition Decl.cpp:4464
unsigned getODRHash()
Returns ODRHash of the function.
Definition Decl.cpp:4781
@ TK_FunctionTemplateSpecialization
Definition Decl.h:2098
@ TK_DependentFunctionTemplateSpecialization
Definition Decl.h:2101
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:3065
bool FriendConstraintRefersToEnclosingTemplate() const
Definition Decl.h:2880
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition Decl.cpp:4219
bool isDeletedAsWritten() const
Definition Decl.h:2713
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
Definition Decl.h:2522
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition Decl.h:2526
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
Definition Decl.h:2597
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Definition Decl.h:2852
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
Definition Decl.cpp:3632
bool isDefaulted() const
Whether this function is defaulted.
Definition Decl.h:2554
bool isIneligibleOrNotSelected() const
Definition Decl.h:2587
FunctionDecl * getInstantiatedFromDecl() const
Definition Decl.cpp:4292
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition Decl.h:2513
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition Decl.h:2628
size_t param_size() const
Definition Decl.h:2963
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition Decl.h:3076
bool isInstantiatedFromMemberTemplate() const
Definition Decl.h:2535
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:5380
bool isCBuffer() const
Definition Decl.h:5424
SourceLocation getLBraceLoc() const
Definition Decl.h:5421
SourceLocation getLocStart() const LLVM_READONLY
Definition Decl.h:5420
SourceLocation getRBraceLoc() const
Definition Decl.h:5422
ArrayRef< TemplateArgument > getTemplateArguments() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5239
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:6213
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition Decl.h:5297
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3650
unsigned getChainingSize() const
Definition Decl.h:3675
ArrayRef< NamedDecl * > chain() const
Definition Decl.h:3671
Represents the declaration of a label.
Definition Decl.h:526
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition DeclCXX.h:3355
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition DeclCXX.h:3401
Represents a linkage specification.
Definition DeclCXX.h:3062
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition DeclCXX.h:3085
SourceLocation getExternLoc() const
Definition DeclCXX.h:3101
SourceLocation getRBraceLoc() const
Definition DeclCXX.h:3102
A global _GUID constant.
Definition DeclCXX.h:4468
Parts getParts() const
Get the decomposed parts of this declaration.
Definition DeclCXX.h:4498
MSGuidDeclParts Parts
Definition DeclCXX.h:4470
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4414
IdentifierInfo * getGetterId() const
Definition DeclCXX.h:4436
IdentifierInfo * getSetterId() const
Definition DeclCXX.h:4438
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:892
bool isNamedModule() const
Does this Module is a named module of a standard named module?
Definition Module.h:426
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
Definition Module.h:943
This represents a decl that may have a name.
Definition Decl.h:276
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition DeclBase.h:657
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition Decl.cpp:1184
bool isPlaceholderVar(const LangOptions &LangOpts) const
Definition Decl.cpp:1097
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:342
Represents a C++ namespace alias.
Definition DeclCXX.h:3248
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3309
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3334
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition DeclCXX.h:3337
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition DeclCXX.h:3318
Represent a C++ namespace.
Definition Decl.h:594
SourceLocation getRBraceLoc() const
Definition Decl.h:694
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:693
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition Decl.h:645
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition Decl.h:650
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
Definition Decl.h:677
bool isNested() const
Returns true if this is a nested namespace declaration.
Definition Decl.h:659
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:5065
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5097
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:5813
unsigned getNumParams() const
Definition Decl.h:5095
Represents a parameter to a function.
Definition Decl.h:1832
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion:
Definition Decl.h:1913
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1892
SourceLocation getExplicitObjectParamThisLoc() const
Definition Decl.h:1928
bool isObjCMethodParameter() const
Definition Decl.h:1875
ObjCDeclQualifier getObjCDeclQualifier() const
Definition Decl.h:1896
bool hasUninstantiatedDefaultArg() const
Definition Decl.h:1965
bool hasInheritedDefaultArg() const
Definition Decl.h:1977
Expr * getUninstantiatedDefaultArg()
Definition Decl.cpp:3058
unsigned getFunctionScopeDepth() const
Definition Decl.h:1882
Represents a #pragma comment line.
Definition Decl.h:169
StringRef getArg() const
Definition Decl.h:192
PragmaMSCommentKind getCommentKind() const
Definition Decl.h:190
Represents a #pragma detect_mismatch line.
Definition Decl.h:203
StringRef getName() const
Definition Decl.h:224
StringRef getValue() const
Definition Decl.h:225
A (possibly-)qualified type.
Definition TypeBase.h:938
Represents a struct/union/class.
Definition Decl.h:4508
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition Decl.cpp:5554
bool hasNonTrivialToPrimitiveDestructCUnion() const
Definition Decl.h:4618
bool hasNonTrivialToPrimitiveCopyCUnion() const
Definition Decl.h:4626
RecordArgPassingKind getArgPassingRestrictions() const
Definition Decl.h:4649
bool hasVolatileMember() const
Definition Decl.h:4571
bool hasFlexibleArrayMember() const
Definition Decl.h:4541
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Definition Decl.h:4610
bool hasObjectMember() const
Definition Decl.h:4568
bool isNonTrivialToPrimitiveDestroy() const
Definition Decl.h:4602
bool isNonTrivialToPrimitiveCopy() const
Definition Decl.h:4594
bool isParamDestroyedInCallee() const
Definition Decl.h:4658
RecordDecl * getMostRecentDecl()
Definition Decl.h:4534
bool hasUninitializedExplicitInitFields() const
Definition Decl.h:4634
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition Decl.h:4586
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition Decl.h:4560
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:2122
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:4183
bool isFailed() const
Definition DeclCXX.h:4212
SourceLocation getRParenLoc() const
Definition DeclCXX.h:4214
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3900
SourceRange getBraceRange() const
Definition Decl.h:3977
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition Decl.h:3996
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:4025
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:4001
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition Decl.h:4137
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition Decl.h:4010
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
Definition Decl.h:4036
TagKind getTagKind() const
Definition Decl.h:4100
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:4818
unsigned getOrdinal() const
Definition Decl.h:4842
The top declaration context.
Definition Decl.h:107
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition Decl.h:3871
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition Decl.h:3889
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:224
UnsignedOrNone getArgPackSubstIndex() const
Definition ASTConcept.h:247
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Definition ASTConcept.h:241
ConceptReference * getConceptReference() const
Definition ASTConcept.h:245
Represents a declaration of a type.
Definition Decl.h:3696
const Type * getTypeForDecl() const
Definition Decl.h:3721
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:3730
QualType getType() const
Return the type wrapped by this type source info.
Definition TypeBase.h:8560
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition Type.cpp:2235
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition Decl.h:3850
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3745
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:3795
TypedefNameDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isModed() const
Definition Decl.h:3791
QualType getUnderlyingType() const
Definition Decl.h:3800
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
Definition Decl.cpp:5911
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4525
const APValue & getValue() const
Definition DeclCXX.h:4551
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition DeclCXX.h:4165
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4084
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition DeclCXX.h:4114
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4118
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4135
Represents a dependent using declaration which was not marked with typename.
Definition DeclCXX.h:3987
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition DeclCXX.h:4018
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4028
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4045
Represents a C++ using-declaration.
Definition DeclCXX.h:3638
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition DeclCXX.h:3687
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3672
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition DeclCXX.h:3665
Represents C++ using-directive.
Definition DeclCXX.h:3143
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition DeclCXX.h:3214
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:3210
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3218
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3188
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3839
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
Definition DeclCXX.h:3863
TypeSourceInfo * getEnumType() const
Definition DeclCXX.h:3875
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Definition DeclCXX.h:3859
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition DeclCXX.h:3920
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition DeclCXX.h:3949
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition DeclCXX.h:3953
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3446
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:3510
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:714
QualType getType() const
Definition Decl.h:725
Represents a variable declaration or definition.
Definition Decl.h:934
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition Decl.cpp:2802
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition Decl.h:1606
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition Decl.h:1503
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition Decl.h:1615
@ CInit
C-style initialization with assignment.
Definition Decl.h:939
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C.
Definition Decl.h:1569
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
Definition Decl.cpp:2446
bool isInlineSpecified() const
Definition Decl.h:1591
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition Decl.h:1308
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
Definition Decl.h:1559
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition Decl.h:1549
bool isCXXForRangeImplicitVar() const
Whether this variable is the implicit '__range' variable in C++ range-based for loops.
Definition Decl.h:1659
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition Decl.h:1531
bool isInline() const
Whether this variable is (C++1z) inline.
Definition Decl.h:1588
ThreadStorageClassSpecifier getTSCSpec() const
Definition Decl.h:1185
const Expr * getInit() const
Definition Decl.h:1393
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition Decl.h:1584
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition Decl.h:1252
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1176
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
Definition Decl.cpp:2703
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition Decl.h:1513
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition Decl.h:1625
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:2771
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Definition Decl.cpp:2890
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:578
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
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:90
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:91
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition Expr.h:6804
Data that is common to all of the declarations of a given function template.
uint16_t Part2
...-89ab-...
Definition DeclCXX.h:4447
uint32_t Part1
{01234567-...
Definition DeclCXX.h:4445
uint16_t Part3
...-cdef-...
Definition DeclCXX.h:4449
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition DeclCXX.h:4451
static DeclType * getDecl(EntryType *D)