Thanks to visit codestin.com
Credit goes to clang.llvm.org

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 Record.AddDeclRef(D->getOperatorGlobalDelete());
1797
1799}
1800
1806
1808 VisitDecl(D);
1809 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1810 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1811 Record.push_back(!IdentifierLocs.empty());
1812 if (IdentifierLocs.empty()) {
1813 Record.AddSourceLocation(D->getEndLoc());
1814 Record.push_back(1);
1815 } else {
1816 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1817 Record.AddSourceLocation(IdentifierLocs[I]);
1818 Record.push_back(IdentifierLocs.size());
1819 }
1820 // Note: the number of source locations must always be the last element in
1821 // the record.
1823}
1824
1826 VisitDecl(D);
1827 Record.AddSourceLocation(D->getColonLoc());
1829}
1830
1832 // Record the number of friend type template parameter lists here
1833 // so as to simplify memory allocation during deserialization.
1834 Record.push_back(D->NumTPLists);
1835 VisitDecl(D);
1836 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1837 Record.push_back(hasFriendDecl);
1838 if (hasFriendDecl)
1839 Record.AddDeclRef(D->getFriendDecl());
1840 else
1841 Record.AddTypeSourceInfo(D->getFriendType());
1842 for (unsigned i = 0; i < D->NumTPLists; ++i)
1843 Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1844 Record.AddDeclRef(D->getNextFriend());
1845 Record.push_back(D->UnsupportedFriend);
1846 Record.AddSourceLocation(D->FriendLoc);
1847 Record.AddSourceLocation(D->EllipsisLoc);
1849}
1850
1852 VisitDecl(D);
1853 Record.push_back(D->getNumTemplateParameters());
1854 for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1855 Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1856 Record.push_back(D->getFriendDecl() != nullptr);
1857 if (D->getFriendDecl())
1858 Record.AddDeclRef(D->getFriendDecl());
1859 else
1860 Record.AddTypeSourceInfo(D->getFriendType());
1861 Record.AddSourceLocation(D->getFriendLoc());
1863}
1864
1866 VisitNamedDecl(D);
1867
1868 Record.AddTemplateParameterList(D->getTemplateParameters());
1869 Record.AddDeclRef(D->getTemplatedDecl());
1870}
1871
1877
1880 Record.push_back(D->getTemplateArguments().size());
1881 VisitDecl(D);
1882 for (const TemplateArgument &Arg : D->getTemplateArguments())
1883 Record.AddTemplateArgument(Arg);
1885}
1886
1890
1893
1894 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1895 // getCommonPtr() can be used while this is still initializing.
1896 if (D->isFirstDecl()) {
1897 // This declaration owns the 'common' pointer, so serialize that data now.
1898 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1900 Record.push_back(D->isMemberSpecialization());
1901 }
1902
1904 Record.push_back(D->getIdentifierNamespace());
1905}
1906
1909
1910 if (D->isFirstDecl())
1912
1913 // Force emitting the corresponding deduction guide in reduced BMI mode.
1914 // Otherwise, the deduction guide may be optimized out incorrectly.
1915 if (Writer.isGeneratingReducedBMI()) {
1916 auto Name =
1917 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1918 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1919 Writer.GetDeclRef(DG->getCanonicalDecl());
1920 }
1921
1923}
1924
1928
1930
1931 llvm::PointerUnion<ClassTemplateDecl *,
1934 if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1935 Record.AddDeclRef(InstFromD);
1936 } else {
1937 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1938 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1939 }
1940
1941 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1942 Record.AddSourceLocation(D->getPointOfInstantiation());
1943 Record.push_back(D->getSpecializationKind());
1944 Record.push_back(D->hasStrictPackMatch());
1945 Record.push_back(D->isCanonicalDecl());
1946
1947 if (D->isCanonicalDecl()) {
1948 // When reading, we'll add it to the folding set of the following template.
1949 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1950 }
1951
1956 Record.push_back(ExplicitInstantiation);
1958 Record.AddSourceLocation(D->getExternKeywordLoc());
1959 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1960 }
1961
1962 const ASTTemplateArgumentListInfo *ArgsWritten =
1964 Record.push_back(!!ArgsWritten);
1965 if (ArgsWritten)
1966 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1967
1968 // Mention the implicitly generated C++ deduction guide to make sure the
1969 // deduction guide will be rewritten as expected.
1970 //
1971 // FIXME: Would it be more efficient to add a callback register function
1972 // in sema to register the deduction guide?
1973 if (Writer.isWritingStdCXXNamedModules()) {
1974 auto Name =
1975 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
1977 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1978 Writer.GetDeclRef(DG->getCanonicalDecl());
1979 }
1980
1982}
1983
1986 Record.AddTemplateParameterList(D->getTemplateParameters());
1987
1989
1990 // These are read/set from/to the first declaration.
1991 if (D->getPreviousDecl() == nullptr) {
1992 Record.AddDeclRef(D->getInstantiatedFromMember());
1993 Record.push_back(D->isMemberSpecialization());
1994 }
1995
1997}
1998
2006
2010
2011 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
2012 InstFrom = D->getSpecializedTemplateOrPartial();
2013 if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
2014 Record.AddDeclRef(InstFromD);
2015 } else {
2016 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
2017 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
2018 }
2019
2024 Record.push_back(ExplicitInstantiation);
2026 Record.AddSourceLocation(D->getExternKeywordLoc());
2027 Record.AddSourceLocation(D->getTemplateKeywordLoc());
2028 }
2029
2030 const ASTTemplateArgumentListInfo *ArgsWritten =
2032 Record.push_back(!!ArgsWritten);
2033 if (ArgsWritten)
2034 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
2035
2036 Record.AddTemplateArgumentList(&D->getTemplateArgs());
2037 Record.AddSourceLocation(D->getPointOfInstantiation());
2038 Record.push_back(D->getSpecializationKind());
2039 Record.push_back(D->IsCompleteDefinition);
2040
2041 VisitVarDecl(D);
2042
2043 Record.push_back(D->isCanonicalDecl());
2044
2045 if (D->isCanonicalDecl()) {
2046 // When reading, we'll add it to the folding set of the following template.
2047 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
2048 }
2049
2051}
2052
2055 Record.AddTemplateParameterList(D->getTemplateParameters());
2056
2058
2059 // These are read/set from/to the first declaration.
2060 if (D->getPreviousDecl() == nullptr) {
2061 Record.AddDeclRef(D->getInstantiatedFromMember());
2062 Record.push_back(D->isMemberSpecialization());
2063 }
2064
2066}
2067
2075
2077 Record.push_back(D->hasTypeConstraint());
2078 VisitTypeDecl(D);
2079
2080 Record.push_back(D->wasDeclaredWithTypename());
2081
2082 const TypeConstraint *TC = D->getTypeConstraint();
2083 if (D->hasTypeConstraint())
2084 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
2085 if (TC) {
2086 auto *CR = TC->getConceptReference();
2087 Record.push_back(CR != nullptr);
2088 if (CR)
2089 Record.AddConceptReference(CR);
2090 Record.AddStmt(TC->getImmediatelyDeclaredConstraint());
2091 Record.writeUnsignedOrNone(TC->getArgPackSubstIndex());
2092 Record.writeUnsignedOrNone(D->getNumExpansionParameters());
2093 }
2094
2095 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2097 Record.push_back(OwnsDefaultArg);
2098 if (OwnsDefaultArg)
2099 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2100
2101 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
2103 !D->isInvalidDecl() && !D->hasAttrs() &&
2106 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
2107
2109}
2110
2112 // For an expanded parameter pack, record the number of expansion types here
2113 // so that it's easier for deserialization to allocate the right amount of
2114 // memory.
2115 Record.push_back(D->hasPlaceholderTypeConstraint());
2116 if (D->isExpandedParameterPack())
2117 Record.push_back(D->getNumExpansionTypes());
2118
2120 // TemplateParmPosition.
2121 Record.push_back(D->getDepth());
2122 Record.push_back(D->getPosition());
2123
2125 Record.AddStmt(D->getPlaceholderTypeConstraint());
2126
2127 if (D->isExpandedParameterPack()) {
2128 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2129 Record.AddTypeRef(D->getExpansionType(I));
2130 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2131 }
2132
2134 } else {
2135 // Rest of NonTypeTemplateParmDecl.
2136 Record.push_back(D->isParameterPack());
2137 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2139 Record.push_back(OwnsDefaultArg);
2140 if (OwnsDefaultArg)
2141 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2143 }
2144}
2145
2147 // For an expanded parameter pack, record the number of expansion types here
2148 // so that it's easier for deserialization to allocate the right amount of
2149 // memory.
2150 if (D->isExpandedParameterPack())
2151 Record.push_back(D->getNumExpansionTemplateParameters());
2152
2154 Record.push_back(D->templateParameterKind());
2155 Record.push_back(D->wasDeclaredWithTypename());
2156 // TemplateParmPosition.
2157 Record.push_back(D->getDepth());
2158 Record.push_back(D->getPosition());
2159
2160 if (D->isExpandedParameterPack()) {
2161 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2162 I != N; ++I)
2163 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2165 } else {
2166 // Rest of TemplateTemplateParmDecl.
2167 Record.push_back(D->isParameterPack());
2168 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2170 Record.push_back(OwnsDefaultArg);
2171 if (OwnsDefaultArg)
2172 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2174 }
2175}
2176
2181
2183 VisitDecl(D);
2184 Record.AddStmt(D->getAssertExpr());
2185 Record.push_back(D->isFailed());
2186 Record.AddStmt(D->getMessage());
2187 Record.AddSourceLocation(D->getRParenLoc());
2189}
2190
2191/// Emit the DeclContext part of a declaration context decl.
2193 static_assert(DeclContext::NumDeclContextBits == 13,
2194 "You need to update the serializer after you change the "
2195 "DeclContextBits");
2196 LookupBlockOffsets Offsets;
2197
2198 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2199 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2200 // In reduced BMI, delay writing lexical and visible block for namespace
2201 // in the global module fragment. See the comments of DelayedNamespace for
2202 // details.
2203 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2204 } else {
2205 Offsets.LexicalOffset =
2206 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2207 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC, Offsets);
2208 }
2209
2210 Record.AddLookupOffsets(Offsets);
2211}
2212
2214 assert(IsLocalDecl(D) && "expected a local declaration");
2215
2216 const Decl *Canon = D->getCanonicalDecl();
2217 if (IsLocalDecl(Canon))
2218 return Canon;
2219
2220 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2221 if (CacheEntry)
2222 return CacheEntry;
2223
2224 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2225 if (IsLocalDecl(Redecl))
2226 D = Redecl;
2227 return CacheEntry = D;
2228}
2229
2230template <typename T>
2232 T *First = D->getFirstDecl();
2233 T *MostRecent = First->getMostRecentDecl();
2234 T *DAsT = static_cast<T *>(D);
2235 if (MostRecent != First) {
2236 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2237 "Not considered redeclarable?");
2238
2239 Record.AddDeclRef(First);
2240
2241 // Write out a list of local redeclarations of this declaration if it's the
2242 // first local declaration in the chain.
2243 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2244 if (DAsT == FirstLocal) {
2245 // Emit a list of all imported first declarations so that we can be sure
2246 // that all redeclarations visible to this module are before D in the
2247 // redecl chain.
2248 unsigned I = Record.size();
2249 Record.push_back(0);
2250 if (Writer.Chain)
2251 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2252 // This is the number of imported first declarations + 1.
2253 Record[I] = Record.size() - I;
2254
2255 // Collect the set of local redeclarations of this declaration, from
2256 // newest to oldest.
2257 ASTWriter::RecordData LocalRedecls;
2258 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2259 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2260 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2261 if (!Prev->isFromASTFile())
2262 LocalRedeclWriter.AddDeclRef(Prev);
2263
2264 // If we have any redecls, write them now as a separate record preceding
2265 // the declaration itself.
2266 if (LocalRedecls.empty())
2267 Record.push_back(0);
2268 else
2269 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2270 } else {
2271 Record.push_back(0);
2272 Record.AddDeclRef(FirstLocal);
2273 }
2274
2275 // Make sure that we serialize both the previous and the most-recent
2276 // declarations, which (transitively) ensures that all declarations in the
2277 // chain get serialized.
2278 //
2279 // FIXME: This is not correct; when we reach an imported declaration we
2280 // won't emit its previous declaration.
2281 (void)Writer.GetDeclRef(D->getPreviousDecl());
2282 (void)Writer.GetDeclRef(MostRecent);
2283 } else {
2284 // We use the sentinel value 0 to indicate an only declaration.
2285 Record.push_back(0);
2286 }
2287}
2288
2290 VisitNamedDecl(D);
2292 Record.push_back(D->isCBuffer());
2293 Record.AddSourceLocation(D->getLocStart());
2294 Record.AddSourceLocation(D->getLBraceLoc());
2295 Record.AddSourceLocation(D->getRBraceLoc());
2296
2298}
2299
2301 Record.writeOMPChildren(D->Data);
2302 VisitDecl(D);
2304}
2305
2307 Record.writeOMPChildren(D->Data);
2308 VisitDecl(D);
2310}
2311
2313 Record.writeOMPChildren(D->Data);
2314 VisitDecl(D);
2316}
2317
2320 "You need to update the serializer after you change the "
2321 "NumOMPDeclareReductionDeclBits");
2322
2323 VisitValueDecl(D);
2324 Record.AddSourceLocation(D->getBeginLoc());
2325 Record.AddStmt(D->getCombinerIn());
2326 Record.AddStmt(D->getCombinerOut());
2327 Record.AddStmt(D->getCombiner());
2328 Record.AddStmt(D->getInitOrig());
2329 Record.AddStmt(D->getInitPriv());
2330 Record.AddStmt(D->getInitializer());
2331 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2332 Record.AddDeclRef(D->getPrevDeclInScope());
2334}
2335
2337 Record.writeOMPChildren(D->Data);
2338 VisitValueDecl(D);
2339 Record.AddDeclarationName(D->getVarName());
2340 Record.AddDeclRef(D->getPrevDeclInScope());
2342}
2343
2348
2350 Record.writeUInt32(D->clauses().size());
2351 VisitDecl(D);
2352 Record.writeEnum(D->DirKind);
2353 Record.AddSourceLocation(D->DirectiveLoc);
2354 Record.AddSourceLocation(D->EndLoc);
2355 Record.writeOpenACCClauseList(D->clauses());
2357}
2359 Record.writeUInt32(D->clauses().size());
2360 VisitDecl(D);
2361 Record.writeEnum(D->DirKind);
2362 Record.AddSourceLocation(D->DirectiveLoc);
2363 Record.AddSourceLocation(D->EndLoc);
2364 Record.AddSourceRange(D->ParensLoc);
2365 Record.AddStmt(D->FuncRef);
2366 Record.writeOpenACCClauseList(D->clauses());
2368}
2369
2370//===----------------------------------------------------------------------===//
2371// ASTWriter Implementation
2372//===----------------------------------------------------------------------===//
2373
2374namespace {
2375template <FunctionDecl::TemplatedKind Kind>
2376std::shared_ptr<llvm::BitCodeAbbrev>
2377getFunctionDeclAbbrev(serialization::DeclCode Code) {
2378 using namespace llvm;
2379
2380 auto Abv = std::make_shared<BitCodeAbbrev>();
2381 Abv->Add(BitCodeAbbrevOp(Code));
2382 // RedeclarableDecl
2383 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2384 Abv->Add(BitCodeAbbrevOp(Kind));
2385 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2386
2387 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2388 // DescribedFunctionTemplate
2389 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2390 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2391 // Instantiated From Decl
2392 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2393 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2394 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2395 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2396 3)); // TemplateSpecializationKind
2397 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2398 } else if constexpr (Kind ==
2400 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2401 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2402 3)); // TemplateSpecializationKind
2403 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2404 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2405 Abv->Add(
2406 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2407 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2408 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2409 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2410 Abv->Add(BitCodeAbbrevOp(0));
2411 Abv->Add(
2412 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2413 } else if constexpr (Kind == FunctionDecl::
2414 TK_DependentFunctionTemplateSpecialization) {
2415 // Candidates of specialization
2416 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2417 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2418 } else {
2419 llvm_unreachable("Unknown templated kind?");
2420 }
2421 // Decl
2422 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2423 8)); // Packed DeclBits: ModuleOwnershipKind,
2424 // isUsed, isReferenced, AccessSpecifier,
2425 // isImplicit
2426 //
2427 // The following bits should be 0:
2428 // HasStandaloneLexicalDC, HasAttrs,
2429 // TopLevelDeclInObjCContainer,
2430 // isInvalidDecl
2431 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2432 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2433 // NamedDecl
2434 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2435 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2436 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2437 // ValueDecl
2438 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2439 // DeclaratorDecl
2440 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2441 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2442 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2443 // FunctionDecl
2444 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2445 Abv->Add(BitCodeAbbrevOp(
2446 BitCodeAbbrevOp::Fixed,
2447 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2448 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2449 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2450 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2451 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2452 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2453 // ShouldSkipCheckingODR
2454 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2455 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2456 // This Array slurps the rest of the record. Fortunately we want to encode
2457 // (nearly) all the remaining (variable number of) fields in the same way.
2458 //
2459 // This is:
2460 // NumParams and Params[] from FunctionDecl, and
2461 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2462 //
2463 // Add an AbbrevOp for 'size then elements' and use it here.
2464 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2465 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2466 return Abv;
2467}
2468
2469template <FunctionDecl::TemplatedKind Kind>
2470std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2471 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2472}
2473} // namespace
2474
2475void ASTWriter::WriteDeclAbbrevs() {
2476 using namespace llvm;
2477
2478 std::shared_ptr<BitCodeAbbrev> Abv;
2479
2480 // Abbreviation for DECL_FIELD
2481 Abv = std::make_shared<BitCodeAbbrev>();
2482 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2483 // Decl
2484 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2485 7)); // Packed DeclBits: ModuleOwnershipKind,
2486 // isUsed, isReferenced, AccessSpecifier,
2487 //
2488 // The following bits should be 0:
2489 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2490 // TopLevelDeclInObjCContainer,
2491 // isInvalidDecl
2492 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2493 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2494 // NamedDecl
2495 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2496 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2497 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2498 // ValueDecl
2499 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2500 // DeclaratorDecl
2501 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2502 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2503 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2504 // FieldDecl
2505 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2506 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2507 // Type Source Info
2508 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2509 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2510 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2511
2512 // Abbreviation for DECL_OBJC_IVAR
2513 Abv = std::make_shared<BitCodeAbbrev>();
2514 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2515 // Decl
2516 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2517 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2518 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2519 // isReferenced, TopLevelDeclInObjCContainer,
2520 // AccessSpecifier, ModuleOwnershipKind
2521 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2522 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2523 // NamedDecl
2524 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2525 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2526 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2527 // ValueDecl
2528 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2529 // DeclaratorDecl
2530 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2531 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2532 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2533 // FieldDecl
2534 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2535 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2536 // ObjC Ivar
2537 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2538 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2539 // Type Source Info
2540 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2541 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2542 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2543
2544 // Abbreviation for DECL_ENUM
2545 Abv = std::make_shared<BitCodeAbbrev>();
2546 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2547 // Redeclarable
2548 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2549 // Decl
2550 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2551 7)); // Packed DeclBits: ModuleOwnershipKind,
2552 // isUsed, isReferenced, AccessSpecifier,
2553 //
2554 // The following bits should be 0:
2555 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2556 // TopLevelDeclInObjCContainer,
2557 // isInvalidDecl
2558 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2559 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2560 // NamedDecl
2561 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2562 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2563 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2564 // TypeDecl
2565 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2566 // TagDecl
2567 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2568 Abv->Add(BitCodeAbbrevOp(
2569 BitCodeAbbrevOp::Fixed,
2570 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2571 // EmbeddedInDeclarator, IsFreeStanding,
2572 // isCompleteDefinitionRequired, ExtInfoKind
2573 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2574 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2575 // EnumDecl
2576 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2577 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2578 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2579 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2580 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2581 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2582 // DC
2583 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2584 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2585 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2586 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2587 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2588
2589 // Abbreviation for DECL_RECORD
2590 Abv = std::make_shared<BitCodeAbbrev>();
2591 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2592 // Redeclarable
2593 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2594 // Decl
2595 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2596 7)); // Packed DeclBits: ModuleOwnershipKind,
2597 // isUsed, isReferenced, AccessSpecifier,
2598 //
2599 // The following bits should be 0:
2600 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2601 // TopLevelDeclInObjCContainer,
2602 // isInvalidDecl
2603 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2604 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2605 // NamedDecl
2606 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2607 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2608 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2609 // TypeDecl
2610 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2611 // TagDecl
2612 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2613 Abv->Add(BitCodeAbbrevOp(
2614 BitCodeAbbrevOp::Fixed,
2615 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2616 // EmbeddedInDeclarator, IsFreeStanding,
2617 // isCompleteDefinitionRequired, ExtInfoKind
2618 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2619 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2620 // RecordDecl
2621 Abv->Add(BitCodeAbbrevOp(
2622 BitCodeAbbrevOp::Fixed,
2623 14)); // Packed Record Decl Bits: FlexibleArrayMember,
2624 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2625 // isNonTrivialToPrimitiveDefaultInitialize,
2626 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2627 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2628 // hasNonTrivialToPrimitiveDestructCUnion,
2629 // hasNonTrivialToPrimitiveCopyCUnion,
2630 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2631 // getArgPassingRestrictions
2632 // ODRHash
2633 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2634
2635 // DC
2636 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2637 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2638 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2639 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2640 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2641
2642 // Abbreviation for DECL_PARM_VAR
2643 Abv = std::make_shared<BitCodeAbbrev>();
2644 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2645 // Redeclarable
2646 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2647 // Decl
2648 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2649 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2650 // isReferenced, AccessSpecifier,
2651 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2652 // TopLevelDeclInObjCContainer,
2653 // isInvalidDecl,
2654 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2655 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2656 // NamedDecl
2657 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2658 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2659 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2660 // ValueDecl
2661 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2662 // DeclaratorDecl
2663 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2664 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2665 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2666 // VarDecl
2667 Abv->Add(
2668 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2669 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2670 // isARCPseudoStrong, Linkage, ModulesCodegen
2671 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2672 // ParmVarDecl
2673 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2674 Abv->Add(BitCodeAbbrevOp(
2675 BitCodeAbbrevOp::Fixed,
2676 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2677 // ObjCDeclQualifier, KNRPromoted,
2678 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2679 // Type Source Info
2680 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2681 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2682 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2683
2684 // Abbreviation for DECL_TYPEDEF
2685 Abv = std::make_shared<BitCodeAbbrev>();
2686 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2687 // Redeclarable
2688 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2689 // Decl
2690 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2691 7)); // Packed DeclBits: ModuleOwnershipKind,
2692 // isReferenced, isUsed, AccessSpecifier. Other
2693 // higher bits should be 0: isImplicit,
2694 // HasStandaloneLexicalDC, HasAttrs,
2695 // TopLevelDeclInObjCContainer, isInvalidDecl
2696 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2697 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2698 // NamedDecl
2699 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2700 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2701 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2702 // TypeDecl
2703 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2704 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2705 // TypedefDecl
2706 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2707 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2708 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2709
2710 // Abbreviation for DECL_VAR
2711 Abv = std::make_shared<BitCodeAbbrev>();
2712 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2713 // Redeclarable
2714 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2715 // Decl
2716 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2717 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2718 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2719 // isReferenced, TopLevelDeclInObjCContainer,
2720 // AccessSpecifier, ModuleOwnershipKind
2721 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2722 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2723 // NamedDecl
2724 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2725 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2726 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2727 // ValueDecl
2728 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2729 // DeclaratorDecl
2730 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2731 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2732 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2733 // VarDecl
2734 Abv->Add(BitCodeAbbrevOp(
2735 BitCodeAbbrevOp::Fixed,
2736 22)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2737 // SClass, TSCSpec, InitStyle,
2738 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2739 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2740 // isInline, isInlineSpecified, isConstexpr,
2741 // isInitCapture, isPrevDeclInSameScope, hasInitWithSideEffects,
2742 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2743 // IsCXXForRangeImplicitVar
2744 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2745 // Type Source Info
2746 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2747 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2748 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2749
2750 // Abbreviation for DECL_CXX_METHOD
2751 DeclCXXMethodAbbrev =
2752 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2753 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2754 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2755 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2756 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2757 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2758 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2759 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2760 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2761 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2762 getCXXMethodAbbrev<
2764
2765 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2766 Abv = std::make_shared<BitCodeAbbrev>();
2767 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2768 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2769 // Decl
2770 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2771 7)); // Packed DeclBits: ModuleOwnershipKind,
2772 // isReferenced, isUsed, AccessSpecifier. Other
2773 // higher bits should be 0: isImplicit,
2774 // HasStandaloneLexicalDC, HasAttrs,
2775 // TopLevelDeclInObjCContainer, isInvalidDecl
2776 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2777 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2778 // NamedDecl
2779 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2780 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2781 Abv->Add(BitCodeAbbrevOp(0));
2782 // TypeDecl
2783 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2784 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2785 // TemplateTypeParmDecl
2786 Abv->Add(
2787 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2788 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2789 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2790
2791 // Abbreviation for DECL_USING_SHADOW
2792 Abv = std::make_shared<BitCodeAbbrev>();
2793 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2794 // Redeclarable
2795 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2796 // Decl
2797 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2798 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2799 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2800 // isReferenced, TopLevelDeclInObjCContainer,
2801 // AccessSpecifier, ModuleOwnershipKind
2802 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2803 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2804 // NamedDecl
2805 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2806 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2807 Abv->Add(BitCodeAbbrevOp(0));
2808 // UsingShadowDecl
2809 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2810 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2811 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2812 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2813 6)); // InstantiatedFromUsingShadowDecl
2814 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2815
2816 // Abbreviation for EXPR_DECL_REF
2817 Abv = std::make_shared<BitCodeAbbrev>();
2818 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2819 // Stmt
2820 // Expr
2821 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2822 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2823 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2824 // DeclRefExpr
2825 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2826 // IsImmediateEscalating, NonOdrUseReason.
2827 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2828 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2829 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2830 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2831 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2832
2833 // Abbreviation for EXPR_INTEGER_LITERAL
2834 Abv = std::make_shared<BitCodeAbbrev>();
2835 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2836 //Stmt
2837 // Expr
2838 // DependenceKind, ValueKind, ObjectKind
2839 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2840 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2841 // Integer Literal
2842 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2843 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2844 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2845 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2846
2847 // Abbreviation for EXPR_CHARACTER_LITERAL
2848 Abv = std::make_shared<BitCodeAbbrev>();
2849 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2850 //Stmt
2851 // Expr
2852 // DependenceKind, ValueKind, ObjectKind
2853 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2854 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2855 // Character Literal
2856 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2857 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2858 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2859 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2860
2861 // Abbreviation for EXPR_IMPLICIT_CAST
2862 Abv = std::make_shared<BitCodeAbbrev>();
2863 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2864 // Stmt
2865 // Expr
2866 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2867 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2868 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2869 // CastExpr
2870 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2871 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2872 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2873 // ImplicitCastExpr
2874 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2875
2876 // Abbreviation for EXPR_BINARY_OPERATOR
2877 Abv = std::make_shared<BitCodeAbbrev>();
2878 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2879 // Stmt
2880 // Expr
2881 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2882 // be 0 in this case.
2883 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2884 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2885 // BinaryOperator
2886 Abv->Add(
2887 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2888 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2889 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2890
2891 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2892 Abv = std::make_shared<BitCodeAbbrev>();
2893 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2894 // Stmt
2895 // Expr
2896 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2897 // be 0 in this case.
2898 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2899 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2900 // BinaryOperator
2901 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2902 Abv->Add(
2903 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2904 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2905 // CompoundAssignOperator
2906 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2907 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2908 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2909
2910 // Abbreviation for EXPR_CALL
2911 Abv = std::make_shared<BitCodeAbbrev>();
2912 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2913 // Stmt
2914 // Expr
2915 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2916 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2917 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2918 // CallExpr
2919 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2920 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2921 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2922 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2923
2924 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2925 Abv = std::make_shared<BitCodeAbbrev>();
2926 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2927 // Stmt
2928 // Expr
2929 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2930 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2931 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2932 // CallExpr
2933 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2934 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2935 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2936 // CXXOperatorCallExpr
2937 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
2938 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2939 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2940
2941 // Abbreviation for EXPR_CXX_MEMBER_CALL
2942 Abv = std::make_shared<BitCodeAbbrev>();
2943 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
2944 // Stmt
2945 // Expr
2946 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2947 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2948 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2949 // CallExpr
2950 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2951 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2952 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2953 // CXXMemberCallExpr
2954 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2955
2956 // Abbreviation for STMT_COMPOUND
2957 Abv = std::make_shared<BitCodeAbbrev>();
2958 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
2959 // Stmt
2960 // CompoundStmt
2961 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
2962 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
2963 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2964 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2965 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
2966
2967 Abv = std::make_shared<BitCodeAbbrev>();
2968 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2969 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2970 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2971
2972 Abv = std::make_shared<BitCodeAbbrev>();
2973 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2974 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2975 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2976
2977 Abv = std::make_shared<BitCodeAbbrev>();
2978 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
2979 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2980 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2981
2982 Abv = std::make_shared<BitCodeAbbrev>();
2983 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
2984 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2985 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2986
2987 Abv = std::make_shared<BitCodeAbbrev>();
2988 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
2989 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2990 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2991
2992 Abv = std::make_shared<BitCodeAbbrev>();
2993 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
2994 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2995 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2996}
2997
2998/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2999/// consumers of the AST.
3000///
3001/// Such decls will always be deserialized from the AST file, so we would like
3002/// this to be as restrictive as possible. Currently the predicate is driven by
3003/// code generation requirements, if other clients have a different notion of
3004/// what is "required" then we may have to consider an alternate scheme where
3005/// clients can iterate over the top-level decls and get information on them,
3006/// without necessary deserializing them. We could explicitly require such
3007/// clients to use a separate API call to "realize" the decl. This should be
3008/// relatively painless since they would presumably only do it for top-level
3009/// decls.
3010static bool isRequiredDecl(const Decl *D, ASTContext &Context,
3011 Module *WritingModule) {
3012 // Named modules have different semantics than header modules. Every named
3013 // module units owns a translation unit. So the importer of named modules
3014 // doesn't need to deserilize everything ahead of time.
3015 if (WritingModule && WritingModule->isNamedModule()) {
3016 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
3017 // And the behavior of MSVC for such cases will leak this to the module
3018 // users. Given pragma is not a standard thing, the compiler has the space
3019 // to do their own decision. Let's follow MSVC here.
3021 return true;
3022 return false;
3023 }
3024
3025 // An ObjCMethodDecl is never considered as "required" because its
3026 // implementation container always is.
3027
3028 // File scoped assembly or obj-c or OMP declare target implementation must be
3029 // seen.
3031 return true;
3032
3033 if (WritingModule && isPartOfPerModuleInitializer(D)) {
3034 // These declarations are part of the module initializer, and are emitted
3035 // if and when the module is imported, rather than being emitted eagerly.
3036 return false;
3037 }
3038
3039 return Context.DeclMustBeEmitted(D);
3040}
3041
3042void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
3043 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
3044 "serializing");
3045
3046 // Determine the ID for this declaration.
3047 LocalDeclID ID;
3048 assert(!D->isFromASTFile() && "should not be emitting imported decl");
3049 LocalDeclID &IDR = DeclIDs[D];
3050 if (IDR.isInvalid())
3051 IDR = NextDeclID++;
3052
3053 ID = IDR;
3054
3055 assert(ID >= FirstDeclID && "invalid decl ID");
3056
3058 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
3059
3060 // Build a record for this declaration
3061 W.Visit(D);
3062
3063 // Emit this declaration to the bitstream.
3064 uint64_t Offset = W.Emit(D);
3065
3066 // Record the offset for this declaration
3067 SourceLocation Loc = D->getLocation();
3069 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
3070
3071 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
3072 if (DeclOffsets.size() == Index)
3073 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
3074 else if (DeclOffsets.size() < Index) {
3075 // FIXME: Can/should this happen?
3076 DeclOffsets.resize(Index+1);
3077 DeclOffsets[Index].setRawLoc(RawLoc);
3078 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
3079 } else {
3080 llvm_unreachable("declarations should be emitted in ID order");
3081 }
3082
3083 SourceManager &SM = Context.getSourceManager();
3084 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
3085 associateDeclWithFile(D, ID);
3086
3087 // Note declarations that should be deserialized eagerly so that we can add
3088 // them to a record in the AST file later.
3089 if (isRequiredDecl(D, Context, WritingModule))
3090 AddDeclRef(D, EagerlyDeserializedDecls);
3091}
3092
3094 // Switch case IDs are per function body.
3095 Writer->ClearSwitchCaseIDs();
3096
3097 assert(FD->doesThisDeclarationHaveABody());
3098 bool ModulesCodegen = shouldFunctionGenerateHereOnly(FD);
3099 Record->push_back(ModulesCodegen);
3100 if (ModulesCodegen)
3101 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3102 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3103 Record->push_back(CD->getNumCtorInitializers());
3104 if (CD->getNumCtorInitializers())
3105 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3106 }
3107 AddStmt(FD->getBody());
3108}
static void addExplicitSpecifier(ExplicitSpecifier ES, ASTRecordWriter &Record)
static bool shouldVarGenerateHereOnly(const VarDecl *VD)
static bool shouldFunctionGenerateHereOnly(const FunctionDecl *FD)
static bool isRequiredDecl(const Decl *D, ASTContext &Context, Module *WritingModule)
isRequiredDecl - Check if this is a "required" Decl, which must be seen by consumers of the AST.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
llvm::MachO::Record Record
Definition MachO.h:31
#define SM(sm)
This file defines OpenMP AST classes for clauses.
Defines the SourceManager interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:220
SourceManager & getSourceManager()
Definition ASTContext.h:833
const LangOptions & getLangOpts() const
Definition ASTContext.h:926
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:4185
Expr * getBinding() const
Get the expression to which this declaration is bound.
Definition DeclCXX.h:4211
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
Definition ASTWriter.h:1065
void addBit(bool Value)
Definition ASTWriter.h:1085
void addBits(uint32_t Value, uint32_t BitsWidth)
Definition ASTWriter.h:1086
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4651
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition Decl.h:4774
bool canAvoidCopyToHeap() const
Definition Decl.h:4805
size_t param_size() const
Definition Decl.h:4753
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:4730
ArrayRef< Capture > captures() const
Definition Decl.h:4778
bool blockMissingReturnType() const
Definition Decl.h:4786
bool capturesCXXThis() const
Definition Decl.h:4783
bool doesNotEscape() const
Definition Decl.h:4802
bool isConversionFromLambda() const
Definition Decl.h:4794
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:4737
bool isVariadic() const
Definition Decl.h:4726
TypeSourceInfo * getSignatureAsWritten() const
Definition Decl.h:4734
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:2943
ExplicitSpecifier getExplicitSpecifier()
Definition DeclCXX.h:2970
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:2904
const FunctionDecl * getOperatorGlobalDelete() const
Definition DeclCXX.h:2908
Expr * getOperatorDeleteThisArg() const
Definition DeclCXX.h:2912
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:4923
unsigned getNumParams() const
Definition Decl.h:4961
unsigned getContextParamPosition() const
Definition Decl.h:4990
bool isNothrow() const
Definition Decl.cpp:5573
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4963
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:3677
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:4249
ArrayRef< BindingDecl * > bindings() const
Definition DeclCXX.h:4287
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:5158
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:5111
SourceLocation getRBraceLoc() const
Definition Decl.h:5130
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:4599
SourceLocation getRParenLoc() const
Definition Decl.h:4593
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:5173
bool isCBuffer() const
Definition Decl.h:5217
SourceLocation getLBraceLoc() const
Definition Decl.h:5214
SourceLocation getLocStart() const LLVM_READONLY
Definition Decl.h:5213
SourceLocation getRBraceLoc() const
Definition Decl.h:5215
ArrayRef< TemplateArgument > getTemplateArguments() const
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition Decl.h:5032
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:5942
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition Decl.h:5090
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:3308
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
Definition DeclCXX.h:3354
Represents a linkage specification.
Definition DeclCXX.h:3015
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition DeclCXX.h:3038
SourceLocation getExternLoc() const
Definition DeclCXX.h:3054
SourceLocation getRBraceLoc() const
Definition DeclCXX.h:3055
A global _GUID constant.
Definition DeclCXX.h:4398
Parts getParts() const
Get the decomposed parts of this declaration.
Definition DeclCXX.h:4428
MSGuidDeclParts Parts
Definition DeclCXX.h:4400
An instance of this class represents the declaration of a property member.
Definition DeclCXX.h:4344
IdentifierInfo * getGetterId() const
Definition DeclCXX.h:4366
IdentifierInfo * getSetterId() const
Definition DeclCXX.h:4368
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:3201
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3262
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3287
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition DeclCXX.h:3290
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition DeclCXX.h:3271
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:536
Pseudo declaration for capturing expressions.
Definition DeclOpenMP.h:445
OMPChildren * Data
Data, associated with the directive.
Definition DeclOpenMP.h:43
This represents 'pragma omp declare mapper ...' directive.
Definition DeclOpenMP.h:349
OMPDeclareMapperDecl * getPrevDeclInScope()
Get reference to previous declare mapper construct in the same scope with the same name.
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
Definition DeclOpenMP.h:421
This represents 'pragma omp declare reduction ...' directive.
Definition DeclOpenMP.h:239
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Definition DeclOpenMP.h:300
Expr * getInitPriv()
Get Priv variable of the initializer.
Definition DeclOpenMP.h:311
Expr * getCombinerOut()
Get Out variable of the combiner.
Definition DeclOpenMP.h:288
Expr * getCombinerIn()
Get In variable of the combiner.
Definition DeclOpenMP.h:285
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
Definition DeclOpenMP.h:282
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name.
Expr * getInitOrig()
Get Orig variable of the initializer.
Definition DeclOpenMP.h:308
OMPDeclareReductionInitKind getInitializerKind() const
Get initializer kind.
Definition DeclOpenMP.h:303
This represents 'pragma omp requires...' directive.
Definition DeclOpenMP.h:479
This represents 'pragma omp threadprivate ...' directive.
Definition DeclOpenMP.h:110
Represents a field declaration created by an @defs(...).
Definition DeclObjC.h:2030
static bool classofKind(Kind K)
Definition DeclObjC.h:2051
ObjCCategoryDecl - Represents a category declaration.
Definition DeclObjC.h:2329
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:2417
unsigned protocol_size() const
Definition DeclObjC.h:2412
ObjCInterfaceDecl * getClassInterface()
Definition DeclObjC.h:2372
SourceLocation getIvarLBraceLoc() const
Definition DeclObjC.h:2464
SourceLocation getIvarRBraceLoc() const
Definition DeclObjC.h:2466
protocol_range protocols() const
Definition DeclObjC.h:2403
SourceLocation getCategoryNameLoc() const
Definition DeclObjC.h:2460
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition DeclObjC.h:2545
SourceLocation getCategoryNameLoc() const
Definition DeclObjC.h:2572
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition DeclObjC.h:2775
const ObjCInterfaceDecl * getClassInterface() const
Definition DeclObjC.h:2793
ObjCContainerDecl - Represents a container for method declarations.
Definition DeclObjC.h:948
SourceRange getAtEndRange() const
Definition DeclObjC.h:1103
SourceLocation getAtStartLoc() const
Definition DeclObjC.h:1096
const ObjCInterfaceDecl * getClassInterface() const
Definition DeclObjC.h:2486
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition DeclObjC.h:2597
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition DeclObjC.h:2678
SourceLocation getIvarRBraceLoc() const
Definition DeclObjC.h:2744
bool hasNonZeroConstructors() const
Do any of the ivars of this class (not counting its base classes) require construction other than zer...
Definition DeclObjC.h:2702
SourceLocation getSuperClassLoc() const
Definition DeclObjC.h:2737
bool hasDestructors() const
Do any of the ivars of this class (not counting its base classes) require non-trivial destruction?
Definition DeclObjC.h:2707
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition DeclObjC.h:2669
const ObjCInterfaceDecl * getSuperClass() const
Definition DeclObjC.h:2735
SourceLocation getIvarLBraceLoc() const
Definition DeclObjC.h:2742
Represents an ObjC class declaration.
Definition DeclObjC.h:1154
protocol_range protocols() const
Definition DeclObjC.h:1359
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition DeclObjC.cpp:788
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:1388
ObjCCategoryDecl * getCategoryListRaw() const
Retrieve the raw pointer to the start of the category/extension list.
Definition DeclObjC.h:1785
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition DeclObjC.h:1523
const Type * getTypeForDecl() const
Definition DeclObjC.h:1919
SourceLocation getEndOfDefinitionLoc() const
Definition DeclObjC.h:1878
TypeSourceInfo * getSuperClassTInfo() const
Definition DeclObjC.h:1573
ObjCIvarDecl - Represents an ObjC instance variable.
Definition DeclObjC.h:1952
AccessControl getAccessControl() const
Definition DeclObjC.h:2000
bool getSynthesize() const
Definition DeclObjC.h:2007
static bool classofKind(Kind K)
Definition DeclObjC.h:2015
T *const * iterator
Definition DeclObjC.h:88
ObjCMethodDecl - Represents an instance or class method declaration.
Definition DeclObjC.h:140
ImplicitParamDecl * getSelfDecl() const
Definition DeclObjC.h:418
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
Definition DeclObjC.h:462
ObjCDeclQualifier getObjCDeclQualifier() const
Definition DeclObjC.h:246
ArrayRef< ParmVarDecl * > parameters() const
Definition DeclObjC.h:373
unsigned param_size() const
Definition DeclObjC.h:347
bool isPropertyAccessor() const
Definition DeclObjC.h:436
bool isVariadic() const
Definition DeclObjC.h:431
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition DeclObjC.cpp:906
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition DeclObjC.h:343
bool hasRedeclaration() const
True if redeclared in the same interface.
Definition DeclObjC.h:271
bool isSynthesizedAccessorStub() const
Definition DeclObjC.h:444
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
Definition DeclObjC.h:256
bool isRedeclaration() const
True if this is a method redeclaration in the same interface.
Definition DeclObjC.h:266
ImplicitParamDecl * getCmdDecl() const
Definition DeclObjC.h:420
bool isInstanceMethod() const
Definition DeclObjC.h:426
bool isDefined() const
Definition DeclObjC.h:452
QualType getReturnType() const
Definition DeclObjC.h:329
ObjCImplementationControl getImplementationControl() const
Definition DeclObjC.h:500
bool hasSkippedBody() const
True if the method was a definition but its body was skipped.
Definition DeclObjC.h:477
Represents one property declaration in an Objective-C interface.
Definition DeclObjC.h:731
SourceLocation getGetterNameLoc() const
Definition DeclObjC.h:886
ObjCMethodDecl * getGetterMethodDecl() const
Definition DeclObjC.h:901
ObjCMethodDecl * getSetterMethodDecl() const
Definition DeclObjC.h:904
SourceLocation getSetterNameLoc() const
Definition DeclObjC.h:894
SourceLocation getAtLoc() const
Definition DeclObjC.h:796
ObjCIvarDecl * getPropertyIvarDecl() const
Definition DeclObjC.h:924
Selector getSetterName() const
Definition DeclObjC.h:893
TypeSourceInfo * getTypeSourceInfo() const
Definition DeclObjC.h:802
QualType getType() const
Definition DeclObjC.h:804
Selector getGetterName() const
Definition DeclObjC.h:885
SourceLocation getLParenLoc() const
Definition DeclObjC.h:799
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
Definition DeclObjC.h:827
ObjCPropertyAttribute::Kind getPropertyAttributes() const
Definition DeclObjC.h:815
PropertyControl getPropertyImplementation() const
Definition DeclObjC.h:912
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition DeclObjC.h:2805
ObjCIvarDecl * getPropertyIvarDecl() const
Definition DeclObjC.h:2879
SourceLocation getPropertyIvarDeclLoc() const
Definition DeclObjC.h:2882
Expr * getSetterCXXAssignment() const
Definition DeclObjC.h:2915
ObjCPropertyDecl * getPropertyDecl() const
Definition DeclObjC.h:2870
Expr * getGetterCXXConstructor() const
Definition DeclObjC.h:2907
ObjCMethodDecl * getSetterMethodDecl() const
Definition DeclObjC.h:2904
SourceLocation getBeginLoc() const LLVM_READONLY
Definition DeclObjC.h:2867
ObjCMethodDecl * getGetterMethodDecl() const
Definition DeclObjC.h:2901
Represents an Objective-C protocol declaration.
Definition DeclObjC.h:2084
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition DeclObjC.h:2261
protocol_loc_range protocol_locs() const
Definition DeclObjC.h:2182
protocol_range protocols() const
Definition DeclObjC.h:2161
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
unsigned protocol_size() const
Definition DeclObjC.h:2200
Represents the declaration of an Objective-C type parameter.
Definition DeclObjC.h:578
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition DeclObjC.h:662
unsigned size() const
Determine the number of type parameters in this list.
Definition DeclObjC.h:689
SourceLocation getRAngleLoc() const
Definition DeclObjC.h:711
SourceLocation getLAngleLoc() const
Definition DeclObjC.h:710
ArrayRef< const OpenACCClause * > clauses() const
Definition DeclOpenACC.h:62
Represents a partial function definition.
Definition Decl.h:4858
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:4890
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:5544
unsigned getNumParams() const
Definition Decl.h:4888
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:5290
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:4136
bool isFailed() const
Definition DeclCXX.h:4165
SourceLocation getRParenLoc() const
Definition DeclCXX.h:4167
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
Represents the declaration of a struct/union/class/enum.
Definition Decl.h: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:4614
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:5642
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition DeclCXX.h:4455
const APValue & getValue() const
Definition DeclCXX.h:4481
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition DeclCXX.h:4118
Represents a dependent using declaration which was marked with typename.
Definition DeclCXX.h:4037
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Definition DeclCXX.h:4067
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:4071
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:4088
Represents a dependent using declaration which was not marked with typename.
Definition DeclCXX.h:3940
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
Definition DeclCXX.h:3971
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3981
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition DeclCXX.h:3998
Represents a C++ using-declaration.
Definition DeclCXX.h:3591
bool hasTypename() const
Return true if the using declaration has 'typename'.
Definition DeclCXX.h:3640
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition DeclCXX.h:3625
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Definition DeclCXX.h:3618
Represents C++ using-directive.
Definition DeclCXX.h:3096
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition DeclCXX.h:3167
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition DeclCXX.cpp:3244
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition DeclCXX.h:3163
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition DeclCXX.h:3171
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition DeclCXX.h:3141
Represents a C++ using-enum-declaration.
Definition DeclCXX.h:3792
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
Definition DeclCXX.h:3816
TypeSourceInfo * getEnumType() const
Definition DeclCXX.h:3828
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Definition DeclCXX.h:3812
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition DeclCXX.h:3873
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
Definition DeclCXX.h:3902
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Definition DeclCXX.h:3906
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition DeclCXX.h:3399
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:3463
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:93
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:582
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:6604
Data that is common to all of the declarations of a given function template.
uint16_t Part2
...-89ab-...
Definition DeclCXX.h:4377
uint32_t Part1
{01234567-...
Definition DeclCXX.h:4375
uint16_t Part3
...-cdef-...
Definition DeclCXX.h:4379
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition DeclCXX.h:4381
static DeclType * getDecl(EntryType *D)