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