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->getDefalutedOrDeletedInfo()) {
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
1798}
1799
1805
1807 VisitDecl(D);
1808 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1809 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1810 Record.push_back(!IdentifierLocs.empty());
1811 if (IdentifierLocs.empty()) {
1812 Record.AddSourceLocation(D->getEndLoc());
1813 Record.push_back(1);
1814 } else {
1815 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1816 Record.AddSourceLocation(IdentifierLocs[I]);
1817 Record.push_back(IdentifierLocs.size());
1818 }
1819 // Note: the number of source locations must always be the last element in
1820 // the record.
1822}
1823
1825 VisitDecl(D);
1826 Record.AddSourceLocation(D->getColonLoc());
1828}
1829
1831 // Record the number of friend type template parameter lists here
1832 // so as to simplify memory allocation during deserialization.
1833 Record.push_back(D->NumTPLists);
1834 VisitDecl(D);
1835 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1836 Record.push_back(hasFriendDecl);
1837 if (hasFriendDecl)
1838 Record.AddDeclRef(D->getFriendDecl());
1839 else
1840 Record.AddTypeSourceInfo(D->getFriendType());
1841 for (unsigned i = 0; i < D->NumTPLists; ++i)
1842 Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1843 Record.AddDeclRef(D->getNextFriend());
1844 Record.push_back(D->UnsupportedFriend);
1845 Record.AddSourceLocation(D->FriendLoc);
1846 Record.AddSourceLocation(D->EllipsisLoc);
1848}
1849
1851 VisitDecl(D);
1852 Record.push_back(D->getNumTemplateParameters());
1853 for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1854 Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1855 Record.push_back(D->getFriendDecl() != nullptr);
1856 if (D->getFriendDecl())
1857 Record.AddDeclRef(D->getFriendDecl());
1858 else
1859 Record.AddTypeSourceInfo(D->getFriendType());
1860 Record.AddSourceLocation(D->getFriendLoc());
1862}
1863
1865 VisitNamedDecl(D);
1866
1867 Record.AddTemplateParameterList(D->getTemplateParameters());
1868 Record.AddDeclRef(D->getTemplatedDecl());
1869}
1870
1876
1879 Record.push_back(D->getTemplateArguments().size());
1880 VisitDecl(D);
1881 for (const TemplateArgument &Arg : D->getTemplateArguments())
1882 Record.AddTemplateArgument(Arg);
1884}
1885
1889
1892
1893 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1894 // getCommonPtr() can be used while this is still initializing.
1895 if (D->isFirstDecl()) {
1896 // This declaration owns the 'common' pointer, so serialize that data now.
1897 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1899 Record.push_back(D->isMemberSpecialization());
1900 }
1901
1903 Record.push_back(D->getIdentifierNamespace());
1904}
1905
1908
1909 if (D->isFirstDecl())
1911
1912 // Force emitting the corresponding deduction guide in reduced BMI mode.
1913 // Otherwise, the deduction guide may be optimized out incorrectly.
1914 if (Writer.isGeneratingReducedBMI()) {
1915 auto Name =
1916 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1917 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1918 Writer.GetDeclRef(DG->getCanonicalDecl());
1919 }
1920
1922}
1923
1927
1929
1930 llvm::PointerUnion<ClassTemplateDecl *,
1933 if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1934 Record.AddDeclRef(InstFromD);
1935 } else {
1936 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1937 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1938 }
1939
1940 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1941 Record.AddSourceLocation(D->getPointOfInstantiation());
1942 Record.push_back(D->getSpecializationKind());
1943 Record.push_back(D->hasStrictPackMatch());
1944 Record.push_back(D->isCanonicalDecl());
1945
1946 if (D->isCanonicalDecl()) {
1947 // When reading, we'll add it to the folding set of the following template.
1948 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1949 }
1950
1955 Record.push_back(ExplicitInstantiation);
1957 Record.AddSourceLocation(D->getExternKeywordLoc());
1958 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1959 }
1960
1961 const ASTTemplateArgumentListInfo *ArgsWritten =
1963 Record.push_back(!!ArgsWritten);
1964 if (ArgsWritten)
1965 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1966
1967 // Mention the implicitly generated C++ deduction guide to make sure the
1968 // deduction guide will be rewritten as expected.
1969 //
1970 // FIXME: Would it be more efficient to add a callback register function
1971 // in sema to register the deduction guide?
1972 if (Writer.isWritingStdCXXNamedModules()) {
1973 auto Name =
1974 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
1976 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1977 Writer.GetDeclRef(DG->getCanonicalDecl());
1978 }
1979
1981}
1982
1985 Record.AddTemplateParameterList(D->getTemplateParameters());
1986
1988
1989 // These are read/set from/to the first declaration.
1990 if (D->getPreviousDecl() == nullptr) {
1991 Record.AddDeclRef(D->getInstantiatedFromMember());
1992 Record.push_back(D->isMemberSpecialization());
1993 }
1994
1996}
1997
2005
2009
2010 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2011 InstFrom = D->getSpecializedTemplateOrPartial();
2012 if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
2013 Record.AddDeclRef(InstFromD);
2014 } else {
2015 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
2016 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
2017 }
2018
2023 Record.push_back(ExplicitInstantiation);
2025 Record.AddSourceLocation(D->getExternKeywordLoc());
2026 Record.AddSourceLocation(D->getTemplateKeywordLoc());
2027 }
2028
2029 const ASTTemplateArgumentListInfo *ArgsWritten =
2031 Record.push_back(!!ArgsWritten);
2032 if (ArgsWritten)
2033 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
2034
2035 Record.AddTemplateArgumentList(&D->getTemplateArgs());
2036 Record.AddSourceLocation(D->getPointOfInstantiation());
2037 Record.push_back(D->getSpecializationKind());
2038 Record.push_back(D->IsCompleteDefinition);
2039
2040 VisitVarDecl(D);
2041
2042 Record.push_back(D->isCanonicalDecl());
2043
2044 if (D->isCanonicalDecl()) {
2045 // When reading, we'll add it to the folding set of the following template.
2046 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
2047 }
2048
2050}
2051
2054 Record.AddTemplateParameterList(D->getTemplateParameters());
2055
2057
2058 // These are read/set from/to the first declaration.
2059 if (D->getPreviousDecl() == nullptr) {
2060 Record.AddDeclRef(D->getInstantiatedFromMember());
2061 Record.push_back(D->isMemberSpecialization());
2062 }
2063
2065}
2066
2074
2076 Record.push_back(D->hasTypeConstraint());
2077 VisitTypeDecl(D);
2078
2079 Record.push_back(D->wasDeclaredWithTypename());
2080
2081 const TypeConstraint *TC = D->getTypeConstraint();
2082 if (D->hasTypeConstraint())
2083 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
2084 if (TC) {
2085 auto *CR = TC->getConceptReference();
2086 Record.push_back(CR != nullptr);
2087 if (CR)
2088 Record.AddConceptReference(CR);
2089 Record.AddStmt(TC->getImmediatelyDeclaredConstraint());
2090 Record.writeUnsignedOrNone(TC->getArgPackSubstIndex());
2091 Record.writeUnsignedOrNone(D->getNumExpansionParameters());
2092 }
2093
2094 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2096 Record.push_back(OwnsDefaultArg);
2097 if (OwnsDefaultArg)
2098 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2099
2100 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
2102 !D->isInvalidDecl() && !D->hasAttrs() &&
2105 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
2106
2108}
2109
2111 // For an expanded parameter pack, record the number of expansion types here
2112 // so that it's easier for deserialization to allocate the right amount of
2113 // memory.
2114 Record.push_back(D->hasPlaceholderTypeConstraint());
2115 if (D->isExpandedParameterPack())
2116 Record.push_back(D->getNumExpansionTypes());
2117
2119 // TemplateParmPosition.
2120 Record.push_back(D->getDepth());
2121 Record.push_back(D->getPosition());
2122
2124 Record.AddStmt(D->getPlaceholderTypeConstraint());
2125
2126 if (D->isExpandedParameterPack()) {
2127 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2128 Record.AddTypeRef(D->getExpansionType(I));
2129 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2130 }
2131
2133 } else {
2134 // Rest of NonTypeTemplateParmDecl.
2135 Record.push_back(D->isParameterPack());
2136 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2138 Record.push_back(OwnsDefaultArg);
2139 if (OwnsDefaultArg)
2140 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2142 }
2143}
2144
2146 // For an expanded parameter pack, record the number of expansion types here
2147 // so that it's easier for deserialization to allocate the right amount of
2148 // memory.
2149 if (D->isExpandedParameterPack())
2150 Record.push_back(D->getNumExpansionTemplateParameters());
2151
2153 Record.push_back(D->templateParameterKind());
2154 Record.push_back(D->wasDeclaredWithTypename());
2155 // TemplateParmPosition.
2156 Record.push_back(D->getDepth());
2157 Record.push_back(D->getPosition());
2158
2159 if (D->isExpandedParameterPack()) {
2160 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2161 I != N; ++I)
2162 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2164 } else {
2165 // Rest of TemplateTemplateParmDecl.
2166 Record.push_back(D->isParameterPack());
2167 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2169 Record.push_back(OwnsDefaultArg);
2170 if (OwnsDefaultArg)
2171 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2173 }
2174}
2175
2180
2182 VisitDecl(D);
2183 Record.AddStmt(D->getAssertExpr());
2184 Record.push_back(D->isFailed());
2185 Record.AddStmt(D->getMessage());
2186 Record.AddSourceLocation(D->getRParenLoc());
2188}
2189
2190/// Emit the DeclContext part of a declaration context decl.
2192 static_assert(DeclContext::NumDeclContextBits == 13,
2193 "You need to update the serializer after you change the "
2194 "DeclContextBits");
2195 LookupBlockOffsets Offsets;
2196
2197 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2198 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2199 // In reduced BMI, delay writing lexical and visible block for namespace
2200 // in the global module fragment. See the comments of DelayedNamespace for
2201 // details.
2202 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2203 } else {
2204 Offsets.LexicalOffset =
2205 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2206 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC, Offsets);
2207 }
2208
2209 Record.AddLookupOffsets(Offsets);
2210}
2211
2213 assert(IsLocalDecl(D) && "expected a local declaration");
2214
2215 const Decl *Canon = D->getCanonicalDecl();
2216 if (IsLocalDecl(Canon))
2217 return Canon;
2218
2219 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2220 if (CacheEntry)
2221 return CacheEntry;
2222
2223 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2224 if (IsLocalDecl(Redecl))
2225 D = Redecl;
2226 return CacheEntry = D;
2227}
2228
2229template <typename T>
2231 T *First = D->getFirstDecl();
2232 T *MostRecent = First->getMostRecentDecl();
2233 T *DAsT = static_cast<T *>(D);
2234 if (MostRecent != First) {
2235 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2236 "Not considered redeclarable?");
2237
2238 Record.AddDeclRef(First);
2239
2240 // Write out a list of local redeclarations of this declaration if it's the
2241 // first local declaration in the chain.
2242 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2243 if (DAsT == FirstLocal) {
2244 // Emit a list of all imported first declarations so that we can be sure
2245 // that all redeclarations visible to this module are before D in the
2246 // redecl chain.
2247 unsigned I = Record.size();
2248 Record.push_back(0);
2249 if (Writer.Chain)
2250 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2251 // This is the number of imported first declarations + 1.
2252 Record[I] = Record.size() - I;
2253
2254 // Collect the set of local redeclarations of this declaration, from
2255 // newest to oldest.
2256 ASTWriter::RecordData LocalRedecls;
2257 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2258 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2259 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2260 if (!Prev->isFromASTFile())
2261 LocalRedeclWriter.AddDeclRef(Prev);
2262
2263 // If we have any redecls, write them now as a separate record preceding
2264 // the declaration itself.
2265 if (LocalRedecls.empty())
2266 Record.push_back(0);
2267 else
2268 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2269 } else {
2270 Record.push_back(0);
2271 Record.AddDeclRef(FirstLocal);
2272 }
2273
2274 // Make sure that we serialize both the previous and the most-recent
2275 // declarations, which (transitively) ensures that all declarations in the
2276 // chain get serialized.
2277 //
2278 // FIXME: This is not correct; when we reach an imported declaration we
2279 // won't emit its previous declaration.
2280 (void)Writer.GetDeclRef(D->getPreviousDecl());
2281 (void)Writer.GetDeclRef(MostRecent);
2282 } else {
2283 // We use the sentinel value 0 to indicate an only declaration.
2284 Record.push_back(0);
2285 }
2286}
2287
2289 VisitNamedDecl(D);
2291 Record.push_back(D->isCBuffer());
2292 Record.AddSourceLocation(D->getLocStart());
2293 Record.AddSourceLocation(D->getLBraceLoc());
2294 Record.AddSourceLocation(D->getRBraceLoc());
2295
2297}
2298
2300 Record.writeOMPChildren(D->Data);
2301 VisitDecl(D);
2303}
2304
2306 Record.writeOMPChildren(D->Data);
2307 VisitDecl(D);
2309}
2310
2312 Record.writeOMPChildren(D->Data);
2313 VisitDecl(D);
2315}
2316
2319 "You need to update the serializer after you change the "
2320 "NumOMPDeclareReductionDeclBits");
2321
2322 VisitValueDecl(D);
2323 Record.AddSourceLocation(D->getBeginLoc());
2324 Record.AddStmt(D->getCombinerIn());
2325 Record.AddStmt(D->getCombinerOut());
2326 Record.AddStmt(D->getCombiner());
2327 Record.AddStmt(D->getInitOrig());
2328 Record.AddStmt(D->getInitPriv());
2329 Record.AddStmt(D->getInitializer());
2330 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2331 Record.AddDeclRef(D->getPrevDeclInScope());
2333}
2334
2336 Record.writeOMPChildren(D->Data);
2337 VisitValueDecl(D);
2338 Record.AddDeclarationName(D->getVarName());
2339 Record.AddDeclRef(D->getPrevDeclInScope());
2341}
2342
2347
2349 Record.writeUInt32(D->clauses().size());
2350 VisitDecl(D);
2351 Record.writeEnum(D->DirKind);
2352 Record.AddSourceLocation(D->DirectiveLoc);
2353 Record.AddSourceLocation(D->EndLoc);
2354 Record.writeOpenACCClauseList(D->clauses());
2356}
2358 Record.writeUInt32(D->clauses().size());
2359 VisitDecl(D);
2360 Record.writeEnum(D->DirKind);
2361 Record.AddSourceLocation(D->DirectiveLoc);
2362 Record.AddSourceLocation(D->EndLoc);
2363 Record.AddSourceRange(D->ParensLoc);
2364 Record.AddStmt(D->FuncRef);
2365 Record.writeOpenACCClauseList(D->clauses());
2367}
2368
2369//===----------------------------------------------------------------------===//
2370// ASTWriter Implementation
2371//===----------------------------------------------------------------------===//
2372
2373namespace {
2374template <FunctionDecl::TemplatedKind Kind>
2375std::shared_ptr<llvm::BitCodeAbbrev>
2376getFunctionDeclAbbrev(serialization::DeclCode Code) {
2377 using namespace llvm;
2378
2379 auto Abv = std::make_shared<BitCodeAbbrev>();
2380 Abv->Add(BitCodeAbbrevOp(Code));
2381 // RedeclarableDecl
2382 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2383 Abv->Add(BitCodeAbbrevOp(Kind));
2384 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2385
2386 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2387 // DescribedFunctionTemplate
2388 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2389 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2390 // Instantiated From Decl
2391 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2392 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2393 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2394 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2395 3)); // TemplateSpecializationKind
2396 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2397 } else if constexpr (Kind ==
2399 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2400 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2401 3)); // TemplateSpecializationKind
2402 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2403 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2404 Abv->Add(
2405 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2406 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2407 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2408 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2409 Abv->Add(BitCodeAbbrevOp(0));
2410 Abv->Add(
2411 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2412 } else if constexpr (Kind == FunctionDecl::
2413 TK_DependentFunctionTemplateSpecialization) {
2414 // Candidates of specialization
2415 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2416 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2417 } else {
2418 llvm_unreachable("Unknown templated kind?");
2419 }
2420 // Decl
2421 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2422 8)); // Packed DeclBits: ModuleOwnershipKind,
2423 // isUsed, isReferenced, AccessSpecifier,
2424 // isImplicit
2425 //
2426 // The following bits should be 0:
2427 // HasStandaloneLexicalDC, HasAttrs,
2428 // TopLevelDeclInObjCContainer,
2429 // isInvalidDecl
2430 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2431 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2432 // NamedDecl
2433 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2434 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2435 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2436 // ValueDecl
2437 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2438 // DeclaratorDecl
2439 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2440 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2441 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2442 // FunctionDecl
2443 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2444 Abv->Add(BitCodeAbbrevOp(
2445 BitCodeAbbrevOp::Fixed,
2446 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2447 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2448 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2449 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2450 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2451 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2452 // ShouldSkipCheckingODR
2453 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2454 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2455 // This Array slurps the rest of the record. Fortunately we want to encode
2456 // (nearly) all the remaining (variable number of) fields in the same way.
2457 //
2458 // This is:
2459 // NumParams and Params[] from FunctionDecl, and
2460 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2461 //
2462 // Add an AbbrevOp for 'size then elements' and use it here.
2463 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2464 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2465 return Abv;
2466}
2467
2468template <FunctionDecl::TemplatedKind Kind>
2469std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2470 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2471}
2472} // namespace
2473
2474void ASTWriter::WriteDeclAbbrevs() {
2475 using namespace llvm;
2476
2477 std::shared_ptr<BitCodeAbbrev> Abv;
2478
2479 // Abbreviation for DECL_FIELD
2480 Abv = std::make_shared<BitCodeAbbrev>();
2481 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2482 // Decl
2483 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2484 7)); // Packed DeclBits: ModuleOwnershipKind,
2485 // isUsed, isReferenced, AccessSpecifier,
2486 //
2487 // The following bits should be 0:
2488 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2489 // TopLevelDeclInObjCContainer,
2490 // isInvalidDecl
2491 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2492 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2493 // NamedDecl
2494 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2495 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2496 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2497 // ValueDecl
2498 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2499 // DeclaratorDecl
2500 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2501 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2502 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2503 // FieldDecl
2504 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2505 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2506 // Type Source Info
2507 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2508 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2509 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2510
2511 // Abbreviation for DECL_OBJC_IVAR
2512 Abv = std::make_shared<BitCodeAbbrev>();
2513 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2514 // Decl
2515 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2516 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2517 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2518 // isReferenced, TopLevelDeclInObjCContainer,
2519 // AccessSpecifier, ModuleOwnershipKind
2520 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2521 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2522 // NamedDecl
2523 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2524 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2525 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2526 // ValueDecl
2527 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2528 // DeclaratorDecl
2529 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2530 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2531 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2532 // FieldDecl
2533 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2534 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2535 // ObjC Ivar
2536 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2537 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2538 // Type Source Info
2539 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2540 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2541 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2542
2543 // Abbreviation for DECL_ENUM
2544 Abv = std::make_shared<BitCodeAbbrev>();
2545 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2546 // Redeclarable
2547 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2548 // Decl
2549 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2550 7)); // Packed DeclBits: ModuleOwnershipKind,
2551 // isUsed, isReferenced, AccessSpecifier,
2552 //
2553 // The following bits should be 0:
2554 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2555 // TopLevelDeclInObjCContainer,
2556 // isInvalidDecl
2557 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2558 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2559 // NamedDecl
2560 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2561 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2562 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2563 // TypeDecl
2564 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2565 // TagDecl
2566 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2567 Abv->Add(BitCodeAbbrevOp(
2568 BitCodeAbbrevOp::Fixed,
2569 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2570 // EmbeddedInDeclarator, IsFreeStanding,
2571 // isCompleteDefinitionRequired, ExtInfoKind
2572 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2573 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2574 // EnumDecl
2575 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2576 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2577 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2578 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2579 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2580 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2581 // DC
2582 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2583 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2584 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2585 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2586 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2587
2588 // Abbreviation for DECL_RECORD
2589 Abv = std::make_shared<BitCodeAbbrev>();
2590 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2591 // Redeclarable
2592 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2593 // Decl
2594 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2595 7)); // Packed DeclBits: ModuleOwnershipKind,
2596 // isUsed, isReferenced, AccessSpecifier,
2597 //
2598 // The following bits should be 0:
2599 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2600 // TopLevelDeclInObjCContainer,
2601 // isInvalidDecl
2602 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2603 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2604 // NamedDecl
2605 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2606 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2607 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2608 // TypeDecl
2609 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2610 // TagDecl
2611 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2612 Abv->Add(BitCodeAbbrevOp(
2613 BitCodeAbbrevOp::Fixed,
2614 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2615 // EmbeddedInDeclarator, IsFreeStanding,
2616 // isCompleteDefinitionRequired, ExtInfoKind
2617 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2618 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2619 // RecordDecl
2620 Abv->Add(BitCodeAbbrevOp(
2621 BitCodeAbbrevOp::Fixed,
2622 14)); // Packed Record Decl Bits: FlexibleArrayMember,
2623 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2624 // isNonTrivialToPrimitiveDefaultInitialize,
2625 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2626 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2627 // hasNonTrivialToPrimitiveDestructCUnion,
2628 // hasNonTrivialToPrimitiveCopyCUnion,
2629 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2630 // getArgPassingRestrictions
2631 // ODRHash
2632 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2633
2634 // DC
2635 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2636 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2637 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2638 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2639 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2640
2641 // Abbreviation for DECL_PARM_VAR
2642 Abv = std::make_shared<BitCodeAbbrev>();
2643 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2644 // Redeclarable
2645 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2646 // Decl
2647 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2648 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2649 // isReferenced, AccessSpecifier,
2650 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2651 // TopLevelDeclInObjCContainer,
2652 // isInvalidDecl,
2653 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2654 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2655 // NamedDecl
2656 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2657 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2658 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2659 // ValueDecl
2660 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2661 // DeclaratorDecl
2662 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2663 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2664 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2665 // VarDecl
2666 Abv->Add(
2667 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2668 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2669 // isARCPseudoStrong, Linkage, ModulesCodegen
2670 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2671 // ParmVarDecl
2672 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2673 Abv->Add(BitCodeAbbrevOp(
2674 BitCodeAbbrevOp::Fixed,
2675 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2676 // ObjCDeclQualifier, KNRPromoted,
2677 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2678 // Type Source Info
2679 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2680 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2681 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2682
2683 // Abbreviation for DECL_TYPEDEF
2684 Abv = std::make_shared<BitCodeAbbrev>();
2685 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2686 // Redeclarable
2687 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2688 // Decl
2689 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2690 7)); // Packed DeclBits: ModuleOwnershipKind,
2691 // isReferenced, isUsed, AccessSpecifier. Other
2692 // higher bits should be 0: isImplicit,
2693 // HasStandaloneLexicalDC, HasAttrs,
2694 // TopLevelDeclInObjCContainer, isInvalidDecl
2695 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2696 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2697 // NamedDecl
2698 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2699 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2700 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2701 // TypeDecl
2702 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2703 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2704 // TypedefDecl
2705 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2706 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2707 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2708
2709 // Abbreviation for DECL_VAR
2710 Abv = std::make_shared<BitCodeAbbrev>();
2711 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2712 // Redeclarable
2713 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2714 // Decl
2715 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2716 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2717 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2718 // isReferenced, TopLevelDeclInObjCContainer,
2719 // AccessSpecifier, ModuleOwnershipKind
2720 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2721 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2722 // NamedDecl
2723 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2724 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2725 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2726 // ValueDecl
2727 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2728 // DeclaratorDecl
2729 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2730 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2731 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2732 // VarDecl
2733 Abv->Add(BitCodeAbbrevOp(
2734 BitCodeAbbrevOp::Fixed,
2735 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2736 // SClass, TSCSpec, InitStyle,
2737 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2738 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2739 // isInline, isInlineSpecified, isConstexpr,
2740 // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
2741 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2742 // IsCXXForRangeImplicitVar
2743 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2744 // Type Source Info
2745 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2746 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2747 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2748
2749 // Abbreviation for DECL_CXX_METHOD
2750 DeclCXXMethodAbbrev =
2751 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2752 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2753 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2754 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2755 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2756 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2757 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2758 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2759 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2760 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2761 getCXXMethodAbbrev<
2763
2764 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2765 Abv = std::make_shared<BitCodeAbbrev>();
2766 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2767 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2768 // Decl
2769 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2770 7)); // Packed DeclBits: ModuleOwnershipKind,
2771 // isReferenced, isUsed, AccessSpecifier. Other
2772 // higher bits should be 0: isImplicit,
2773 // HasStandaloneLexicalDC, HasAttrs,
2774 // TopLevelDeclInObjCContainer, isInvalidDecl
2775 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2776 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2777 // NamedDecl
2778 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2779 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2780 Abv->Add(BitCodeAbbrevOp(0));
2781 // TypeDecl
2782 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2783 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2784 // TemplateTypeParmDecl
2785 Abv->Add(
2786 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2787 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2788 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2789
2790 // Abbreviation for DECL_USING_SHADOW
2791 Abv = std::make_shared<BitCodeAbbrev>();
2792 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2793 // Redeclarable
2794 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2795 // Decl
2796 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2797 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2798 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2799 // isReferenced, TopLevelDeclInObjCContainer,
2800 // AccessSpecifier, ModuleOwnershipKind
2801 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2802 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2803 // NamedDecl
2804 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2805 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2806 Abv->Add(BitCodeAbbrevOp(0));
2807 // UsingShadowDecl
2808 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2809 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2810 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2811 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2812 6)); // InstantiatedFromUsingShadowDecl
2813 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2814
2815 // Abbreviation for EXPR_DECL_REF
2816 Abv = std::make_shared<BitCodeAbbrev>();
2817 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2818 // Stmt
2819 // Expr
2820 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2821 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2822 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2823 // DeclRefExpr
2824 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2825 // IsImmediateEscalating, NonOdrUseReason.
2826 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2827 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2828 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2829 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2830 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2831
2832 // Abbreviation for EXPR_INTEGER_LITERAL
2833 Abv = std::make_shared<BitCodeAbbrev>();
2834 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2835 //Stmt
2836 // Expr
2837 // DependenceKind, ValueKind, ObjectKind
2838 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2839 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2840 // Integer Literal
2841 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2842 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2843 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2844 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2845
2846 // Abbreviation for EXPR_CHARACTER_LITERAL
2847 Abv = std::make_shared<BitCodeAbbrev>();
2848 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2849 //Stmt
2850 // Expr
2851 // DependenceKind, ValueKind, ObjectKind
2852 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2853 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2854 // Character Literal
2855 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2856 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2857 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2858 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2859
2860 // Abbreviation for EXPR_IMPLICIT_CAST
2861 Abv = std::make_shared<BitCodeAbbrev>();
2862 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2863 // Stmt
2864 // Expr
2865 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2866 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2867 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2868 // CastExpr
2869 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2870 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2871 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2872 // ImplicitCastExpr
2873 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2874
2875 // Abbreviation for EXPR_BINARY_OPERATOR
2876 Abv = std::make_shared<BitCodeAbbrev>();
2877 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2878 // Stmt
2879 // Expr
2880 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2881 // be 0 in this case.
2882 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2883 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2884 // BinaryOperator
2885 Abv->Add(
2886 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2887 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2888 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2889
2890 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2891 Abv = std::make_shared<BitCodeAbbrev>();
2892 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2893 // Stmt
2894 // Expr
2895 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2896 // be 0 in this case.
2897 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2898 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2899 // BinaryOperator
2900 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2901 Abv->Add(
2902 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2903 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2904 // CompoundAssignOperator
2905 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2906 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2907 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2908
2909 // Abbreviation for EXPR_CALL
2910 Abv = std::make_shared<BitCodeAbbrev>();
2911 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2912 // Stmt
2913 // Expr
2914 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2915 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2916 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2917 // CallExpr
2918 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2919 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2920 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2921 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2922
2923 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2924 Abv = std::make_shared<BitCodeAbbrev>();
2925 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2926 // Stmt
2927 // Expr
2928 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2929 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2930 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2931 // CallExpr
2932 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2933 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2934 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2935 // CXXOperatorCallExpr
2936 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
2937 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2938 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2939
2940 // Abbreviation for EXPR_CXX_MEMBER_CALL
2941 Abv = std::make_shared<BitCodeAbbrev>();
2942 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
2943 // Stmt
2944 // Expr
2945 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2946 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2947 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2948 // CallExpr
2949 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2950 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2951 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2952 // CXXMemberCallExpr
2953 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2954
2955 // Abbreviation for STMT_COMPOUND
2956 Abv = std::make_shared<BitCodeAbbrev>();
2957 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
2958 // Stmt
2959 // CompoundStmt
2960 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
2961 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
2962 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2963 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2964 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
2965
2966 Abv = std::make_shared<BitCodeAbbrev>();
2967 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2968 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2969 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2970
2971 Abv = std::make_shared<BitCodeAbbrev>();
2972 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2973 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2974 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2975
2976 Abv = std::make_shared<BitCodeAbbrev>();
2977 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
2978 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2979 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2980
2981 Abv = std::make_shared<BitCodeAbbrev>();
2982 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
2983 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2984 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2985
2986 Abv = std::make_shared<BitCodeAbbrev>();
2987 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
2988 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2989 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2990
2991 Abv = std::make_shared<BitCodeAbbrev>();
2992 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
2993 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2994 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2995}
2996
2997/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2998/// consumers of the AST.
2999///
3000/// Such decls will always be deserialized from the AST file, so we would like
3001/// this to be as restrictive as possible. Currently the predicate is driven by
3002/// code generation requirements, if other clients have a different notion of
3003/// what is "required" then we may have to consider an alternate scheme where
3004/// clients can iterate over the top-level decls and get information on them,
3005/// without necessary deserializing them. We could explicitly require such
3006/// clients to use a separate API call to "realize" the decl. This should be
3007/// relatively painless since they would presumably only do it for top-level
3008/// decls.
3009static bool isRequiredDecl(const Decl *D, ASTContext &Context,
3010 Module *WritingModule) {
3011 // Named modules have different semantics than header modules. Every named
3012 // module units owns a translation unit. So the importer of named modules
3013 // doesn't need to deserilize everything ahead of time.
3014 if (WritingModule && WritingModule->isNamedModule()) {
3015 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
3016 // And the behavior of MSVC for such cases will leak this to the module
3017 // users. Given pragma is not a standard thing, the compiler has the space
3018 // to do their own decision. Let's follow MSVC here.
3020 return true;
3021 return false;
3022 }
3023
3024 // An ObjCMethodDecl is never considered as "required" because its
3025 // implementation container always is.
3026
3027 // File scoped assembly or obj-c or OMP declare target implementation must be
3028 // seen.
3030 return true;
3031
3032 if (WritingModule && isPartOfPerModuleInitializer(D)) {
3033 // These declarations are part of the module initializer, and are emitted
3034 // if and when the module is imported, rather than being emitted eagerly.
3035 return false;
3036 }
3037
3038 return Context.DeclMustBeEmitted(D);
3039}
3040
3041void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
3042 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
3043 "serializing");
3044
3045 // Determine the ID for this declaration.
3046 LocalDeclID ID;
3047 assert(!D->isFromASTFile() && "should not be emitting imported decl");
3048 LocalDeclID &IDR = DeclIDs[D];
3049 if (IDR.isInvalid())
3050 IDR = NextDeclID++;
3051
3052 ID = IDR;
3053
3054 assert(ID >= FirstDeclID && "invalid decl ID");
3055
3057 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
3058
3059 // Build a record for this declaration
3060 W.Visit(D);
3061
3062 // Emit this declaration to the bitstream.
3063 uint64_t Offset = W.Emit(D);
3064
3065 // Record the offset for this declaration
3066 SourceLocation Loc = D->getLocation();
3068 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
3069
3070 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
3071 if (DeclOffsets.size() == Index)
3072 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
3073 else if (DeclOffsets.size() < Index) {
3074 // FIXME: Can/should this happen?
3075 DeclOffsets.resize(Index+1);
3076 DeclOffsets[Index].setRawLoc(RawLoc);
3077 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
3078 } else {
3079 llvm_unreachable("declarations should be emitted in ID order");
3080 }
3081
3082 SourceManager &SM = Context.getSourceManager();
3083 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
3084 associateDeclWithFile(D, ID);
3085
3086 // Note declarations that should be deserialized eagerly so that we can add
3087 // them to a record in the AST file later.
3088 if (isRequiredDecl(D, Context, WritingModule))
3089 AddDeclRef(D, EagerlyDeserializedDecls);
3090}
3091
3093 // Switch case IDs are per function body.
3094 Writer->ClearSwitchCaseIDs();
3095
3096 assert(FD->doesThisDeclarationHaveABody());
3097 bool ModulesCodegen = shouldFunctionGenerateHereOnly(FD);
3098 Record->push_back(ModulesCodegen);
3099 if (ModulesCodegen)
3100 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3101 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3102 Record->push_back(CD->getNumCtorInitializers());
3103 if (CD->getNumCtorInitializers())
3104 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3105 }
3106 AddStmt(FD->getBody());
3107}
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:188
SourceManager & getSourceManager()
Definition ASTContext.h:798
const LangOptions & getLangOpts() const
Definition ASTContext.h:891
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:4179
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition DeclCXX.h:4205
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
Definition ASTWriter.h:1063
void addBit(bool Value)
Definition ASTWriter.h:1083
void addBits(uint32_t Value, uint32_t BitsWidth)
Definition ASTWriter.h:1084
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4634
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition Decl.h:4757
bool canAvoidCopyToHeap() const
Definition Decl.h:4788
size_t param_size() const
Definition Decl.h:4736
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:4713
ArrayRef< Capture > captures() const
Definition Decl.h:4761
bool blockMissingReturnType() const
Definition Decl.h:4769
bool capturesCXXThis() const
Definition Decl.h:4766
bool doesNotEscape() const
Definition Decl.h:4785
bool isConversionFromLambda() const
Definition Decl.h:4777
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:4720
bool isVariadic() const
Definition Decl.h:4709
TypeSourceInfo * getSignatureAsWritten() const
Definition Decl.h:4717
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:2937
ExplicitSpecifier getExplicitSpecifier()
Definition DeclCXX.h:2964
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 * getOperatorDelete() const
Definition DeclCXX.h:2902
Expr * getOperatorDeleteThisArg() const
Definition DeclCXX.h:2906
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:4906
unsigned getNumParams() const
Definition Decl.h:4944
unsigned getContextParamPosition() const
Definition Decl.h:4973
bool isNothrow() const
Definition Decl.cpp:5569
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4946
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:3671
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:524
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:578
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:147
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:553
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:779
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:821
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:808
A decomposition declaration.
Definition DeclCXX.h:4243
ArrayRef< BindingDecl * > bindings() const
Definition DeclCXX.h:4281
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:5141
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3420
llvm::APSInt getInitVal() const
Definition Decl.h:3440
const Expr * getInitExpr() const
Definition Decl.h:3438
Represents an enum.
Definition Decl.h:4004
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition Decl.h:4267
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4213
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition Decl.h:4205
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4216
unsigned getODRHash()
Definition Decl.cpp:5046
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Definition Decl.h:4184
EnumDecl * getMostRecentDecl()
Definition Decl.h:4100
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition Decl.h:4222
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition Decl.h:4168
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
Definition Decl.h:4194
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition Decl.h:4160
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:5094
SourceLocation getRBraceLoc() const
Definition Decl.h:5113
This represents one expression.
Definition Expr.h:112
Represents a member of a struct/union/class.
Definition Decl.h:3157
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition Decl.h:3257
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition Decl.h:3337
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition Decl.h:3376
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
Definition Decl.h:3273
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition Decl.h:3381
const Expr * getAsmStringExpr() const
Definition Decl.h:4582
SourceLocation getRParenLoc() const
Definition Decl.h:4576
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:1999
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Definition Decl.h:2686
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition Decl.cpp:3271
bool isTrivialForCall() const
Definition Decl.h:2379
ConstexprSpecKind getConstexprKind() const
Definition Decl.h:2475
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition Decl.cpp:4134
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
Definition Decl.cpp:3539
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
Definition Decl.h:2918
SourceLocation getDefaultLoc() const
Definition Decl.h:2397
bool usesSEHTry() const
Indicates the function uses __try.
Definition Decl.h:2517
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2771
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
Definition Decl.h:2388
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition Decl.h:2376
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Definition Decl.h:2447
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
Definition Decl.cpp:4113
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition Decl.cpp:4264
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition Decl.h:2325
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition Decl.cpp:4330
unsigned getODRHash()
Returns ODRHash of the function.
Definition Decl.cpp:4620
@ TK_FunctionTemplateSpecialization
Definition Decl.h:2015
@ TK_DependentFunctionTemplateSpecialization
Definition Decl.h:2018
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:2885
bool FriendConstraintRefersToEnclosingTemplate() const
Definition Decl.h:2704
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition Decl.cpp:4085
bool isDeletedAsWritten() const
Definition Decl.h:2543
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
Definition Decl.h:2352
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition Decl.h:2356
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
Definition Decl.h:2427
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Definition Decl.h:2676
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
Definition Decl.cpp:3547
bool isDefaulted() const
Whether this function is defaulted.
Definition Decl.h:2384
bool isIneligibleOrNotSelected() const
Definition Decl.h:2417
FunctionDecl * getInstantiatedFromDecl() const
Definition Decl.cpp:4158
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition Decl.h:2343
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition Decl.h:2458
size_t param_size() const
Definition Decl.h:2787
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition Decl.h:2896
DefaultedOrDeletedFunctionInfo * getDefalutedOrDeletedInfo() const
Definition Decl.cpp:3186
bool isInstantiatedFromMemberTemplate() const
Definition Decl.h:2365
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:5156
bool isCBuffer() const
Definition Decl.h:5200
SourceLocation getLBraceLoc() const
Definition Decl.h:5197
SourceLocation getLocStart() const LLVM_READONLY
Definition Decl.h:5196
SourceLocation getRBraceLoc() const
Definition Decl.h:5198
ArrayRef< TemplateArgument > getTemplateArguments() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5015
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:5938
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition Decl.h:5073
Represents a field injected from an anonymous union/struct into the parent scope.
Definition Decl.h:3464
unsigned getChainingSize() const
Definition Decl.h:3489
ArrayRef< NamedDecl * > chain() const
Definition Decl.h:3485
Represents the declaration of a label.
Definition Decl.h:523
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition DeclCXX.h:3302
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition DeclCXX.h:3348
Represents a linkage specification.
Definition DeclCXX.h:3009
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition DeclCXX.h:3032
SourceLocation getExternLoc() const
Definition DeclCXX.h:3048
SourceLocation getRBraceLoc() const
Definition DeclCXX.h:3049
A global _GUID constant.
Definition DeclCXX.h:4392
Parts getParts() const
Get the decomposed parts of this declaration.
Definition DeclCXX.h:4422
MSGuidDeclParts Parts
Definition DeclCXX.h:4394
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4338
IdentifierInfo * getGetterId() const
Definition DeclCXX.h:4360
IdentifierInfo * getSetterId() const
Definition DeclCXX.h:4362
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:273
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:339
Represents a C++ namespace alias.
Definition DeclCXX.h:3195
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3256
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3281
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition DeclCXX.h:3284
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition DeclCXX.h:3265
Represent a C++ namespace.
Definition Decl.h:591
SourceLocation getRBraceLoc() const
Definition Decl.h:691
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:690
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition Decl.h:642
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition Decl.h:647
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
Definition Decl.h:674
bool isNested() const
Returns true if this is a nested namespace declaration.
Definition Decl.h:656
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:474
Pseudo declaration for capturing expressions.
Definition DeclOpenMP.h:383
OMPChildren * Data
Data, associated with the directive.
Definition DeclOpenMP.h:43
This represents 'pragma omp declare mapper ...' directive.
Definition DeclOpenMP.h:287
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:359
This represents 'pragma omp declare reduction ...' directive.
Definition DeclOpenMP.h:177
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition DeclOpenMP.h:238
Expr * getInitPriv()
Get Priv variable of the initializer.
Definition DeclOpenMP.h:249
Expr * getCombinerOut()
Get Out variable of the combiner.
Definition DeclOpenMP.h:226
Expr * getCombinerIn()
Get In variable of the combiner.
Definition DeclOpenMP.h:223
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition DeclOpenMP.h:220
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:246
OMPDeclareReductionInitKind getInitializerKind() const
Get initializer kind.
Definition DeclOpenMP.h:241
This represents 'pragma omp requires...' directive.
Definition DeclOpenMP.h:417
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:4841
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4873
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:5540
unsigned getNumParams() const
Definition Decl.h:4871
Represents a parameter to a function.
Definition Decl.h:1789
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion:
Definition Decl.h:1870
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1849
SourceLocation getExplicitObjectParamThisLoc() const
Definition Decl.h:1885
bool isObjCMethodParameter() const
Definition Decl.h:1832
ObjCDeclQualifier getObjCDeclQualifier() const
Definition Decl.h:1853
bool hasUninstantiatedDefaultArg() const
Definition Decl.h:1922
bool hasInheritedDefaultArg() const
Definition Decl.h:1934
Expr * getUninstantiatedDefaultArg()
Definition Decl.cpp:3044
unsigned getFunctionScopeDepth() const
Definition Decl.h:1839
Represents a #pragma comment line.
Definition Decl.h:166
StringRef getArg() const
Definition Decl.h:189
PragmaMSCommentKind getCommentKind() const
Definition Decl.h:187
Represents a #pragma detect_mismatch line.
Definition Decl.h:200
StringRef getName() const
Definition Decl.h:221
StringRef getValue() const
Definition Decl.h:222
A (possibly-)qualified type.
Definition TypeBase.h:937
Represents a struct/union/class.
Definition Decl.h:4309
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition Decl.cpp:5286
bool hasNonTrivialToPrimitiveDestructCUnion() const
Definition Decl.h:4419
bool hasNonTrivialToPrimitiveCopyCUnion() const
Definition Decl.h:4427
RecordArgPassingKind getArgPassingRestrictions() const
Definition Decl.h:4450
bool hasVolatileMember() const
Definition Decl.h:4372
bool hasFlexibleArrayMember() const
Definition Decl.h:4342
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Definition Decl.h:4411
bool hasObjectMember() const
Definition Decl.h:4369
bool isNonTrivialToPrimitiveDestroy() const
Definition Decl.h:4403
bool isNonTrivialToPrimitiveCopy() const
Definition Decl.h:4395
bool isParamDestroyedInCallee() const
Definition Decl.h:4459
RecordDecl * getMostRecentDecl()
Definition Decl.h:4335
bool hasUninitializedExplicitInitFields() const
Definition Decl.h:4435
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition Decl.h:4387
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition Decl.h:4361
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:4130
bool isFailed() const
Definition DeclCXX.h:4159
SourceLocation getRParenLoc() const
Definition DeclCXX.h:4161
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1801
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3714
SourceRange getBraceRange() const
Definition Decl.h:3785
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition Decl.h:3804
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:3833
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:3809
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition Decl.h:3945
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition Decl.h:3818
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
Definition Decl.h:3844
TagKind getTagKind() const
Definition Decl.h:3908
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:4597
The top declaration context.
Definition Decl.h:104
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition Decl.h:3685
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition Decl.h:3703
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition ASTConcept.h:223
UnsignedOrNone getArgPackSubstIndex() const
Definition ASTConcept.h:246
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Definition ASTConcept.h:240
ConceptReference * getConceptReference() const
Definition ASTConcept.h:244
Represents a declaration of a type.
Definition Decl.h:3510
const Type * getTypeForDecl() const
Definition Decl.h:3535
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:3544
QualType getType() const
Return the type wrapped by this type source info.
Definition TypeBase.h:8267
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:3664
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3559
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:3609
TypedefNameDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isModed() const
Definition Decl.h:3605
QualType getUnderlyingType() const
Definition Decl.h:3614
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
Definition Decl.cpp:5638
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4449
const APValue & getValue() const
Definition DeclCXX.h:4475
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition DeclCXX.h:4112
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4031
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition DeclCXX.h:4061
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4065
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4082
Represents a dependent using declaration which was not marked with typename.
Definition DeclCXX.h:3934
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition DeclCXX.h:3965
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3975
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:3992
Represents a C++ using-declaration.
Definition DeclCXX.h:3585
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition DeclCXX.h:3634
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3619
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition DeclCXX.h:3612
Represents C++ using-directive.
Definition DeclCXX.h:3090
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition DeclCXX.h:3161
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition DeclCXX.cpp:3228
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition DeclCXX.h:3157
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3165
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3135
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3786
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
Definition DeclCXX.h:3810
TypeSourceInfo * getEnumType() const
Definition DeclCXX.h:3822
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Definition DeclCXX.h:3806
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition DeclCXX.h:3867
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition DeclCXX.h:3896
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition DeclCXX.h:3900
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3393
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:3457
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:711
QualType getType() const
Definition Decl.h:722
Represents a variable declaration or definition.
Definition Decl.h:925
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:1568
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition Decl.h:1465
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition Decl.h:1577
@ CInit
C-style initialization with assignment.
Definition Decl.h:930
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C.
Definition Decl.h:1531
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
Definition Decl.cpp:2444
bool isInlineSpecified() const
Definition Decl.h:1553
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition Decl.h:1282
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
Definition Decl.h:1521
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition Decl.h:1511
bool isCXXForRangeImplicitVar() const
Whether this variable is the implicit '__range' variable in C++ range-based for loops.
Definition Decl.h:1621
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition Decl.h:1493
bool isInline() const
Whether this variable is (C++1z) inline.
Definition Decl.h:1550
ThreadStorageClassSpecifier getTSCSpec() const
Definition Decl.h:1176
const Expr * getInit() const
Definition Decl.h:1367
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition Decl.h:1546
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition Decl.h:1228
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1167
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:1475
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition Decl.h:1587
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:92
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:87
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:88
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition Expr.h:6606
Data that is common to all of the declarations of a given function template.
uint16_t Part2
...-89ab-...
Definition DeclCXX.h:4371
uint32_t Part1
{01234567-...
Definition DeclCXX.h:4369
uint16_t Part3
...-cdef-...
Definition DeclCXX.h:4373
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition DeclCXX.h:4375
static DeclType * getDecl(EntryType *D)