clang 22.0.0git
ASTWriterDecl.cpp
Go to the documentation of this file.
1//===--- ASTWriterDecl.cpp - Declaration Serialization --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements serialization for Declarations.
10//
11//===----------------------------------------------------------------------===//
12
13#include "ASTCommon.h"
14#include "clang/AST/Attr.h"
15#include "clang/AST/DeclCXX.h"
18#include "clang/AST/Expr.h"
24#include "llvm/Bitstream/BitstreamWriter.h"
25#include "llvm/Support/ErrorHandling.h"
26using namespace clang;
27using namespace serialization;
28
29//===----------------------------------------------------------------------===//
30// Utility functions
31//===----------------------------------------------------------------------===//
32
33namespace {
34
35// Helper function that returns true if the decl passed in the argument is
36// a defintion in dependent contxt.
37template <typename DT> bool isDefinitionInDependentContext(DT *D) {
38 return D->isDependentContext() && D->isThisDeclarationADefinition();
39}
40
41} // namespace
42
43//===----------------------------------------------------------------------===//
44// Declaration serialization
45//===----------------------------------------------------------------------===//
46
47namespace clang {
48 class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
49 ASTWriter &Writer;
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 DeclBits.addBit(D->isUsed(false));
529 DeclBits.addBits(D->getAccess(), /*BitWidth=*/2);
530 DeclBits.addBit(D->isImplicit());
531 DeclBits.addBit(D->getDeclContext() != D->getLexicalDeclContext());
532 DeclBits.addBit(D->hasAttrs());
534 DeclBits.addBit(D->isInvalidDecl());
535 Record.push_back(DeclBits);
536
537 Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
538 if (D->getDeclContext() != D->getLexicalDeclContext())
539 Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
540
541 if (D->hasAttrs())
542 Record.AddAttributes(D->getAttrs());
543
544 Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
545
546 // If this declaration injected a name into a context different from its
547 // lexical context, and that context is an imported namespace, we need to
548 // update its visible declarations to include this name.
549 //
550 // This happens when we instantiate a class with a friend declaration or a
551 // function with a local extern declaration, for instance.
552 //
553 // FIXME: Can we handle this in AddedVisibleDecl instead?
554 if (D->isOutOfLine()) {
555 auto *DC = D->getDeclContext();
556 while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
557 if (!NS->isFromASTFile())
558 break;
559 Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
560 if (!NS->isInlineNamespace())
561 break;
562 DC = NS->getParent();
563 }
564 }
565}
566
568 StringRef Arg = D->getArg();
569 Record.push_back(Arg.size());
570 VisitDecl(D);
571 Record.AddSourceLocation(D->getBeginLoc());
572 Record.push_back(D->getCommentKind());
573 Record.AddString(Arg);
575}
576
579 StringRef Name = D->getName();
580 StringRef Value = D->getValue();
581 Record.push_back(Name.size() + 1 + Value.size());
582 VisitDecl(D);
583 Record.AddSourceLocation(D->getBeginLoc());
584 Record.AddString(Name);
585 Record.AddString(Value);
587}
588
590 llvm_unreachable("Translation units aren't directly serialized");
591}
592
594 VisitDecl(D);
595 Record.AddDeclarationName(D->getDeclName());
596 Record.push_back(needsAnonymousDeclarationNumber(D)
597 ? Writer.getAnonymousDeclarationNumber(D)
598 : 0);
599}
600
603 Record.AddSourceLocation(D->getBeginLoc());
605 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
606}
607
610 VisitTypeDecl(D);
611 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
612 Record.push_back(D->isModed());
613 if (D->isModed())
614 Record.AddTypeRef(D->getUnderlyingType());
615 Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
616}
617
620 if (D->getDeclContext() == D->getLexicalDeclContext() &&
621 !D->hasAttrs() &&
622 !D->isImplicit() &&
623 D->getFirstDecl() == D->getMostRecentDecl() &&
624 !D->isInvalidDecl() &&
626 !D->isModulePrivate() &&
629 AbbrevToUse = Writer.getDeclTypedefAbbrev();
630
632}
633
639
641 static_assert(DeclContext::NumTagDeclBits == 23,
642 "You need to update the serializer after you change the "
643 "TagDeclBits");
644
646 VisitTypeDecl(D);
647 Record.push_back(D->getIdentifierNamespace());
648
649 BitsPacker TagDeclBits;
650 TagDeclBits.addBits(llvm::to_underlying(D->getTagKind()), /*BitWidth=*/3);
651 TagDeclBits.addBit(!isa<CXXRecordDecl>(D) ? D->isCompleteDefinition() : 0);
652 TagDeclBits.addBit(D->isEmbeddedInDeclarator());
653 TagDeclBits.addBit(D->isFreeStanding());
654 TagDeclBits.addBit(D->isCompleteDefinitionRequired());
655 TagDeclBits.addBits(
656 D->hasExtInfo() ? 1 : (D->getTypedefNameForAnonDecl() ? 2 : 0),
657 /*BitWidth=*/2);
658 Record.push_back(TagDeclBits);
659
660 Record.AddSourceRange(D->getBraceRange());
661
662 if (D->hasExtInfo()) {
663 Record.AddQualifierInfo(*D->getExtInfo());
664 } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
665 Record.AddDeclRef(TD);
666 Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
667 }
668}
669
671 static_assert(DeclContext::NumEnumDeclBits == 43,
672 "You need to update the serializer after you change the "
673 "EnumDeclBits");
674
675 VisitTagDecl(D);
676 Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
677 if (!D->getIntegerTypeSourceInfo())
678 Record.AddTypeRef(D->getIntegerType());
679 Record.AddTypeRef(D->getPromotionType());
680
681 BitsPacker EnumDeclBits;
682 EnumDeclBits.addBits(D->getNumPositiveBits(), /*BitWidth=*/8);
683 EnumDeclBits.addBits(D->getNumNegativeBits(), /*BitWidth=*/8);
684 EnumDeclBits.addBit(D->isScoped());
685 EnumDeclBits.addBit(D->isScopedUsingClassTag());
686 EnumDeclBits.addBit(D->isFixed());
687 Record.push_back(EnumDeclBits);
688
689 Record.push_back(D->getODRHash());
690
692 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
693 Record.push_back(MemberInfo->getTemplateSpecializationKind());
694 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
695 } else {
696 Record.AddDeclRef(nullptr);
697 }
698
699 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
700 !D->isInvalidDecl() && !D->isImplicit() && !D->hasExtInfo() &&
702 D->getFirstDecl() == D->getMostRecentDecl() &&
708 AbbrevToUse = Writer.getDeclEnumAbbrev();
709
711}
712
714 static_assert(DeclContext::NumRecordDeclBits == 64,
715 "You need to update the serializer after you change the "
716 "RecordDeclBits");
717
718 VisitTagDecl(D);
719
720 BitsPacker RecordDeclBits;
721 RecordDeclBits.addBit(D->hasFlexibleArrayMember());
722 RecordDeclBits.addBit(D->isAnonymousStructOrUnion());
723 RecordDeclBits.addBit(D->hasObjectMember());
724 RecordDeclBits.addBit(D->hasVolatileMember());
726 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveCopy());
727 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDestroy());
730 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveCopyCUnion());
731 RecordDeclBits.addBit(D->hasUninitializedExplicitInitFields());
732 RecordDeclBits.addBit(D->isParamDestroyedInCallee());
733 RecordDeclBits.addBits(llvm::to_underlying(D->getArgPassingRestrictions()), 2);
734 Record.push_back(RecordDeclBits);
735
736 // Only compute this for C/Objective-C, in C++ this is computed as part
737 // of CXXRecordDecl.
738 if (!isa<CXXRecordDecl>(D))
739 Record.push_back(D->getODRHash());
740
741 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
742 !D->isImplicit() && !D->isInvalidDecl() && !D->hasExtInfo() &&
744 D->getFirstDecl() == D->getMostRecentDecl() &&
749 AbbrevToUse = Writer.getDeclRecordAbbrev();
750
752}
753
756 Record.AddTypeRef(D->getType());
757}
758
761 Record.push_back(D->getInitExpr()? 1 : 0);
762 if (D->getInitExpr())
763 Record.AddStmt(D->getInitExpr());
764 Record.AddAPSInt(D->getInitVal());
765
767}
768
771 Record.AddSourceLocation(D->getInnerLocStart());
772 Record.push_back(D->hasExtInfo());
773 if (D->hasExtInfo()) {
774 DeclaratorDecl::ExtInfo *Info = D->getExtInfo();
775 Record.AddQualifierInfo(*Info);
776 Record.AddStmt(
777 const_cast<Expr *>(Info->TrailingRequiresClause.ConstraintExpr));
778 Record.writeUnsignedOrNone(Info->TrailingRequiresClause.ArgPackSubstIndex);
779 }
780 // The location information is deferred until the end of the record.
781 Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType()
782 : QualType());
783}
784
786 static_assert(DeclContext::NumFunctionDeclBits == 45,
787 "You need to update the serializer after you change the "
788 "FunctionDeclBits");
789
791
792 Record.push_back(D->getTemplatedKind());
793 switch (D->getTemplatedKind()) {
795 break;
797 Record.AddDeclRef(D->getInstantiatedFromDecl());
798 break;
800 Record.AddDeclRef(D->getDescribedFunctionTemplate());
801 break;
804 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
805 Record.push_back(MemberInfo->getTemplateSpecializationKind());
806 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
807 break;
808 }
811 FTSInfo = D->getTemplateSpecializationInfo();
812
814
815 Record.AddDeclRef(FTSInfo->getTemplate());
816 Record.push_back(FTSInfo->getTemplateSpecializationKind());
817
818 // Template arguments.
819 Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
820
821 // Template args as written.
822 Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
823 if (FTSInfo->TemplateArgumentsAsWritten)
824 Record.AddASTTemplateArgumentListInfo(
826
827 Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
828
829 if (MemberSpecializationInfo *MemberInfo =
830 FTSInfo->getMemberSpecializationInfo()) {
831 Record.push_back(1);
832 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
833 Record.push_back(MemberInfo->getTemplateSpecializationKind());
834 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
835 } else {
836 Record.push_back(0);
837 }
838
839 if (D->isCanonicalDecl()) {
840 // Write the template that contains the specializations set. We will
841 // add a FunctionTemplateSpecializationInfo to it when reading.
842 Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
843 }
844 break;
845 }
848 DFTSInfo = D->getDependentSpecializationInfo();
849
850 // Candidates.
851 Record.push_back(DFTSInfo->getCandidates().size());
852 for (FunctionTemplateDecl *FTD : DFTSInfo->getCandidates())
853 Record.AddDeclRef(FTD);
854
855 // Templates args.
856 Record.push_back(DFTSInfo->TemplateArgumentsAsWritten != nullptr);
857 if (DFTSInfo->TemplateArgumentsAsWritten)
858 Record.AddASTTemplateArgumentListInfo(
860 break;
861 }
862 }
863
865 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
866 Record.push_back(D->getIdentifierNamespace());
867
868 // The order matters here. It will be better to put the bit with higher
869 // probability to be 0 in the end of the bits. See the comments in VisitDecl
870 // for details.
871 BitsPacker FunctionDeclBits;
872 // FIXME: stable encoding
873 FunctionDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()), 3);
874 FunctionDeclBits.addBits((uint32_t)D->getStorageClass(), /*BitWidth=*/3);
875 FunctionDeclBits.addBit(D->isInlineSpecified());
876 FunctionDeclBits.addBit(D->isInlined());
877 FunctionDeclBits.addBit(D->hasSkippedBody());
878 FunctionDeclBits.addBit(D->isVirtualAsWritten());
879 FunctionDeclBits.addBit(D->isPureVirtual());
880 FunctionDeclBits.addBit(D->hasInheritedPrototype());
881 FunctionDeclBits.addBit(D->hasWrittenPrototype());
882 FunctionDeclBits.addBit(D->isDeletedBit());
883 FunctionDeclBits.addBit(D->isTrivial());
884 FunctionDeclBits.addBit(D->isTrivialForCall());
885 FunctionDeclBits.addBit(D->isDefaulted());
886 FunctionDeclBits.addBit(D->isExplicitlyDefaulted());
887 FunctionDeclBits.addBit(D->isIneligibleOrNotSelected());
888 FunctionDeclBits.addBits((uint64_t)(D->getConstexprKind()), /*BitWidth=*/2);
889 FunctionDeclBits.addBit(D->hasImplicitReturnZero());
890 FunctionDeclBits.addBit(D->isMultiVersion());
891 FunctionDeclBits.addBit(D->isLateTemplateParsed());
892 FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate());
894 FunctionDeclBits.addBit(D->usesSEHTry());
895 FunctionDeclBits.addBit(D->isDestroyingOperatorDelete());
896 FunctionDeclBits.addBit(D->isTypeAwareOperatorNewOrDelete());
897 Record.push_back(FunctionDeclBits);
898
899 Record.AddSourceLocation(D->getEndLoc());
900 if (D->isExplicitlyDefaulted())
901 Record.AddSourceLocation(D->getDefaultLoc());
902
903 Record.push_back(D->getODRHash());
904
905 if (D->isDefaulted() || D->isDeletedAsWritten()) {
906 if (auto *FDI = D->getDefaultedOrDeletedInfo()) {
907 // Store both that there is an DefaultedOrDeletedInfo and whether it
908 // contains a DeletedMessage.
909 StringLiteral *DeletedMessage = FDI->getDeletedMessage();
910 Record.push_back(1 | (DeletedMessage ? 2 : 0));
911 if (DeletedMessage)
912 Record.AddStmt(DeletedMessage);
913
914 Record.push_back(FDI->getUnqualifiedLookups().size());
915 for (DeclAccessPair P : FDI->getUnqualifiedLookups()) {
916 Record.AddDeclRef(P.getDecl());
917 Record.push_back(P.getAccess());
918 }
919 } else {
920 Record.push_back(0);
921 }
922 }
923
924 if (D->getFriendObjectKind()) {
925 // For a friend function defined inline within a class template, we have to
926 // force the definition to be the one inside the definition of the template
927 // class. Remember this relation to deserialize them together.
928 if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent());
929 RD && isDefinitionInDependentContext(RD)) {
930 Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
931 Writer.GetDeclRef(D));
932 }
933 }
934
935 Record.push_back(D->param_size());
936 for (auto *P : D->parameters())
937 Record.AddDeclRef(P);
939}
940
943 uint64_t Kind = static_cast<uint64_t>(ES.getKind());
944 Kind = Kind << 1 | static_cast<bool>(ES.getExpr());
945 Record.push_back(Kind);
946 if (ES.getExpr()) {
947 Record.AddStmt(ES.getExpr());
948 }
949}
950
953 Record.AddDeclRef(D->Ctor);
955 Record.push_back(static_cast<unsigned char>(D->getDeductionCandidateKind()));
956 Record.AddDeclRef(D->getSourceDeductionGuide());
957 Record.push_back(
958 static_cast<unsigned char>(D->getSourceDeductionGuideKind()));
960}
961
963 static_assert(DeclContext::NumObjCMethodDeclBits == 37,
964 "You need to update the serializer after you change the "
965 "ObjCMethodDeclBits");
966
968 // FIXME: convert to LazyStmtPtr?
969 // Unlike C/C++, method bodies will never be in header files.
970 bool HasBodyStuff = D->getBody() != nullptr;
971 Record.push_back(HasBodyStuff);
972 if (HasBodyStuff) {
973 Record.AddStmt(D->getBody());
974 }
975 Record.AddDeclRef(D->getSelfDecl());
976 Record.AddDeclRef(D->getCmdDecl());
977 Record.push_back(D->isInstanceMethod());
978 Record.push_back(D->isVariadic());
979 Record.push_back(D->isPropertyAccessor());
980 Record.push_back(D->isSynthesizedAccessorStub());
981 Record.push_back(D->isDefined());
982 Record.push_back(D->isOverriding());
983 Record.push_back(D->hasSkippedBody());
984
985 Record.push_back(D->isRedeclaration());
986 Record.push_back(D->hasRedeclaration());
987 if (D->hasRedeclaration()) {
988 assert(Record.getASTContext().getObjCMethodRedeclaration(D));
989 Record.AddDeclRef(Record.getASTContext().getObjCMethodRedeclaration(D));
990 }
991
992 // FIXME: stable encoding for @required/@optional
993 Record.push_back(llvm::to_underlying(D->getImplementationControl()));
994 // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
995 Record.push_back(D->getObjCDeclQualifier());
996 Record.push_back(D->hasRelatedResultType());
997 Record.AddTypeRef(D->getReturnType());
998 Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
999 Record.AddSourceLocation(D->getEndLoc());
1000 Record.push_back(D->param_size());
1001 for (const auto *P : D->parameters())
1002 Record.AddDeclRef(P);
1003
1004 Record.push_back(D->getSelLocsKind());
1005 unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
1006 SourceLocation *SelLocs = D->getStoredSelLocs();
1007 Record.push_back(NumStoredSelLocs);
1008 for (unsigned i = 0; i != NumStoredSelLocs; ++i)
1009 Record.AddSourceLocation(SelLocs[i]);
1010
1012}
1013
1016 Record.push_back(D->Variance);
1017 Record.push_back(D->Index);
1018 Record.AddSourceLocation(D->VarianceLoc);
1019 Record.AddSourceLocation(D->ColonLoc);
1020
1022}
1023
1025 static_assert(DeclContext::NumObjCContainerDeclBits == 64,
1026 "You need to update the serializer after you change the "
1027 "ObjCContainerDeclBits");
1028
1029 VisitNamedDecl(D);
1030 Record.AddSourceLocation(D->getAtStartLoc());
1031 Record.AddSourceRange(D->getAtEndRange());
1032 // Abstract class (no need to define a stable serialization::DECL code).
1033}
1034
1038 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
1039 AddObjCTypeParamList(D->TypeParamList);
1040
1041 Record.push_back(D->isThisDeclarationADefinition());
1043 // Write the DefinitionData
1044 ObjCInterfaceDecl::DefinitionData &Data = D->data();
1045
1046 Record.AddTypeSourceInfo(D->getSuperClassTInfo());
1047 Record.AddSourceLocation(D->getEndOfDefinitionLoc());
1048 Record.push_back(Data.HasDesignatedInitializers);
1049 Record.push_back(D->getODRHash());
1050
1051 // Write out the protocols that are directly referenced by the @interface.
1052 Record.push_back(Data.ReferencedProtocols.size());
1053 for (const auto *P : D->protocols())
1054 Record.AddDeclRef(P);
1055 for (const auto &PL : D->protocol_locs())
1056 Record.AddSourceLocation(PL);
1057
1058 // Write out the protocols that are transitively referenced.
1059 Record.push_back(Data.AllReferencedProtocols.size());
1061 P = Data.AllReferencedProtocols.begin(),
1062 PEnd = Data.AllReferencedProtocols.end();
1063 P != PEnd; ++P)
1064 Record.AddDeclRef(*P);
1065
1066
1067 if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
1068 // Ensure that we write out the set of categories for this class.
1069 Writer.ObjCClassesWithCategories.insert(D);
1070
1071 // Make sure that the categories get serialized.
1072 for (; Cat; Cat = Cat->getNextClassCategoryRaw())
1073 (void)Writer.GetDeclRef(Cat);
1074 }
1075 }
1076
1078}
1079
1081 VisitFieldDecl(D);
1082 // FIXME: stable encoding for @public/@private/@protected/@package
1083 Record.push_back(D->getAccessControl());
1084 Record.push_back(D->getSynthesize());
1085
1086 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1087 !D->hasAttrs() &&
1088 !D->isImplicit() &&
1089 !D->isUsed(false) &&
1090 !D->isInvalidDecl() &&
1091 !D->isReferenced() &&
1092 !D->isModulePrivate() &&
1093 !D->getBitWidth() &&
1094 !D->hasExtInfo() &&
1095 D->getDeclName())
1096 AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
1097
1099}
1100
1104
1105 Record.push_back(D->isThisDeclarationADefinition());
1107 Record.push_back(D->protocol_size());
1108 for (const auto *I : D->protocols())
1109 Record.AddDeclRef(I);
1110 for (const auto &PL : D->protocol_locs())
1111 Record.AddSourceLocation(PL);
1112 Record.push_back(D->getODRHash());
1113 }
1114
1116}
1117
1122
1125 Record.AddSourceLocation(D->getCategoryNameLoc());
1126 Record.AddSourceLocation(D->getIvarLBraceLoc());
1127 Record.AddSourceLocation(D->getIvarRBraceLoc());
1128 Record.AddDeclRef(D->getClassInterface());
1129 AddObjCTypeParamList(D->TypeParamList);
1130 Record.push_back(D->protocol_size());
1131 for (const auto *I : D->protocols())
1132 Record.AddDeclRef(I);
1133 for (const auto &PL : D->protocol_locs())
1134 Record.AddSourceLocation(PL);
1136}
1137
1143
1145 VisitNamedDecl(D);
1146 Record.AddSourceLocation(D->getAtLoc());
1147 Record.AddSourceLocation(D->getLParenLoc());
1148 Record.AddTypeRef(D->getType());
1149 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
1150 // FIXME: stable encoding
1151 Record.push_back((unsigned)D->getPropertyAttributes());
1152 Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
1153 // FIXME: stable encoding
1154 Record.push_back((unsigned)D->getPropertyImplementation());
1155 Record.AddDeclarationName(D->getGetterName());
1156 Record.AddSourceLocation(D->getGetterNameLoc());
1157 Record.AddDeclarationName(D->getSetterName());
1158 Record.AddSourceLocation(D->getSetterNameLoc());
1159 Record.AddDeclRef(D->getGetterMethodDecl());
1160 Record.AddDeclRef(D->getSetterMethodDecl());
1161 Record.AddDeclRef(D->getPropertyIvarDecl());
1163}
1164
1167 Record.AddDeclRef(D->getClassInterface());
1168 // Abstract class (no need to define a stable serialization::DECL code).
1169}
1170
1176
1179 Record.AddDeclRef(D->getSuperClass());
1180 Record.AddSourceLocation(D->getSuperClassLoc());
1181 Record.AddSourceLocation(D->getIvarLBraceLoc());
1182 Record.AddSourceLocation(D->getIvarRBraceLoc());
1183 Record.push_back(D->hasNonZeroConstructors());
1184 Record.push_back(D->hasDestructors());
1185 Record.push_back(D->NumIvarInitializers);
1186 if (D->NumIvarInitializers)
1187 Record.AddCXXCtorInitializers(
1188 llvm::ArrayRef(D->init_begin(), D->init_end()));
1190}
1191
1193 VisitDecl(D);
1194 Record.AddSourceLocation(D->getBeginLoc());
1195 Record.AddDeclRef(D->getPropertyDecl());
1196 Record.AddDeclRef(D->getPropertyIvarDecl());
1197 Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
1198 Record.AddDeclRef(D->getGetterMethodDecl());
1199 Record.AddDeclRef(D->getSetterMethodDecl());
1200 Record.AddStmt(D->getGetterCXXConstructor());
1201 Record.AddStmt(D->getSetterCXXAssignment());
1203}
1204
1207 Record.push_back(D->isMutable());
1208
1209 Record.push_back((D->StorageKind << 1) | D->BitField);
1210 if (D->StorageKind == FieldDecl::ISK_CapturedVLAType)
1211 Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
1212 else if (D->BitField)
1213 Record.AddStmt(D->getBitWidth());
1214
1215 if (!D->getDeclName() || D->isPlaceholderVar(Writer.getLangOpts()))
1216 Record.AddDeclRef(
1217 Record.getASTContext().getInstantiatedFromUnnamedFieldDecl(D));
1218
1219 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1220 !D->hasAttrs() &&
1221 !D->isImplicit() &&
1222 !D->isUsed(false) &&
1223 !D->isInvalidDecl() &&
1224 !D->isReferenced() &&
1226 !D->isModulePrivate() &&
1227 !D->getBitWidth() &&
1228 !D->hasInClassInitializer() &&
1229 !D->hasCapturedVLAType() &&
1230 !D->hasExtInfo() &&
1233 D->getDeclName())
1234 AbbrevToUse = Writer.getDeclFieldAbbrev();
1235
1237}
1238
1241 Record.AddIdentifierRef(D->getGetterId());
1242 Record.AddIdentifierRef(D->getSetterId());
1244}
1245
1247 VisitValueDecl(D);
1248 MSGuidDecl::Parts Parts = D->getParts();
1249 Record.push_back(Parts.Part1);
1250 Record.push_back(Parts.Part2);
1251 Record.push_back(Parts.Part3);
1252 Record.append(std::begin(Parts.Part4And5), std::end(Parts.Part4And5));
1254}
1255
1262
1268
1270 VisitValueDecl(D);
1271 Record.push_back(D->getChainingSize());
1272
1273 for (const auto *P : D->chain())
1274 Record.AddDeclRef(P);
1276}
1277
1281
1282 // The order matters here. It will be better to put the bit with higher
1283 // probability to be 0 in the end of the bits. See the comments in VisitDecl
1284 // for details.
1285 BitsPacker VarDeclBits;
1286 VarDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()),
1287 /*BitWidth=*/3);
1288
1289 bool ModulesCodegen = shouldVarGenerateHereOnly(D);
1290 VarDeclBits.addBit(ModulesCodegen);
1291
1292 VarDeclBits.addBits(D->getStorageClass(), /*BitWidth=*/3);
1293 VarDeclBits.addBits(D->getTSCSpec(), /*BitWidth=*/2);
1294 VarDeclBits.addBits(D->getInitStyle(), /*BitWidth=*/2);
1295 VarDeclBits.addBit(D->isARCPseudoStrong());
1296
1297 bool HasDeducedType = false;
1298 if (!isa<ParmVarDecl>(D)) {
1300 VarDeclBits.addBit(D->isExceptionVariable());
1301 VarDeclBits.addBit(D->isNRVOVariable());
1302 VarDeclBits.addBit(D->isCXXForRangeDecl());
1303
1304 VarDeclBits.addBit(D->isInline());
1305 VarDeclBits.addBit(D->isInlineSpecified());
1306 VarDeclBits.addBit(D->isConstexpr());
1307 VarDeclBits.addBit(D->isInitCapture());
1308 VarDeclBits.addBit(D->isPreviousDeclInSameBlockScope());
1309
1310 VarDeclBits.addBit(D->isEscapingByref());
1311 HasDeducedType = D->getType()->getContainedDeducedType();
1312 VarDeclBits.addBit(HasDeducedType);
1313
1314 if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
1315 VarDeclBits.addBits(llvm::to_underlying(IPD->getParameterKind()),
1316 /*Width=*/3);
1317 else
1318 VarDeclBits.addBits(0, /*Width=*/3);
1319
1320 VarDeclBits.addBit(D->isObjCForDecl());
1321 VarDeclBits.addBit(D->isCXXForRangeImplicitVar());
1322 }
1323
1324 Record.push_back(VarDeclBits);
1325
1326 if (ModulesCodegen)
1327 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1328
1329 if (D->hasAttr<BlocksAttr>()) {
1330 BlockVarCopyInit Init = Record.getASTContext().getBlockVarCopyInit(D);
1331 Record.AddStmt(Init.getCopyExpr());
1332 if (Init.getCopyExpr())
1333 Record.push_back(Init.canThrow());
1334 }
1335
1336 enum {
1337 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1338 };
1339 if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
1340 Record.push_back(VarTemplate);
1341 Record.AddDeclRef(TemplD);
1342 } else if (MemberSpecializationInfo *SpecInfo
1344 Record.push_back(StaticDataMemberSpecialization);
1345 Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
1346 Record.push_back(SpecInfo->getTemplateSpecializationKind());
1347 Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
1348 } else {
1349 Record.push_back(VarNotTemplate);
1350 }
1351
1352 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1356 !D->hasExtInfo() && D->getFirstDecl() == D->getMostRecentDecl() &&
1357 D->getKind() == Decl::Var && !D->isInline() && !D->isConstexpr() &&
1359 !D->hasInitWithSideEffects() && !D->isEscapingByref() &&
1360 !HasDeducedType && D->getStorageDuration() != SD_Static &&
1363 !D->isEscapingByref())
1364 AbbrevToUse = Writer.getDeclVarAbbrev();
1365
1367}
1368
1373
1375 VisitVarDecl(D);
1376
1377 // See the implementation of `ParmVarDecl::getParameterIndex()`, which may
1378 // exceed the size of the normal bitfield. So it may be better to not pack
1379 // these bits.
1380 Record.push_back(D->getFunctionScopeIndex());
1381
1382 BitsPacker ParmVarDeclBits;
1383 ParmVarDeclBits.addBit(D->isObjCMethodParameter());
1384 ParmVarDeclBits.addBits(D->getFunctionScopeDepth(), /*BitsWidth=*/7);
1385 // FIXME: stable encoding
1386 ParmVarDeclBits.addBits(D->getObjCDeclQualifier(), /*BitsWidth=*/7);
1387 ParmVarDeclBits.addBit(D->isKNRPromoted());
1388 ParmVarDeclBits.addBit(D->hasInheritedDefaultArg());
1389 ParmVarDeclBits.addBit(D->hasUninstantiatedDefaultArg());
1390 ParmVarDeclBits.addBit(D->getExplicitObjectParamThisLoc().isValid());
1391 Record.push_back(ParmVarDeclBits);
1392
1394 Record.AddStmt(D->getUninstantiatedDefaultArg());
1396 Record.AddSourceLocation(D->getExplicitObjectParamThisLoc());
1398
1399 // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1400 // we dynamically check for the properties that we optimize for, but don't
1401 // know are true of all PARM_VAR_DECLs.
1402 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1403 !D->hasExtInfo() && D->getStorageClass() == 0 && !D->isInvalidDecl() &&
1405 D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1406 D->getInit() == nullptr) // No default expr.
1407 AbbrevToUse = Writer.getDeclParmVarAbbrev();
1408
1409 // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1410 // just us assuming it.
1411 assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1413 && "PARM_VAR_DECL can't be demoted definition.");
1414 assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1415 assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1416 assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1417 assert(!D->isStaticDataMember() &&
1418 "PARM_VAR_DECL can't be static data member");
1419}
1420
1422 // Record the number of bindings first to simplify deserialization.
1423 Record.push_back(D->bindings().size());
1424
1425 VisitVarDecl(D);
1426 for (auto *B : D->bindings())
1427 Record.AddDeclRef(B);
1429}
1430
1432 VisitValueDecl(D);
1433 Record.AddStmt(D->getBinding());
1435}
1436
1438 VisitDecl(D);
1439 Record.AddStmt(D->getAsmStringExpr());
1440 Record.AddSourceLocation(D->getRParenLoc());
1442}
1443
1449
1454
1457 VisitDecl(D);
1458 Record.AddDeclRef(D->getExtendingDecl());
1459 Record.AddStmt(D->getTemporaryExpr());
1460 Record.push_back(static_cast<bool>(D->getValue()));
1461 if (D->getValue())
1462 Record.AddAPValue(*D->getValue());
1463 Record.push_back(D->getManglingNumber());
1465}
1467 VisitDecl(D);
1468 Record.AddStmt(D->getBody());
1469 Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1470 Record.push_back(D->param_size());
1471 for (ParmVarDecl *P : D->parameters())
1472 Record.AddDeclRef(P);
1473 Record.push_back(D->isVariadic());
1474 Record.push_back(D->blockMissingReturnType());
1475 Record.push_back(D->isConversionFromLambda());
1476 Record.push_back(D->doesNotEscape());
1477 Record.push_back(D->canAvoidCopyToHeap());
1478 Record.push_back(D->capturesCXXThis());
1479 Record.push_back(D->getNumCaptures());
1480 for (const auto &capture : D->captures()) {
1481 Record.AddDeclRef(capture.getVariable());
1482
1483 unsigned flags = 0;
1484 if (capture.isByRef()) flags |= 1;
1485 if (capture.isNested()) flags |= 2;
1486 if (capture.hasCopyExpr()) flags |= 4;
1487 Record.push_back(flags);
1488
1489 if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1490 }
1491
1493}
1494
1496 Record.push_back(D->getNumParams());
1497 VisitDecl(D);
1498 for (unsigned I = 0; I < D->getNumParams(); ++I)
1499 Record.AddDeclRef(D->getParam(I));
1500 Record.push_back(D->isNothrow() ? 1 : 0);
1501 Record.AddStmt(D->getBody());
1503}
1504
1506 Record.push_back(CD->getNumParams());
1507 VisitDecl(CD);
1508 Record.push_back(CD->getContextParamPosition());
1509 Record.push_back(CD->isNothrow() ? 1 : 0);
1510 // Body is stored by VisitCapturedStmt.
1511 for (unsigned I = 0; I < CD->getNumParams(); ++I)
1512 Record.AddDeclRef(CD->getParam(I));
1514}
1515
1517 static_assert(DeclContext::NumLinkageSpecDeclBits == 17,
1518 "You need to update the serializer after you change the"
1519 "LinkageSpecDeclBits");
1520
1521 VisitDecl(D);
1522 Record.push_back(llvm::to_underlying(D->getLanguage()));
1523 Record.AddSourceLocation(D->getExternLoc());
1524 Record.AddSourceLocation(D->getRBraceLoc());
1526}
1527
1529 VisitDecl(D);
1530 Record.AddSourceLocation(D->getRBraceLoc());
1532}
1533
1535 VisitNamedDecl(D);
1536 Record.AddSourceLocation(D->getBeginLoc());
1538}
1539
1540
1543 VisitNamedDecl(D);
1544
1545 BitsPacker NamespaceDeclBits;
1546 NamespaceDeclBits.addBit(D->isInline());
1547 NamespaceDeclBits.addBit(D->isNested());
1548 Record.push_back(NamespaceDeclBits);
1549
1550 Record.AddSourceLocation(D->getBeginLoc());
1551 Record.AddSourceLocation(D->getRBraceLoc());
1552
1553 if (D->isFirstDecl())
1554 Record.AddDeclRef(D->getAnonymousNamespace());
1556
1557 if (Writer.hasChain() && D->isAnonymousNamespace() &&
1558 D == D->getMostRecentDecl()) {
1559 // This is a most recent reopening of the anonymous namespace. If its parent
1560 // is in a previous PCH (or is the TU), mark that parent for update, because
1561 // the original namespace always points to the latest re-opening of its
1562 // anonymous namespace.
1563 Decl *Parent = cast<Decl>(
1565 if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1566 Writer.DeclUpdates[Parent].push_back(
1567 ASTWriter::DeclUpdate(DeclUpdateKind::CXXAddedAnonymousNamespace, D));
1568 }
1569 }
1570}
1571
1574 VisitNamedDecl(D);
1575 Record.AddSourceLocation(D->getNamespaceLoc());
1576 Record.AddSourceLocation(D->getTargetNameLoc());
1577 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1578 Record.AddDeclRef(D->getNamespace());
1580}
1581
1583 VisitNamedDecl(D);
1584 Record.AddSourceLocation(D->getUsingLoc());
1585 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1586 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1587 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1588 Record.push_back(D->hasTypename());
1589 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingDecl(D));
1591}
1592
1594 VisitNamedDecl(D);
1595 Record.AddSourceLocation(D->getUsingLoc());
1596 Record.AddSourceLocation(D->getEnumLoc());
1597 Record.AddTypeSourceInfo(D->getEnumType());
1598 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1599 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingEnumDecl(D));
1601}
1602
1604 Record.push_back(D->NumExpansions);
1605 VisitNamedDecl(D);
1606 Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1607 for (auto *E : D->expansions())
1608 Record.AddDeclRef(E);
1610}
1611
1614 VisitNamedDecl(D);
1615 Record.AddDeclRef(D->getTargetDecl());
1616 Record.push_back(D->getIdentifierNamespace());
1617 Record.AddDeclRef(D->UsingOrNextShadow);
1618 Record.AddDeclRef(
1619 Record.getASTContext().getInstantiatedFromUsingShadowDecl(D));
1620
1621 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1622 D->getFirstDecl() == D->getMostRecentDecl() && !D->hasAttrs() &&
1625 AbbrevToUse = Writer.getDeclUsingShadowAbbrev();
1626
1628}
1629
1633 Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1634 Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1635 Record.push_back(D->IsVirtual);
1637}
1638
1640 VisitNamedDecl(D);
1641 Record.AddSourceLocation(D->getUsingLoc());
1642 Record.AddSourceLocation(D->getNamespaceKeyLocation());
1643 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1644 Record.AddDeclRef(D->getNominatedNamespace());
1645 Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1647}
1648
1650 VisitValueDecl(D);
1651 Record.AddSourceLocation(D->getUsingLoc());
1652 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1653 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1654 Record.AddSourceLocation(D->getEllipsisLoc());
1656}
1657
1660 VisitTypeDecl(D);
1661 Record.AddSourceLocation(D->getTypenameLoc());
1662 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1663 Record.AddSourceLocation(D->getEllipsisLoc());
1665}
1666
1672
1674 VisitRecordDecl(D);
1675
1676 enum {
1677 CXXRecNotTemplate = 0,
1678 CXXRecTemplate,
1679 CXXRecMemberSpecialization,
1680 CXXLambda
1681 };
1682 if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1683 Record.push_back(CXXRecTemplate);
1684 Record.AddDeclRef(TemplD);
1685 } else if (MemberSpecializationInfo *MSInfo
1687 Record.push_back(CXXRecMemberSpecialization);
1688 Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1689 Record.push_back(MSInfo->getTemplateSpecializationKind());
1690 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1691 } else if (D->isLambda()) {
1692 // For a lambda, we need some information early for merging.
1693 Record.push_back(CXXLambda);
1694 if (auto *Context = D->getLambdaContextDecl()) {
1695 Record.AddDeclRef(Context);
1696 Record.push_back(D->getLambdaIndexInContext());
1697 } else {
1698 Record.push_back(0);
1699 }
1700 // For lambdas inside template functions, remember the mapping to
1701 // deserialize them together.
1702 if (auto *FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
1703 FD && isDefinitionInDependentContext(FD)) {
1704 Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
1705 Writer.GetDeclRef(D->getLambdaCallOperator()));
1706 }
1707 } else {
1708 Record.push_back(CXXRecNotTemplate);
1709 }
1710
1711 Record.push_back(D->isThisDeclarationADefinition());
1713 Record.AddCXXDefinitionData(D);
1714
1715 if (D->isCompleteDefinition() && D->isInNamedModule())
1716 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1717
1718 // Store (what we currently believe to be) the key function to avoid
1719 // deserializing every method so we can compute it.
1720 //
1721 // FIXME: Avoid adding the key function if the class is defined in
1722 // module purview since in that case the key function is meaningless.
1723 if (D->isCompleteDefinition())
1724 Record.AddDeclRef(Record.getASTContext().getCurrentKeyFunction(D));
1725
1727}
1728
1731 if (D->isCanonicalDecl()) {
1732 Record.push_back(D->size_overridden_methods());
1733 for (const CXXMethodDecl *MD : D->overridden_methods())
1734 Record.AddDeclRef(MD);
1735 } else {
1736 // We only need to record overridden methods once for the canonical decl.
1737 Record.push_back(0);
1738 }
1739
1740 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1741 D->getFirstDecl() == D->getMostRecentDecl() && !D->isInvalidDecl() &&
1742 !D->hasAttrs() && !D->isTopLevelDeclInObjCContainer() &&
1744 !D->hasExtInfo() && !D->isExplicitlyDefaulted()) {
1749 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1750 else if (D->getTemplatedKind() ==
1754
1755 if (FTSInfo->TemplateArguments->size() == 1) {
1756 const TemplateArgument &TA = FTSInfo->TemplateArguments->get(0);
1757 if (TA.getKind() == TemplateArgument::Type &&
1758 !FTSInfo->TemplateArgumentsAsWritten &&
1759 !FTSInfo->getMemberSpecializationInfo())
1760 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1761 }
1762 } else if (D->getTemplatedKind() ==
1766 if (!DFTSInfo->TemplateArgumentsAsWritten)
1767 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1768 }
1769 }
1770
1772}
1773
1775 static_assert(DeclContext::NumCXXConstructorDeclBits == 64,
1776 "You need to update the serializer after you change the "
1777 "CXXConstructorDeclBits");
1778
1779 Record.push_back(D->getTrailingAllocKind());
1780 addExplicitSpecifier(D->getExplicitSpecifierInternal(), Record);
1781 if (auto Inherited = D->getInheritedConstructor()) {
1782 Record.AddDeclRef(Inherited.getShadowDecl());
1783 Record.AddDeclRef(Inherited.getConstructor());
1784 }
1785
1788}
1789
1792
1793 Record.AddDeclRef(D->getOperatorDelete());
1794 if (D->getOperatorDelete())
1795 Record.AddStmt(D->getOperatorDeleteThisArg());
1796 Record.AddDeclRef(D->getOperatorGlobalDelete());
1797 Record.AddDeclRef(D->getArrayOperatorDelete());
1798 Record.AddDeclRef(D->getGlobalArrayOperatorDelete());
1799
1801}
1802
1808
1810 VisitDecl(D);
1811 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1812 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1813 Record.push_back(!IdentifierLocs.empty());
1814 if (IdentifierLocs.empty()) {
1815 Record.AddSourceLocation(D->getEndLoc());
1816 Record.push_back(1);
1817 } else {
1818 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1819 Record.AddSourceLocation(IdentifierLocs[I]);
1820 Record.push_back(IdentifierLocs.size());
1821 }
1822 // Note: the number of source locations must always be the last element in
1823 // the record.
1825}
1826
1828 VisitDecl(D);
1829 Record.AddSourceLocation(D->getColonLoc());
1831}
1832
1834 // Record the number of friend type template parameter lists here
1835 // so as to simplify memory allocation during deserialization.
1836 Record.push_back(D->NumTPLists);
1837 VisitDecl(D);
1838 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1839 Record.push_back(hasFriendDecl);
1840 if (hasFriendDecl)
1841 Record.AddDeclRef(D->getFriendDecl());
1842 else
1843 Record.AddTypeSourceInfo(D->getFriendType());
1844 for (unsigned i = 0; i < D->NumTPLists; ++i)
1845 Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1846 Record.AddDeclRef(D->getNextFriend());
1847 Record.push_back(D->UnsupportedFriend);
1848 Record.AddSourceLocation(D->FriendLoc);
1849 Record.AddSourceLocation(D->EllipsisLoc);
1851}
1852
1854 VisitDecl(D);
1855 Record.push_back(D->getNumTemplateParameters());
1856 for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1857 Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1858 Record.push_back(D->getFriendDecl() != nullptr);
1859 if (D->getFriendDecl())
1860 Record.AddDeclRef(D->getFriendDecl());
1861 else
1862 Record.AddTypeSourceInfo(D->getFriendType());
1863 Record.AddSourceLocation(D->getFriendLoc());
1865}
1866
1868 VisitNamedDecl(D);
1869
1870 Record.AddTemplateParameterList(D->getTemplateParameters());
1871 Record.AddDeclRef(D->getTemplatedDecl());
1872}
1873
1879
1882 Record.push_back(D->getTemplateArguments().size());
1883 VisitDecl(D);
1884 for (const TemplateArgument &Arg : D->getTemplateArguments())
1885 Record.AddTemplateArgument(Arg);
1887}
1888
1892
1895
1896 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1897 // getCommonPtr() can be used while this is still initializing.
1898 if (D->isFirstDecl()) {
1899 // This declaration owns the 'common' pointer, so serialize that data now.
1900 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1902 Record.push_back(D->isMemberSpecialization());
1903 }
1904
1906 Record.push_back(D->getIdentifierNamespace());
1907}
1908
1911
1912 if (D->isFirstDecl())
1914
1915 // Force emitting the corresponding deduction guide in reduced BMI mode.
1916 // Otherwise, the deduction guide may be optimized out incorrectly.
1917 if (Writer.isGeneratingReducedBMI()) {
1918 auto Name =
1919 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1920 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1921 Writer.GetDeclRef(DG->getCanonicalDecl());
1922 }
1923
1925}
1926
1930
1932
1933 llvm::PointerUnion<ClassTemplateDecl *,
1936 if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1937 Record.AddDeclRef(InstFromD);
1938 } else {
1939 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1940 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1941 }
1942
1943 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1944 Record.AddSourceLocation(D->getPointOfInstantiation());
1945 Record.push_back(D->getSpecializationKind());
1946 Record.push_back(D->hasStrictPackMatch());
1947 Record.push_back(D->isCanonicalDecl());
1948
1949 if (D->isCanonicalDecl()) {
1950 // When reading, we'll add it to the folding set of the following template.
1951 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1952 }
1953
1958 Record.push_back(ExplicitInstantiation);
1960 Record.AddSourceLocation(D->getExternKeywordLoc());
1961 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1962 }
1963
1964 const ASTTemplateArgumentListInfo *ArgsWritten =
1966 Record.push_back(!!ArgsWritten);
1967 if (ArgsWritten)
1968 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1969
1970 // Mention the implicitly generated C++ deduction guide to make sure the
1971 // deduction guide will be rewritten as expected.
1972 //
1973 // FIXME: Would it be more efficient to add a callback register function
1974 // in sema to register the deduction guide?
1975 if (Writer.isWritingStdCXXNamedModules()) {
1976 auto Name =
1977 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
1979 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1980 Writer.GetDeclRef(DG->getCanonicalDecl());
1981 }
1982
1984}
1985
1988 Record.AddTemplateParameterList(D->getTemplateParameters());
1989
1991
1992 // These are read/set from/to the first declaration.
1993 if (D->getPreviousDecl() == nullptr) {
1994 Record.AddDeclRef(D->getInstantiatedFromMember());
1995 Record.push_back(D->isMemberSpecialization());
1996 }
1997
1999}
2000
2008
2012
2013 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2014 InstFrom = D->getSpecializedTemplateOrPartial();
2015 if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
2016 Record.AddDeclRef(InstFromD);
2017 } else {
2018 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
2019 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
2020 }
2021
2026 Record.push_back(ExplicitInstantiation);
2028 Record.AddSourceLocation(D->getExternKeywordLoc());
2029 Record.AddSourceLocation(D->getTemplateKeywordLoc());
2030 }
2031
2032 const ASTTemplateArgumentListInfo *ArgsWritten =
2034 Record.push_back(!!ArgsWritten);
2035 if (ArgsWritten)
2036 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
2037
2038 Record.AddTemplateArgumentList(&D->getTemplateArgs());
2039 Record.AddSourceLocation(D->getPointOfInstantiation());
2040 Record.push_back(D->getSpecializationKind());
2041 Record.push_back(D->IsCompleteDefinition);
2042
2043 VisitVarDecl(D);
2044
2045 Record.push_back(D->isCanonicalDecl());
2046
2047 if (D->isCanonicalDecl()) {
2048 // When reading, we'll add it to the folding set of the following template.
2049 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
2050 }
2051
2053}
2054
2057 Record.AddTemplateParameterList(D->getTemplateParameters());
2058
2060
2061 // These are read/set from/to the first declaration.
2062 if (D->getPreviousDecl() == nullptr) {
2063 Record.AddDeclRef(D->getInstantiatedFromMember());
2064 Record.push_back(D->isMemberSpecialization());
2065 }
2066
2068}
2069
2077
2079 Record.push_back(D->hasTypeConstraint());
2080 VisitTypeDecl(D);
2081
2082 Record.push_back(D->wasDeclaredWithTypename());
2083
2084 const TypeConstraint *TC = D->getTypeConstraint();
2085 if (D->hasTypeConstraint())
2086 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
2087 if (TC) {
2088 auto *CR = TC->getConceptReference();
2089 Record.push_back(CR != nullptr);
2090 if (CR)
2091 Record.AddConceptReference(CR);
2092 Record.AddStmt(TC->getImmediatelyDeclaredConstraint());
2093 Record.writeUnsignedOrNone(TC->getArgPackSubstIndex());
2094 Record.writeUnsignedOrNone(D->getNumExpansionParameters());
2095 }
2096
2097 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2099 Record.push_back(OwnsDefaultArg);
2100 if (OwnsDefaultArg)
2101 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2102
2103 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
2105 !D->isInvalidDecl() && !D->hasAttrs() &&
2108 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
2109
2111}
2112
2114 // For an expanded parameter pack, record the number of expansion types here
2115 // so that it's easier for deserialization to allocate the right amount of
2116 // memory.
2117 Record.push_back(D->hasPlaceholderTypeConstraint());
2118 if (D->isExpandedParameterPack())
2119 Record.push_back(D->getNumExpansionTypes());
2120
2122 // TemplateParmPosition.
2123 Record.push_back(D->getDepth());
2124 Record.push_back(D->getPosition());
2125
2127 Record.AddStmt(D->getPlaceholderTypeConstraint());
2128
2129 if (D->isExpandedParameterPack()) {
2130 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2131 Record.AddTypeRef(D->getExpansionType(I));
2132 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2133 }
2134
2136 } else {
2137 // Rest of NonTypeTemplateParmDecl.
2138 Record.push_back(D->isParameterPack());
2139 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2141 Record.push_back(OwnsDefaultArg);
2142 if (OwnsDefaultArg)
2143 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2145 }
2146}
2147
2149 // For an expanded parameter pack, record the number of expansion types here
2150 // so that it's easier for deserialization to allocate the right amount of
2151 // memory.
2152 if (D->isExpandedParameterPack())
2153 Record.push_back(D->getNumExpansionTemplateParameters());
2154
2156 Record.push_back(D->templateParameterKind());
2157 Record.push_back(D->wasDeclaredWithTypename());
2158 // TemplateParmPosition.
2159 Record.push_back(D->getDepth());
2160 Record.push_back(D->getPosition());
2161
2162 if (D->isExpandedParameterPack()) {
2163 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2164 I != N; ++I)
2165 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2167 } else {
2168 // Rest of TemplateTemplateParmDecl.
2169 Record.push_back(D->isParameterPack());
2170 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2172 Record.push_back(OwnsDefaultArg);
2173 if (OwnsDefaultArg)
2174 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2176 }
2177}
2178
2183
2185 VisitDecl(D);
2186 Record.AddStmt(D->getAssertExpr());
2187 Record.push_back(D->isFailed());
2188 Record.AddStmt(D->getMessage());
2189 Record.AddSourceLocation(D->getRParenLoc());
2191}
2192
2193/// Emit the DeclContext part of a declaration context decl.
2195 static_assert(DeclContext::NumDeclContextBits == 13,
2196 "You need to update the serializer after you change the "
2197 "DeclContextBits");
2198 LookupBlockOffsets Offsets;
2199
2200 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2201 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2202 // In reduced BMI, delay writing lexical and visible block for namespace
2203 // in the global module fragment. See the comments of DelayedNamespace for
2204 // details.
2205 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2206 } else {
2207 Offsets.LexicalOffset =
2208 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2209 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC, Offsets);
2210 }
2211
2212 Record.AddLookupOffsets(Offsets);
2213}
2214
2216 assert(IsLocalDecl(D) && "expected a local declaration");
2217
2218 const Decl *Canon = D->getCanonicalDecl();
2219 if (IsLocalDecl(Canon))
2220 return Canon;
2221
2222 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2223 if (CacheEntry)
2224 return CacheEntry;
2225
2226 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2227 if (IsLocalDecl(Redecl))
2228 D = Redecl;
2229 return CacheEntry = D;
2230}
2231
2232template <typename T>
2234 T *First = D->getFirstDecl();
2235 T *MostRecent = First->getMostRecentDecl();
2236 T *DAsT = static_cast<T *>(D);
2237 if (MostRecent != First) {
2238 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2239 "Not considered redeclarable?");
2240
2241 Record.AddDeclRef(First);
2242
2243 // Write out a list of local redeclarations of this declaration if it's the
2244 // first local declaration in the chain.
2245 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2246 if (DAsT == FirstLocal) {
2247 // Emit a list of all imported first declarations so that we can be sure
2248 // that all redeclarations visible to this module are before D in the
2249 // redecl chain.
2250 unsigned I = Record.size();
2251 Record.push_back(0);
2252 if (Writer.Chain)
2253 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2254 // This is the number of imported first declarations + 1.
2255 Record[I] = Record.size() - I;
2256
2257 // Collect the set of local redeclarations of this declaration, from
2258 // newest to oldest.
2259 ASTWriter::RecordData LocalRedecls;
2260 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2261 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2262 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2263 if (!Prev->isFromASTFile())
2264 LocalRedeclWriter.AddDeclRef(Prev);
2265
2266 // If we have any redecls, write them now as a separate record preceding
2267 // the declaration itself.
2268 if (LocalRedecls.empty())
2269 Record.push_back(0);
2270 else
2271 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2272 } else {
2273 Record.push_back(0);
2274 Record.AddDeclRef(FirstLocal);
2275 }
2276
2277 // Make sure that we serialize both the previous and the most-recent
2278 // declarations, which (transitively) ensures that all declarations in the
2279 // chain get serialized.
2280 //
2281 // FIXME: This is not correct; when we reach an imported declaration we
2282 // won't emit its previous declaration.
2283 (void)Writer.GetDeclRef(D->getPreviousDecl());
2284 (void)Writer.GetDeclRef(MostRecent);
2285 } else {
2286 // We use the sentinel value 0 to indicate an only declaration.
2287 Record.push_back(0);
2288 }
2289}
2290
2292 VisitNamedDecl(D);
2294 Record.push_back(D->isCBuffer());
2295 Record.AddSourceLocation(D->getLocStart());
2296 Record.AddSourceLocation(D->getLBraceLoc());
2297 Record.AddSourceLocation(D->getRBraceLoc());
2298
2300}
2301
2303 Record.writeOMPChildren(D->Data);
2304 VisitDecl(D);
2306}
2307
2309 Record.writeOMPChildren(D->Data);
2310 VisitDecl(D);
2312}
2313
2315 Record.writeOMPChildren(D->Data);
2316 VisitDecl(D);
2318}
2319
2322 "You need to update the serializer after you change the "
2323 "NumOMPDeclareReductionDeclBits");
2324
2325 VisitValueDecl(D);
2326 Record.AddSourceLocation(D->getBeginLoc());
2327 Record.AddStmt(D->getCombinerIn());
2328 Record.AddStmt(D->getCombinerOut());
2329 Record.AddStmt(D->getCombiner());
2330 Record.AddStmt(D->getInitOrig());
2331 Record.AddStmt(D->getInitPriv());
2332 Record.AddStmt(D->getInitializer());
2333 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2334 Record.AddDeclRef(D->getPrevDeclInScope());
2336}
2337
2339 Record.writeOMPChildren(D->Data);
2340 VisitValueDecl(D);
2341 Record.AddDeclarationName(D->getVarName());
2342 Record.AddDeclRef(D->getPrevDeclInScope());
2344}
2345
2350
2352 Record.writeUInt32(D->clauses().size());
2353 VisitDecl(D);
2354 Record.writeEnum(D->DirKind);
2355 Record.AddSourceLocation(D->DirectiveLoc);
2356 Record.AddSourceLocation(D->EndLoc);
2357 Record.writeOpenACCClauseList(D->clauses());
2359}
2361 Record.writeUInt32(D->clauses().size());
2362 VisitDecl(D);
2363 Record.writeEnum(D->DirKind);
2364 Record.AddSourceLocation(D->DirectiveLoc);
2365 Record.AddSourceLocation(D->EndLoc);
2366 Record.AddSourceRange(D->ParensLoc);
2367 Record.AddStmt(D->FuncRef);
2368 Record.writeOpenACCClauseList(D->clauses());
2370}
2371
2372//===----------------------------------------------------------------------===//
2373// ASTWriter Implementation
2374//===----------------------------------------------------------------------===//
2375
2376namespace {
2377template <FunctionDecl::TemplatedKind Kind>
2378std::shared_ptr<llvm::BitCodeAbbrev>
2379getFunctionDeclAbbrev(serialization::DeclCode Code) {
2380 using namespace llvm;
2381
2382 auto Abv = std::make_shared<BitCodeAbbrev>();
2383 Abv->Add(BitCodeAbbrevOp(Code));
2384 // RedeclarableDecl
2385 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2386 Abv->Add(BitCodeAbbrevOp(Kind));
2387 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2388
2389 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2390 // DescribedFunctionTemplate
2391 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2392 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2393 // Instantiated From Decl
2394 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2395 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2396 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2397 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2398 3)); // TemplateSpecializationKind
2399 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2400 } else if constexpr (Kind ==
2402 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2403 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2404 3)); // TemplateSpecializationKind
2405 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2406 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2407 Abv->Add(
2408 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2409 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2410 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2411 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2412 Abv->Add(BitCodeAbbrevOp(0));
2413 Abv->Add(
2414 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2415 } else if constexpr (Kind == FunctionDecl::
2416 TK_DependentFunctionTemplateSpecialization) {
2417 // Candidates of specialization
2418 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2419 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2420 } else {
2421 llvm_unreachable("Unknown templated kind?");
2422 }
2423 // Decl
2424 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2425 8)); // Packed DeclBits: ModuleOwnershipKind,
2426 // isUsed, isReferenced, AccessSpecifier,
2427 // isImplicit
2428 //
2429 // The following bits should be 0:
2430 // HasStandaloneLexicalDC, HasAttrs,
2431 // TopLevelDeclInObjCContainer,
2432 // isInvalidDecl
2433 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2434 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2435 // NamedDecl
2436 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2437 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2438 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2439 // ValueDecl
2440 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2441 // DeclaratorDecl
2442 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2443 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2444 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2445 // FunctionDecl
2446 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2447 Abv->Add(BitCodeAbbrevOp(
2448 BitCodeAbbrevOp::Fixed,
2449 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2450 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2451 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2452 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2453 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2454 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2455 // ShouldSkipCheckingODR
2456 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2457 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2458 // This Array slurps the rest of the record. Fortunately we want to encode
2459 // (nearly) all the remaining (variable number of) fields in the same way.
2460 //
2461 // This is:
2462 // NumParams and Params[] from FunctionDecl, and
2463 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2464 //
2465 // Add an AbbrevOp for 'size then elements' and use it here.
2466 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2467 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2468 return Abv;
2469}
2470
2471template <FunctionDecl::TemplatedKind Kind>
2472std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2473 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2474}
2475} // namespace
2476
2477void ASTWriter::WriteDeclAbbrevs() {
2478 using namespace llvm;
2479
2480 std::shared_ptr<BitCodeAbbrev> Abv;
2481
2482 // Abbreviation for DECL_FIELD
2483 Abv = std::make_shared<BitCodeAbbrev>();
2484 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2485 // Decl
2486 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2487 7)); // Packed DeclBits: ModuleOwnershipKind,
2488 // isUsed, isReferenced, AccessSpecifier,
2489 //
2490 // The following bits should be 0:
2491 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2492 // TopLevelDeclInObjCContainer,
2493 // isInvalidDecl
2494 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2495 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2496 // NamedDecl
2497 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2498 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2499 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2500 // ValueDecl
2501 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2502 // DeclaratorDecl
2503 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2504 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2505 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2506 // FieldDecl
2507 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2508 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2509 // Type Source Info
2510 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2511 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2512 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2513
2514 // Abbreviation for DECL_OBJC_IVAR
2515 Abv = std::make_shared<BitCodeAbbrev>();
2516 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2517 // Decl
2518 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2519 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2520 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2521 // isReferenced, TopLevelDeclInObjCContainer,
2522 // AccessSpecifier, ModuleOwnershipKind
2523 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2524 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2525 // NamedDecl
2526 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2527 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2528 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2529 // ValueDecl
2530 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2531 // DeclaratorDecl
2532 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2533 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2534 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2535 // FieldDecl
2536 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2537 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2538 // ObjC Ivar
2539 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2540 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2541 // Type Source Info
2542 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2543 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2544 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2545
2546 // Abbreviation for DECL_ENUM
2547 Abv = std::make_shared<BitCodeAbbrev>();
2548 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2549 // Redeclarable
2550 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2551 // Decl
2552 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2553 7)); // Packed DeclBits: ModuleOwnershipKind,
2554 // isUsed, isReferenced, AccessSpecifier,
2555 //
2556 // The following bits should be 0:
2557 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2558 // TopLevelDeclInObjCContainer,
2559 // isInvalidDecl
2560 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2561 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2562 // NamedDecl
2563 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2564 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2565 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2566 // TypeDecl
2567 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2568 // TagDecl
2569 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2570 Abv->Add(BitCodeAbbrevOp(
2571 BitCodeAbbrevOp::Fixed,
2572 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2573 // EmbeddedInDeclarator, IsFreeStanding,
2574 // isCompleteDefinitionRequired, ExtInfoKind
2575 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2576 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2577 // EnumDecl
2578 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2579 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2580 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2581 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2582 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2583 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2584 // DC
2585 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2586 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2587 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2588 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2589 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2590
2591 // Abbreviation for DECL_RECORD
2592 Abv = std::make_shared<BitCodeAbbrev>();
2593 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2594 // Redeclarable
2595 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2596 // Decl
2597 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2598 7)); // Packed DeclBits: ModuleOwnershipKind,
2599 // isUsed, isReferenced, AccessSpecifier,
2600 //
2601 // The following bits should be 0:
2602 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2603 // TopLevelDeclInObjCContainer,
2604 // isInvalidDecl
2605 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2606 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2607 // NamedDecl
2608 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2609 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2610 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2611 // TypeDecl
2612 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2613 // TagDecl
2614 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2615 Abv->Add(BitCodeAbbrevOp(
2616 BitCodeAbbrevOp::Fixed,
2617 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2618 // EmbeddedInDeclarator, IsFreeStanding,
2619 // isCompleteDefinitionRequired, ExtInfoKind
2620 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2621 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2622 // RecordDecl
2623 Abv->Add(BitCodeAbbrevOp(
2624 BitCodeAbbrevOp::Fixed,
2625 14)); // Packed Record Decl Bits: FlexibleArrayMember,
2626 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2627 // isNonTrivialToPrimitiveDefaultInitialize,
2628 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2629 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2630 // hasNonTrivialToPrimitiveDestructCUnion,
2631 // hasNonTrivialToPrimitiveCopyCUnion,
2632 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2633 // getArgPassingRestrictions
2634 // ODRHash
2635 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2636
2637 // DC
2638 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2639 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2640 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2641 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2642 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2643
2644 // Abbreviation for DECL_PARM_VAR
2645 Abv = std::make_shared<BitCodeAbbrev>();
2646 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2647 // Redeclarable
2648 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2649 // Decl
2650 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2651 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2652 // isReferenced, AccessSpecifier,
2653 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2654 // TopLevelDeclInObjCContainer,
2655 // isInvalidDecl,
2656 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2657 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2658 // NamedDecl
2659 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2660 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2661 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2662 // ValueDecl
2663 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2664 // DeclaratorDecl
2665 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2666 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2667 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2668 // VarDecl
2669 Abv->Add(
2670 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2671 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2672 // isARCPseudoStrong, Linkage, ModulesCodegen
2673 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2674 // ParmVarDecl
2675 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2676 Abv->Add(BitCodeAbbrevOp(
2677 BitCodeAbbrevOp::Fixed,
2678 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2679 // ObjCDeclQualifier, KNRPromoted,
2680 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2681 // Type Source Info
2682 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2683 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2684 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2685
2686 // Abbreviation for DECL_TYPEDEF
2687 Abv = std::make_shared<BitCodeAbbrev>();
2688 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2689 // Redeclarable
2690 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2691 // Decl
2692 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2693 7)); // Packed DeclBits: ModuleOwnershipKind,
2694 // isReferenced, isUsed, AccessSpecifier. Other
2695 // higher bits should be 0: isImplicit,
2696 // HasStandaloneLexicalDC, HasAttrs,
2697 // TopLevelDeclInObjCContainer, isInvalidDecl
2698 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2699 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2700 // NamedDecl
2701 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2702 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2703 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2704 // TypeDecl
2705 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2706 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2707 // TypedefDecl
2708 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2709 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2710 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2711
2712 // Abbreviation for DECL_VAR
2713 Abv = std::make_shared<BitCodeAbbrev>();
2714 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2715 // Redeclarable
2716 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2717 // Decl
2718 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2719 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2720 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2721 // isReferenced, TopLevelDeclInObjCContainer,
2722 // AccessSpecifier, ModuleOwnershipKind
2723 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2724 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2725 // NamedDecl
2726 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2727 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2728 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2729 // ValueDecl
2730 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2731 // DeclaratorDecl
2732 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2733 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2734 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2735 // VarDecl
2736 Abv->Add(BitCodeAbbrevOp(
2737 BitCodeAbbrevOp::Fixed,
2738 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2739 // SClass, TSCSpec, InitStyle,
2740 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2741 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2742 // isInline, isInlineSpecified, isConstexpr,
2743 // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
2744 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2745 // IsCXXForRangeImplicitVar
2746 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2747 // Type Source Info
2748 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2749 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2750 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2751
2752 // Abbreviation for DECL_CXX_METHOD
2753 DeclCXXMethodAbbrev =
2754 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2755 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2756 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2757 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2758 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2759 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2760 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2761 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2762 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2763 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2764 getCXXMethodAbbrev<
2766
2767 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2768 Abv = std::make_shared<BitCodeAbbrev>();
2769 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2770 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2771 // Decl
2772 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2773 7)); // Packed DeclBits: ModuleOwnershipKind,
2774 // isReferenced, isUsed, AccessSpecifier. Other
2775 // higher bits should be 0: isImplicit,
2776 // HasStandaloneLexicalDC, HasAttrs,
2777 // TopLevelDeclInObjCContainer, isInvalidDecl
2778 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2779 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2780 // NamedDecl
2781 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2782 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2783 Abv->Add(BitCodeAbbrevOp(0));
2784 // TypeDecl
2785 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2786 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2787 // TemplateTypeParmDecl
2788 Abv->Add(
2789 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2790 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2791 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2792
2793 // Abbreviation for DECL_USING_SHADOW
2794 Abv = std::make_shared<BitCodeAbbrev>();
2795 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2796 // Redeclarable
2797 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2798 // Decl
2799 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2800 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2801 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2802 // isReferenced, TopLevelDeclInObjCContainer,
2803 // AccessSpecifier, ModuleOwnershipKind
2804 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2805 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2806 // NamedDecl
2807 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2808 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2809 Abv->Add(BitCodeAbbrevOp(0));
2810 // UsingShadowDecl
2811 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2812 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2813 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2814 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2815 6)); // InstantiatedFromUsingShadowDecl
2816 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2817
2818 // Abbreviation for EXPR_DECL_REF
2819 Abv = std::make_shared<BitCodeAbbrev>();
2820 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2821 // Stmt
2822 // Expr
2823 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2824 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2825 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2826 // DeclRefExpr
2827 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2828 // IsImmediateEscalating, NonOdrUseReason.
2829 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2830 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2831 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2832 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2833 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2834
2835 // Abbreviation for EXPR_INTEGER_LITERAL
2836 Abv = std::make_shared<BitCodeAbbrev>();
2837 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2838 //Stmt
2839 // Expr
2840 // DependenceKind, ValueKind, ObjectKind
2841 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2842 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2843 // Integer Literal
2844 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2845 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2846 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2847 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2848
2849 // Abbreviation for EXPR_CHARACTER_LITERAL
2850 Abv = std::make_shared<BitCodeAbbrev>();
2851 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2852 //Stmt
2853 // Expr
2854 // DependenceKind, ValueKind, ObjectKind
2855 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2856 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2857 // Character Literal
2858 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2859 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2860 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2861 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2862
2863 // Abbreviation for EXPR_IMPLICIT_CAST
2864 Abv = std::make_shared<BitCodeAbbrev>();
2865 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2866 // Stmt
2867 // Expr
2868 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2869 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2870 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2871 // CastExpr
2872 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2873 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2874 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2875 // ImplicitCastExpr
2876 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2877
2878 // Abbreviation for EXPR_BINARY_OPERATOR
2879 Abv = std::make_shared<BitCodeAbbrev>();
2880 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2881 // Stmt
2882 // Expr
2883 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2884 // be 0 in this case.
2885 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2886 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2887 // BinaryOperator
2888 Abv->Add(
2889 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2890 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2891 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2892
2893 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2894 Abv = std::make_shared<BitCodeAbbrev>();
2895 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2896 // Stmt
2897 // Expr
2898 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2899 // be 0 in this case.
2900 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2901 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2902 // BinaryOperator
2903 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2904 Abv->Add(
2905 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2906 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2907 // CompoundAssignOperator
2908 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2909 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2910 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2911
2912 // Abbreviation for EXPR_CALL
2913 Abv = std::make_shared<BitCodeAbbrev>();
2914 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2915 // Stmt
2916 // Expr
2917 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2918 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2919 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2920 // CallExpr
2921 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2922 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2923 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2924 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2925
2926 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2927 Abv = std::make_shared<BitCodeAbbrev>();
2928 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2929 // Stmt
2930 // Expr
2931 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2932 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2933 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2934 // CallExpr
2935 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2936 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2937 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2938 // CXXOperatorCallExpr
2939 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
2940 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2941 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2942
2943 // Abbreviation for EXPR_CXX_MEMBER_CALL
2944 Abv = std::make_shared<BitCodeAbbrev>();
2945 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
2946 // Stmt
2947 // Expr
2948 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2949 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2950 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2951 // CallExpr
2952 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2953 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2954 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2955 // CXXMemberCallExpr
2956 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2957
2958 // Abbreviation for STMT_COMPOUND
2959 Abv = std::make_shared<BitCodeAbbrev>();
2960 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
2961 // Stmt
2962 // CompoundStmt
2963 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
2964 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
2965 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2966 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2967 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
2968
2969 Abv = std::make_shared<BitCodeAbbrev>();
2970 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2971 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2972 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2973
2974 Abv = std::make_shared<BitCodeAbbrev>();
2975 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2976 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2977 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2978
2979 Abv = std::make_shared<BitCodeAbbrev>();
2980 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
2981 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2982 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2983
2984 Abv = std::make_shared<BitCodeAbbrev>();
2985 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
2986 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2987 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2988
2989 Abv = std::make_shared<BitCodeAbbrev>();
2990 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
2991 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2992 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2993
2994 Abv = std::make_shared<BitCodeAbbrev>();
2995 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
2996 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2997 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2998}
2999
3000/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
3001/// consumers of the AST.
3002///
3003/// Such decls will always be deserialized from the AST file, so we would like
3004/// this to be as restrictive as possible. Currently the predicate is driven by
3005/// code generation requirements, if other clients have a different notion of
3006/// what is "required" then we may have to consider an alternate scheme where
3007/// clients can iterate over the top-level decls and get information on them,
3008/// without necessary deserializing them. We could explicitly require such
3009/// clients to use a separate API call to "realize" the decl. This should be
3010/// relatively painless since they would presumably only do it for top-level
3011/// decls.
3012static bool isRequiredDecl(const Decl *D, ASTContext &Context,
3013 Module *WritingModule) {
3014 // Named modules have different semantics than header modules. Every named
3015 // module units owns a translation unit. So the importer of named modules
3016 // doesn't need to deserilize everything ahead of time.
3017 if (WritingModule && WritingModule->isNamedModule()) {
3018 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
3019 // And the behavior of MSVC for such cases will leak this to the module
3020 // users. Given pragma is not a standard thing, the compiler has the space
3021 // to do their own decision. Let's follow MSVC here.
3023 return true;
3024 return false;
3025 }
3026
3027 // An ObjCMethodDecl is never considered as "required" because its
3028 // implementation container always is.
3029
3030 // File scoped assembly or obj-c or OMP declare target implementation must be
3031 // seen.
3033 return true;
3034
3035 if (WritingModule && isPartOfPerModuleInitializer(D)) {
3036 // These declarations are part of the module initializer, and are emitted
3037 // if and when the module is imported, rather than being emitted eagerly.
3038 return false;
3039 }
3040
3041 return Context.DeclMustBeEmitted(D);
3042}
3043
3044void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
3045 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
3046 "serializing");
3047
3048 // Determine the ID for this declaration.
3049 LocalDeclID ID;
3050 assert(!D->isFromASTFile() && "should not be emitting imported decl");
3051 LocalDeclID &IDR = DeclIDs[D];
3052 if (IDR.isInvalid())
3053 IDR = NextDeclID++;
3054
3055 ID = IDR;
3056
3057 assert(ID >= FirstDeclID && "invalid decl ID");
3058
3060 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
3061
3062 // Build a record for this declaration
3063 W.Visit(D);
3064
3065 // Emit this declaration to the bitstream.
3066 uint64_t Offset = W.Emit(D);
3067
3068 // Record the offset for this declaration
3069 SourceLocation Loc = D->getLocation();
3071 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
3072
3073 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
3074 if (DeclOffsets.size() == Index)
3075 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
3076 else if (DeclOffsets.size() < Index) {
3077 // FIXME: Can/should this happen?
3078 DeclOffsets.resize(Index+1);
3079 DeclOffsets[Index].setRawLoc(RawLoc);
3080 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
3081 } else {
3082 llvm_unreachable("declarations should be emitted in ID order");
3083 }
3084
3085 SourceManager &SM = Context.getSourceManager();
3086 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
3087 associateDeclWithFile(D, ID);
3088
3089 // Note declarations that should be deserialized eagerly so that we can add
3090 // them to a record in the AST file later.
3091 if (isRequiredDecl(D, Context, WritingModule))
3092 AddDeclRef(D, EagerlyDeserializedDecls);
3093}
3094
3096 // Switch case IDs are per function body.
3097 Writer->ClearSwitchCaseIDs();
3098
3099 assert(FD->doesThisDeclarationHaveABody());
3100 bool ModulesCodegen = shouldFunctionGenerateHereOnly(FD);
3101 Record->push_back(ModulesCodegen);
3102 if (ModulesCodegen)
3103 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3104 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3105 Record->push_back(CD->getNumCtorInitializers());
3106 if (CD->getNumCtorInitializers())
3107 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3108 }
3109 AddStmt(FD->getBody());
3110}
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:845
const LangOptions & getLangOpts() const
Definition ASTContext.h:938
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:775
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:1073
void addBit(bool Value)
Definition ASTWriter.h:1093
void addBits(uint32_t Value, uint32_t BitsWidth)
Definition ASTWriter.h:1094
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4654
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition Decl.h:4777
bool canAvoidCopyToHeap() const
Definition Decl.h:4808
size_t param_size() const
Definition Decl.h:4756
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:4733
ArrayRef< Capture > captures() const
Definition Decl.h:4781
bool blockMissingReturnType() const
Definition Decl.h:4789
bool capturesCXXThis() const
Definition Decl.h:4786
bool doesNotEscape() const
Definition Decl.h:4805
bool isConversionFromLambda() const
Definition Decl.h:4797
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:4740
bool isVariadic() const
Definition Decl.h:4729
TypeSourceInfo * getSignatureAsWritten() const
Definition Decl.h:4737
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:4926
unsigned getNumParams() const
Definition Decl.h:4964
unsigned getContextParamPosition() const
Definition Decl.h:4993
bool isNothrow() const
Definition Decl.cpp:5621
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4966
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:5161
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:4007
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition Decl.h:4270
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4216
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition Decl.h:4208
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4219
unsigned getODRHash()
Definition Decl.cpp:5094
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Definition Decl.h:4187
EnumDecl * getMostRecentDecl()
Definition Decl.h:4103
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition Decl.h:4225
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition Decl.h:4171
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
Definition Decl.h:4197
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition Decl.h:4163
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:5114
SourceLocation getRBraceLoc() const
Definition Decl.h:5133
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:4602
SourceLocation getRParenLoc() const
Definition Decl.h:4596
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:3268
bool isTrivialForCall() const
Definition Decl.h:2380
ConstexprSpecKind getConstexprKind() const
Definition Decl.h:2476
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
Definition Decl.cpp:3183
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition Decl.cpp:4182
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
Definition Decl.cpp:3540
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:4161
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition Decl.cpp:4312
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition Decl.h:2326
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition Decl.cpp:4378
unsigned getODRHash()
Returns ODRHash of the function.
Definition Decl.cpp:4668
@ 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:4133
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:3548
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:4206
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:5176
bool isCBuffer() const
Definition Decl.h:5220
SourceLocation getLBraceLoc() const
Definition Decl.h:5217
SourceLocation getLocStart() const LLVM_READONLY
Definition Decl.h:5216
SourceLocation getRBraceLoc() const
Definition Decl.h:5218
ArrayRef< TemplateArgument > getTemplateArguments() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5035
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:5990
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition Decl.h:5093
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:4861
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4893
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:5592
unsigned getNumParams() const
Definition Decl.h:4891
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:3041
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:4312
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition Decl.cpp:5338
bool hasNonTrivialToPrimitiveDestructCUnion() const
Definition Decl.h:4422
bool hasNonTrivialToPrimitiveCopyCUnion() const
Definition Decl.h:4430
RecordArgPassingKind getArgPassingRestrictions() const
Definition Decl.h:4453
bool hasVolatileMember() const
Definition Decl.h:4375
bool hasFlexibleArrayMember() const
Definition Decl.h:4345
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Definition Decl.h:4414
bool hasObjectMember() const
Definition Decl.h:4372
bool isNonTrivialToPrimitiveDestroy() const
Definition Decl.h:4406
bool isNonTrivialToPrimitiveCopy() const
Definition Decl.h:4398
bool isParamDestroyedInCallee() const
Definition Decl.h:4462
RecordDecl * getMostRecentDecl()
Definition Decl.h:4338
bool hasUninitializedExplicitInitFields() const
Definition Decl.h:4438
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition Decl.h:4390
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition Decl.h:4364
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:3788
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition Decl.h:3807
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:3836
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:3812
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition Decl.h:3948
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition Decl.h:3821
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
Definition Decl.h:3847
TagKind getTagKind() const
Definition Decl.h:3911
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:4617
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:8260
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
Definition Type.cpp:2056
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:5690
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:2810
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:2444
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:2698
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:2779
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Definition Decl.cpp:2898
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:583
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:6604
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)