clang 20.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"
26#include <optional>
27using namespace clang;
28using namespace serialization;
29
30//===----------------------------------------------------------------------===//
31// Declaration serialization
32//===----------------------------------------------------------------------===//
33
34namespace clang {
35 class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
36 ASTWriter &Writer;
38
40 unsigned AbbrevToUse;
41
42 bool GeneratingReducedBMI = false;
43
44 public:
46 ASTWriter::RecordDataImpl &Record, bool GeneratingReducedBMI)
47 : Writer(Writer), Record(Context, Writer, Record),
48 Code((serialization::DeclCode)0), AbbrevToUse(0),
49 GeneratingReducedBMI(GeneratingReducedBMI) {}
50
51 uint64_t Emit(Decl *D) {
52 if (!Code)
53 llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
54 D->getDeclKindName() + "'");
55 return Record.Emit(Code, AbbrevToUse);
56 }
57
58 void Visit(Decl *D);
59
60 void VisitDecl(Decl *D);
65 void VisitLabelDecl(LabelDecl *LD);
75 void VisitTagDecl(TagDecl *D);
103 void VisitVarDecl(VarDecl *D);
140 template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
142
143 // FIXME: Put in the same order is DeclNodes.td?
164
165 /// Add an Objective-C type parameter list to the given record.
167 // Empty type parameter list.
168 if (!typeParams) {
169 Record.push_back(0);
170 return;
171 }
172
173 Record.push_back(typeParams->size());
174 for (auto *typeParam : *typeParams) {
175 Record.AddDeclRef(typeParam);
176 }
177 Record.AddSourceLocation(typeParams->getLAngleLoc());
178 Record.AddSourceLocation(typeParams->getRAngleLoc());
179 }
180
181 /// Collect the first declaration from each module file that provides a
182 /// declaration of D.
184 const Decl *D, bool IncludeLocal,
185 llvm::MapVector<ModuleFile *, const Decl *> &Firsts) {
186
187 // FIXME: We can skip entries that we know are implied by others.
188 for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
189 if (R->isFromASTFile())
190 Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
191 else if (IncludeLocal)
192 Firsts[nullptr] = R;
193 }
194 }
195
196 /// Add to the record the first declaration from each module file that
197 /// provides a declaration of D. The intent is to provide a sufficient
198 /// set such that reloading this set will load all current redeclarations.
199 void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
200 llvm::MapVector<ModuleFile *, const Decl *> Firsts;
201 CollectFirstDeclFromEachModule(D, IncludeLocal, Firsts);
202
203 for (const auto &F : Firsts)
204 Record.AddDeclRef(F.second);
205 }
206
207 /// Add to the record the first template specialization from each module
208 /// file that provides a declaration of D. We store the DeclId and an
209 /// ODRHash of the template arguments of D which should provide enough
210 /// information to load D only if the template instantiator needs it.
212 const Decl *D, llvm::SmallVectorImpl<const Decl *> &SpecsInMap,
213 llvm::SmallVectorImpl<const Decl *> &PartialSpecsInMap) {
214 assert((isa<ClassTemplateSpecializationDecl>(D) ||
215 isa<VarTemplateSpecializationDecl>(D) || isa<FunctionDecl>(D)) &&
216 "Must not be called with other decls");
217 llvm::MapVector<ModuleFile *, const Decl *> Firsts;
218 CollectFirstDeclFromEachModule(D, /*IncludeLocal*/ true, Firsts);
219
220 for (const auto &F : Firsts) {
223 PartialSpecsInMap.push_back(F.second);
224 else
225 SpecsInMap.push_back(F.second);
226 }
227 }
228
229 /// Get the specialization decl from an entry in the specialization list.
230 template <typename EntryType>
234 }
235
236 /// Get the list of partial specializations from a template's common ptr.
237 template<typename T>
238 decltype(T::PartialSpecializations) &getPartialSpecializations(T *Common) {
239 return Common->PartialSpecializations;
240 }
243 return std::nullopt;
244 }
245
246 template<typename DeclTy>
248 auto *Common = D->getCommonPtr();
249
250 // If we have any lazy specializations, and the external AST source is
251 // our chained AST reader, we can just write out the DeclIDs. Otherwise,
252 // we need to resolve them to actual declarations.
253 if (Writer.Chain != Record.getASTContext().getExternalSource() &&
254 Writer.Chain && Writer.Chain->haveUnloadedSpecializations(D)) {
255 D->LoadLazySpecializations();
256 assert(!Writer.Chain->haveUnloadedSpecializations(D));
257 }
258
259 // AddFirstSpecializationDeclFromEachModule might trigger deserialization,
260 // invalidating *Specializations iterators.
262 for (auto &Entry : Common->Specializations)
263 AllSpecs.push_back(getSpecializationDecl(Entry));
264 for (auto &Entry : getPartialSpecializations(Common))
265 AllSpecs.push_back(getSpecializationDecl(Entry));
266
269 for (auto *D : AllSpecs) {
270 assert(D->isCanonicalDecl() && "non-canonical decl in set");
271 AddFirstSpecializationDeclFromEachModule(D, Specs, PartialSpecs);
272 }
273
274 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
275 D, Specs, /*IsPartial=*/false));
276
277 // Function Template Decl doesn't have partial decls.
278 if (isa<FunctionTemplateDecl>(D)) {
279 assert(PartialSpecs.empty());
280 return;
281 }
282
283 Record.AddOffset(Writer.WriteSpecializationInfoLookupTable(
284 D, PartialSpecs, /*IsPartial=*/true));
285 }
286
287 /// Ensure that this template specialization is associated with the specified
288 /// template on reload.
290 const Decl *Specialization) {
291 Template = Template->getCanonicalDecl();
292
293 // If the canonical template is local, we'll write out this specialization
294 // when we emit it.
295 // FIXME: We can do the same thing if there is any local declaration of
296 // the template, to avoid emitting an update record.
297 if (!Template->isFromASTFile())
298 return;
299
300 // We only need to associate the first local declaration of the
301 // specialization. The other declarations will get pulled in by it.
303 return;
304
307 Writer.PartialSpecializationsUpdates[cast<NamedDecl>(Template)]
308 .push_back(cast<NamedDecl>(Specialization));
309 else
310 Writer.SpecializationsUpdates[cast<NamedDecl>(Template)].push_back(
311 cast<NamedDecl>(Specialization));
312 }
313 };
314}
315
317 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
318 if (FD->isInlined() || FD->isConstexpr())
319 return false;
320
321 if (FD->isDependentContext())
322 return false;
323
324 if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
325 return false;
326 }
327
328 if (auto *VD = dyn_cast<VarDecl>(D)) {
329 if (!VD->getDeclContext()->getRedeclContext()->isFileContext() ||
330 VD->isInline() || VD->isConstexpr() || isa<ParmVarDecl>(VD) ||
331 // Constant initialized variable may not affect the ABI, but they
332 // may be used in constant evaluation in the frontend, so we have
333 // to remain them.
334 VD->hasConstantInitialization())
335 return false;
336
337 if (VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
338 return false;
339 }
340
341 return true;
342}
343
346
347 // Source locations require array (variable-length) abbreviations. The
348 // abbreviation infrastructure requires that arrays are encoded last, so
349 // we handle it here in the case of those classes derived from DeclaratorDecl
350 if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
351 if (auto *TInfo = DD->getTypeSourceInfo())
352 Record.AddTypeLoc(TInfo->getTypeLoc());
353 }
354
355 // Handle FunctionDecl's body here and write it after all other Stmts/Exprs
356 // have been written. We want it last because we will not read it back when
357 // retrieving it from the AST, we'll just lazily set the offset.
358 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
359 if (!GeneratingReducedBMI || !CanElideDeclDef(FD)) {
360 Record.push_back(FD->doesThisDeclarationHaveABody());
361 if (FD->doesThisDeclarationHaveABody())
362 Record.AddFunctionDefinition(FD);
363 } else
364 Record.push_back(0);
365 }
366
367 // Similar to FunctionDecls, handle VarDecl's initializer here and write it
368 // after all other Stmts/Exprs. We will not read the initializer until after
369 // we have finished recursive deserialization, because it can recursively
370 // refer back to the variable.
371 if (auto *VD = dyn_cast<VarDecl>(D)) {
372 if (!GeneratingReducedBMI || !CanElideDeclDef(VD))
373 Record.AddVarDeclInit(VD);
374 else
375 Record.push_back(0);
376 }
377
378 // And similarly for FieldDecls. We already serialized whether there is a
379 // default member initializer.
380 if (auto *FD = dyn_cast<FieldDecl>(D)) {
381 if (FD->hasInClassInitializer()) {
382 if (Expr *Init = FD->getInClassInitializer()) {
383 Record.push_back(1);
384 Record.AddStmt(Init);
385 } else {
386 Record.push_back(0);
387 // Initializer has not been instantiated yet.
388 }
389 }
390 }
391
392 // If this declaration is also a DeclContext, write blocks for the
393 // declarations that lexically stored inside its context and those
394 // declarations that are visible from its context.
395 if (auto *DC = dyn_cast<DeclContext>(D))
397}
398
400 BitsPacker DeclBits;
401
402 // The order matters here. It will be better to put the bit with higher
403 // probability to be 0 in the end of the bits.
404 //
405 // Since we're using VBR6 format to store it.
406 // It will be pretty effient if all the higher bits are 0.
407 // For example, if we need to pack 8 bits into a value and the stored value
408 // is 0xf0, the actual stored value will be 0b000111'110000, which takes 12
409 // bits actually. However, if we changed the order to be 0x0f, then we can
410 // store it as 0b001111, which takes 6 bits only now.
411 DeclBits.addBits((uint64_t)D->getModuleOwnershipKind(), /*BitWidth=*/3);
412 DeclBits.addBit(D->isReferenced());
413 DeclBits.addBit(D->isUsed(false));
414 DeclBits.addBits(D->getAccess(), /*BitWidth=*/2);
415 DeclBits.addBit(D->isImplicit());
416 DeclBits.addBit(D->getDeclContext() != D->getLexicalDeclContext());
417 DeclBits.addBit(D->hasAttrs());
419 DeclBits.addBit(D->isInvalidDecl());
420 Record.push_back(DeclBits);
421
422 Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
424 Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
425
426 if (D->hasAttrs())
427 Record.AddAttributes(D->getAttrs());
428
429 Record.push_back(Writer.getSubmoduleID(D->getOwningModule()));
430
431 // If this declaration injected a name into a context different from its
432 // lexical context, and that context is an imported namespace, we need to
433 // update its visible declarations to include this name.
434 //
435 // This happens when we instantiate a class with a friend declaration or a
436 // function with a local extern declaration, for instance.
437 //
438 // FIXME: Can we handle this in AddedVisibleDecl instead?
439 if (D->isOutOfLine()) {
440 auto *DC = D->getDeclContext();
441 while (auto *NS = dyn_cast<NamespaceDecl>(DC->getRedeclContext())) {
442 if (!NS->isFromASTFile())
443 break;
444 Writer.UpdatedDeclContexts.insert(NS->getPrimaryContext());
445 if (!NS->isInlineNamespace())
446 break;
447 DC = NS->getParent();
448 }
449 }
450}
451
453 StringRef Arg = D->getArg();
454 Record.push_back(Arg.size());
455 VisitDecl(D);
456 Record.AddSourceLocation(D->getBeginLoc());
457 Record.push_back(D->getCommentKind());
458 Record.AddString(Arg);
460}
461
464 StringRef Name = D->getName();
465 StringRef Value = D->getValue();
466 Record.push_back(Name.size() + 1 + Value.size());
467 VisitDecl(D);
468 Record.AddSourceLocation(D->getBeginLoc());
469 Record.AddString(Name);
470 Record.AddString(Value);
472}
473
475 llvm_unreachable("Translation units aren't directly serialized");
476}
477
479 VisitDecl(D);
480 Record.AddDeclarationName(D->getDeclName());
483 : 0);
484}
485
488 Record.AddSourceLocation(D->getBeginLoc());
489 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
490}
491
495 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
496 Record.push_back(D->isModed());
497 if (D->isModed())
498 Record.AddTypeRef(D->getUnderlyingType());
499 Record.AddDeclRef(D->getAnonDeclWithTypedefName(false));
500}
501
505 !D->hasAttrs() &&
506 !D->isImplicit() &&
507 D->getFirstDecl() == D->getMostRecentDecl() &&
508 !D->isInvalidDecl() &&
510 !D->isModulePrivate() &&
512 D->getDeclName().getNameKind() == DeclarationName::Identifier)
513 AbbrevToUse = Writer.getDeclTypedefAbbrev();
514
516}
517
520 Record.AddDeclRef(D->getDescribedAliasTemplate());
522}
523
525 static_assert(DeclContext::NumTagDeclBits == 23,
526 "You need to update the serializer after you change the "
527 "TagDeclBits");
528
531 Record.push_back(D->getIdentifierNamespace());
532
533 BitsPacker TagDeclBits;
534 TagDeclBits.addBits(llvm::to_underlying(D->getTagKind()), /*BitWidth=*/3);
535 TagDeclBits.addBit(!isa<CXXRecordDecl>(D) ? D->isCompleteDefinition() : 0);
536 TagDeclBits.addBit(D->isEmbeddedInDeclarator());
537 TagDeclBits.addBit(D->isFreeStanding());
538 TagDeclBits.addBit(D->isCompleteDefinitionRequired());
539 TagDeclBits.addBits(
540 D->hasExtInfo() ? 1 : (D->getTypedefNameForAnonDecl() ? 2 : 0),
541 /*BitWidth=*/2);
542 Record.push_back(TagDeclBits);
543
544 Record.AddSourceRange(D->getBraceRange());
545
546 if (D->hasExtInfo()) {
547 Record.AddQualifierInfo(*D->getExtInfo());
548 } else if (auto *TD = D->getTypedefNameForAnonDecl()) {
549 Record.AddDeclRef(TD);
550 Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
551 }
552}
553
555 static_assert(DeclContext::NumEnumDeclBits == 43,
556 "You need to update the serializer after you change the "
557 "EnumDeclBits");
558
560 Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
561 if (!D->getIntegerTypeSourceInfo())
562 Record.AddTypeRef(D->getIntegerType());
563 Record.AddTypeRef(D->getPromotionType());
564
565 BitsPacker EnumDeclBits;
566 EnumDeclBits.addBits(D->getNumPositiveBits(), /*BitWidth=*/8);
567 EnumDeclBits.addBits(D->getNumNegativeBits(), /*BitWidth=*/8);
568 EnumDeclBits.addBit(D->isScoped());
569 EnumDeclBits.addBit(D->isScopedUsingClassTag());
570 EnumDeclBits.addBit(D->isFixed());
571 Record.push_back(EnumDeclBits);
572
573 Record.push_back(D->getODRHash());
574
575 if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
576 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
577 Record.push_back(MemberInfo->getTemplateSpecializationKind());
578 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
579 } else {
580 Record.AddDeclRef(nullptr);
581 }
582
583 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
584 !D->isInvalidDecl() && !D->isImplicit() && !D->hasExtInfo() &&
585 !D->getTypedefNameForAnonDecl() &&
586 D->getFirstDecl() == D->getMostRecentDecl() &&
589 !D->getIntegerTypeSourceInfo() && !D->getMemberSpecializationInfo() &&
591 D->getDeclName().getNameKind() == DeclarationName::Identifier)
592 AbbrevToUse = Writer.getDeclEnumAbbrev();
593
595}
596
598 static_assert(DeclContext::NumRecordDeclBits == 64,
599 "You need to update the serializer after you change the "
600 "RecordDeclBits");
601
603
604 BitsPacker RecordDeclBits;
605 RecordDeclBits.addBit(D->hasFlexibleArrayMember());
606 RecordDeclBits.addBit(D->isAnonymousStructOrUnion());
607 RecordDeclBits.addBit(D->hasObjectMember());
608 RecordDeclBits.addBit(D->hasVolatileMember());
609 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDefaultInitialize());
610 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveCopy());
611 RecordDeclBits.addBit(D->isNonTrivialToPrimitiveDestroy());
612 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveDefaultInitializeCUnion());
613 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveDestructCUnion());
614 RecordDeclBits.addBit(D->hasNonTrivialToPrimitiveCopyCUnion());
615 RecordDeclBits.addBit(D->hasUninitializedExplicitInitFields());
616 RecordDeclBits.addBit(D->isParamDestroyedInCallee());
617 RecordDeclBits.addBits(llvm::to_underlying(D->getArgPassingRestrictions()), 2);
618 Record.push_back(RecordDeclBits);
619
620 // Only compute this for C/Objective-C, in C++ this is computed as part
621 // of CXXRecordDecl.
622 if (!isa<CXXRecordDecl>(D))
623 Record.push_back(D->getODRHash());
624
625 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
626 !D->isImplicit() && !D->isInvalidDecl() && !D->hasExtInfo() &&
627 !D->getTypedefNameForAnonDecl() &&
628 D->getFirstDecl() == D->getMostRecentDecl() &&
632 D->getDeclName().getNameKind() == DeclarationName::Identifier)
633 AbbrevToUse = Writer.getDeclRecordAbbrev();
634
636}
637
640 Record.AddTypeRef(D->getType());
641}
642
645 Record.push_back(D->getInitExpr()? 1 : 0);
646 if (D->getInitExpr())
647 Record.AddStmt(D->getInitExpr());
648 Record.AddAPSInt(D->getInitVal());
649
651}
652
655 Record.AddSourceLocation(D->getInnerLocStart());
656 Record.push_back(D->hasExtInfo());
657 if (D->hasExtInfo()) {
658 DeclaratorDecl::ExtInfo *Info = D->getExtInfo();
659 Record.AddQualifierInfo(*Info);
660 Record.AddStmt(Info->TrailingRequiresClause);
661 }
662 // The location information is deferred until the end of the record.
663 Record.AddTypeRef(D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType()
664 : QualType());
665}
666
668 static_assert(DeclContext::NumFunctionDeclBits == 44,
669 "You need to update the serializer after you change the "
670 "FunctionDeclBits");
671
673
674 Record.push_back(D->getTemplatedKind());
675 switch (D->getTemplatedKind()) {
677 break;
679 Record.AddDeclRef(D->getInstantiatedFromDecl());
680 break;
682 Record.AddDeclRef(D->getDescribedFunctionTemplate());
683 break;
685 MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo();
686 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
687 Record.push_back(MemberInfo->getTemplateSpecializationKind());
688 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
689 break;
690 }
693 FTSInfo = D->getTemplateSpecializationInfo();
694
696
697 Record.AddDeclRef(FTSInfo->getTemplate());
698 Record.push_back(FTSInfo->getTemplateSpecializationKind());
699
700 // Template arguments.
701 Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
702
703 // Template args as written.
704 Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
705 if (FTSInfo->TemplateArgumentsAsWritten)
706 Record.AddASTTemplateArgumentListInfo(
708
709 Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
710
711 if (MemberSpecializationInfo *MemberInfo =
712 FTSInfo->getMemberSpecializationInfo()) {
713 Record.push_back(1);
714 Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
715 Record.push_back(MemberInfo->getTemplateSpecializationKind());
716 Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
717 } else {
718 Record.push_back(0);
719 }
720
721 if (D->isCanonicalDecl()) {
722 // Write the template that contains the specializations set. We will
723 // add a FunctionTemplateSpecializationInfo to it when reading.
724 Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
725 }
726 break;
727 }
730 DFTSInfo = D->getDependentSpecializationInfo();
731
732 // Candidates.
733 Record.push_back(DFTSInfo->getCandidates().size());
734 for (FunctionTemplateDecl *FTD : DFTSInfo->getCandidates())
735 Record.AddDeclRef(FTD);
736
737 // Templates args.
738 Record.push_back(DFTSInfo->TemplateArgumentsAsWritten != nullptr);
739 if (DFTSInfo->TemplateArgumentsAsWritten)
740 Record.AddASTTemplateArgumentListInfo(
742 break;
743 }
744 }
745
747 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
748 Record.push_back(D->getIdentifierNamespace());
749
750 // The order matters here. It will be better to put the bit with higher
751 // probability to be 0 in the end of the bits. See the comments in VisitDecl
752 // for details.
753 BitsPacker FunctionDeclBits;
754 // FIXME: stable encoding
755 FunctionDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()), 3);
756 FunctionDeclBits.addBits((uint32_t)D->getStorageClass(), /*BitWidth=*/3);
757 FunctionDeclBits.addBit(D->isInlineSpecified());
758 FunctionDeclBits.addBit(D->isInlined());
759 FunctionDeclBits.addBit(D->hasSkippedBody());
760 FunctionDeclBits.addBit(D->isVirtualAsWritten());
761 FunctionDeclBits.addBit(D->isPureVirtual());
762 FunctionDeclBits.addBit(D->hasInheritedPrototype());
763 FunctionDeclBits.addBit(D->hasWrittenPrototype());
764 FunctionDeclBits.addBit(D->isDeletedBit());
765 FunctionDeclBits.addBit(D->isTrivial());
766 FunctionDeclBits.addBit(D->isTrivialForCall());
767 FunctionDeclBits.addBit(D->isDefaulted());
768 FunctionDeclBits.addBit(D->isExplicitlyDefaulted());
769 FunctionDeclBits.addBit(D->isIneligibleOrNotSelected());
770 FunctionDeclBits.addBits((uint64_t)(D->getConstexprKind()), /*BitWidth=*/2);
771 FunctionDeclBits.addBit(D->hasImplicitReturnZero());
772 FunctionDeclBits.addBit(D->isMultiVersion());
773 FunctionDeclBits.addBit(D->isLateTemplateParsed());
774 FunctionDeclBits.addBit(D->FriendConstraintRefersToEnclosingTemplate());
775 FunctionDeclBits.addBit(D->usesSEHTry());
776 Record.push_back(FunctionDeclBits);
777
778 Record.AddSourceLocation(D->getEndLoc());
779 if (D->isExplicitlyDefaulted())
780 Record.AddSourceLocation(D->getDefaultLoc());
781
782 Record.push_back(D->getODRHash());
783
784 if (D->isDefaulted() || D->isDeletedAsWritten()) {
785 if (auto *FDI = D->getDefalutedOrDeletedInfo()) {
786 // Store both that there is an DefaultedOrDeletedInfo and whether it
787 // contains a DeletedMessage.
788 StringLiteral *DeletedMessage = FDI->getDeletedMessage();
789 Record.push_back(1 | (DeletedMessage ? 2 : 0));
790 if (DeletedMessage)
791 Record.AddStmt(DeletedMessage);
792
793 Record.push_back(FDI->getUnqualifiedLookups().size());
794 for (DeclAccessPair P : FDI->getUnqualifiedLookups()) {
795 Record.AddDeclRef(P.getDecl());
796 Record.push_back(P.getAccess());
797 }
798 } else {
799 Record.push_back(0);
800 }
801 }
802
803 if (D->getFriendObjectKind()) {
804 // For a function defined inline within a class template, we have to force
805 // the canonical definition to be the one inside the canonical definition of
806 // the template. Remember this relation to deserialize them together.
807 if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent()))
808 if (RD->isDependentContext() && RD->isThisDeclarationADefinition()) {
809 Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
810 Writer.GetDeclRef(D));
811 }
812 }
813
814 Record.push_back(D->param_size());
815 for (auto *P : D->parameters())
816 Record.AddDeclRef(P);
818}
819
822 uint64_t Kind = static_cast<uint64_t>(ES.getKind());
823 Kind = Kind << 1 | static_cast<bool>(ES.getExpr());
824 Record.push_back(Kind);
825 if (ES.getExpr()) {
826 Record.AddStmt(ES.getExpr());
827 }
828}
829
831 addExplicitSpecifier(D->getExplicitSpecifier(), Record);
832 Record.AddDeclRef(D->Ctor);
834 Record.push_back(static_cast<unsigned char>(D->getDeductionCandidateKind()));
836}
837
839 static_assert(DeclContext::NumObjCMethodDeclBits == 37,
840 "You need to update the serializer after you change the "
841 "ObjCMethodDeclBits");
842
844 // FIXME: convert to LazyStmtPtr?
845 // Unlike C/C++, method bodies will never be in header files.
846 bool HasBodyStuff = D->getBody() != nullptr;
847 Record.push_back(HasBodyStuff);
848 if (HasBodyStuff) {
849 Record.AddStmt(D->getBody());
850 }
851 Record.AddDeclRef(D->getSelfDecl());
852 Record.AddDeclRef(D->getCmdDecl());
853 Record.push_back(D->isInstanceMethod());
854 Record.push_back(D->isVariadic());
855 Record.push_back(D->isPropertyAccessor());
856 Record.push_back(D->isSynthesizedAccessorStub());
857 Record.push_back(D->isDefined());
858 Record.push_back(D->isOverriding());
859 Record.push_back(D->hasSkippedBody());
860
861 Record.push_back(D->isRedeclaration());
862 Record.push_back(D->hasRedeclaration());
863 if (D->hasRedeclaration()) {
864 assert(Record.getASTContext().getObjCMethodRedeclaration(D));
865 Record.AddDeclRef(Record.getASTContext().getObjCMethodRedeclaration(D));
866 }
867
868 // FIXME: stable encoding for @required/@optional
869 Record.push_back(llvm::to_underlying(D->getImplementationControl()));
870 // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
871 Record.push_back(D->getObjCDeclQualifier());
872 Record.push_back(D->hasRelatedResultType());
873 Record.AddTypeRef(D->getReturnType());
874 Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
875 Record.AddSourceLocation(D->getEndLoc());
876 Record.push_back(D->param_size());
877 for (const auto *P : D->parameters())
878 Record.AddDeclRef(P);
879
880 Record.push_back(D->getSelLocsKind());
881 unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
882 SourceLocation *SelLocs = D->getStoredSelLocs();
883 Record.push_back(NumStoredSelLocs);
884 for (unsigned i = 0; i != NumStoredSelLocs; ++i)
885 Record.AddSourceLocation(SelLocs[i]);
886
888}
889
892 Record.push_back(D->Variance);
893 Record.push_back(D->Index);
894 Record.AddSourceLocation(D->VarianceLoc);
895 Record.AddSourceLocation(D->ColonLoc);
896
898}
899
901 static_assert(DeclContext::NumObjCContainerDeclBits == 64,
902 "You need to update the serializer after you change the "
903 "ObjCContainerDeclBits");
904
906 Record.AddSourceLocation(D->getAtStartLoc());
907 Record.AddSourceRange(D->getAtEndRange());
908 // Abstract class (no need to define a stable serialization::DECL code).
909}
910
914 Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
915 AddObjCTypeParamList(D->TypeParamList);
916
917 Record.push_back(D->isThisDeclarationADefinition());
918 if (D->isThisDeclarationADefinition()) {
919 // Write the DefinitionData
920 ObjCInterfaceDecl::DefinitionData &Data = D->data();
921
922 Record.AddTypeSourceInfo(D->getSuperClassTInfo());
923 Record.AddSourceLocation(D->getEndOfDefinitionLoc());
924 Record.push_back(Data.HasDesignatedInitializers);
925 Record.push_back(D->getODRHash());
926
927 // Write out the protocols that are directly referenced by the @interface.
928 Record.push_back(Data.ReferencedProtocols.size());
929 for (const auto *P : D->protocols())
930 Record.AddDeclRef(P);
931 for (const auto &PL : D->protocol_locs())
932 Record.AddSourceLocation(PL);
933
934 // Write out the protocols that are transitively referenced.
935 Record.push_back(Data.AllReferencedProtocols.size());
937 P = Data.AllReferencedProtocols.begin(),
938 PEnd = Data.AllReferencedProtocols.end();
939 P != PEnd; ++P)
940 Record.AddDeclRef(*P);
941
942
943 if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
944 // Ensure that we write out the set of categories for this class.
945 Writer.ObjCClassesWithCategories.insert(D);
946
947 // Make sure that the categories get serialized.
948 for (; Cat; Cat = Cat->getNextClassCategoryRaw())
949 (void)Writer.GetDeclRef(Cat);
950 }
951 }
952
954}
955
958 // FIXME: stable encoding for @public/@private/@protected/@package
959 Record.push_back(D->getAccessControl());
960 Record.push_back(D->getSynthesize());
961
963 !D->hasAttrs() &&
964 !D->isImplicit() &&
965 !D->isUsed(false) &&
966 !D->isInvalidDecl() &&
967 !D->isReferenced() &&
968 !D->isModulePrivate() &&
969 !D->getBitWidth() &&
970 !D->hasExtInfo() &&
971 D->getDeclName())
972 AbbrevToUse = Writer.getDeclObjCIvarAbbrev();
973
975}
976
980
981 Record.push_back(D->isThisDeclarationADefinition());
982 if (D->isThisDeclarationADefinition()) {
983 Record.push_back(D->protocol_size());
984 for (const auto *I : D->protocols())
985 Record.AddDeclRef(I);
986 for (const auto &PL : D->protocol_locs())
987 Record.AddSourceLocation(PL);
988 Record.push_back(D->getODRHash());
989 }
990
992}
993
997}
998
1001 Record.AddSourceLocation(D->getCategoryNameLoc());
1002 Record.AddSourceLocation(D->getIvarLBraceLoc());
1003 Record.AddSourceLocation(D->getIvarRBraceLoc());
1004 Record.AddDeclRef(D->getClassInterface());
1005 AddObjCTypeParamList(D->TypeParamList);
1006 Record.push_back(D->protocol_size());
1007 for (const auto *I : D->protocols())
1008 Record.AddDeclRef(I);
1009 for (const auto &PL : D->protocol_locs())
1010 Record.AddSourceLocation(PL);
1012}
1013
1016 Record.AddDeclRef(D->getClassInterface());
1018}
1019
1022 Record.AddSourceLocation(D->getAtLoc());
1023 Record.AddSourceLocation(D->getLParenLoc());
1024 Record.AddTypeRef(D->getType());
1025 Record.AddTypeSourceInfo(D->getTypeSourceInfo());
1026 // FIXME: stable encoding
1027 Record.push_back((unsigned)D->getPropertyAttributes());
1028 Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
1029 // FIXME: stable encoding
1030 Record.push_back((unsigned)D->getPropertyImplementation());
1031 Record.AddDeclarationName(D->getGetterName());
1032 Record.AddSourceLocation(D->getGetterNameLoc());
1033 Record.AddDeclarationName(D->getSetterName());
1034 Record.AddSourceLocation(D->getSetterNameLoc());
1035 Record.AddDeclRef(D->getGetterMethodDecl());
1036 Record.AddDeclRef(D->getSetterMethodDecl());
1037 Record.AddDeclRef(D->getPropertyIvarDecl());
1039}
1040
1043 Record.AddDeclRef(D->getClassInterface());
1044 // Abstract class (no need to define a stable serialization::DECL code).
1045}
1046
1049 Record.AddSourceLocation(D->getCategoryNameLoc());
1051}
1052
1055 Record.AddDeclRef(D->getSuperClass());
1056 Record.AddSourceLocation(D->getSuperClassLoc());
1057 Record.AddSourceLocation(D->getIvarLBraceLoc());
1058 Record.AddSourceLocation(D->getIvarRBraceLoc());
1059 Record.push_back(D->hasNonZeroConstructors());
1060 Record.push_back(D->hasDestructors());
1061 Record.push_back(D->NumIvarInitializers);
1062 if (D->NumIvarInitializers)
1063 Record.AddCXXCtorInitializers(
1064 llvm::ArrayRef(D->init_begin(), D->init_end()));
1066}
1067
1069 VisitDecl(D);
1070 Record.AddSourceLocation(D->getBeginLoc());
1071 Record.AddDeclRef(D->getPropertyDecl());
1072 Record.AddDeclRef(D->getPropertyIvarDecl());
1073 Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
1074 Record.AddDeclRef(D->getGetterMethodDecl());
1075 Record.AddDeclRef(D->getSetterMethodDecl());
1076 Record.AddStmt(D->getGetterCXXConstructor());
1077 Record.AddStmt(D->getSetterCXXAssignment());
1079}
1080
1083 Record.push_back(D->isMutable());
1084
1085 Record.push_back((D->StorageKind << 1) | D->BitField);
1086 if (D->StorageKind == FieldDecl::ISK_CapturedVLAType)
1087 Record.AddTypeRef(QualType(D->getCapturedVLAType(), 0));
1088 else if (D->BitField)
1089 Record.AddStmt(D->getBitWidth());
1090
1091 if (!D->getDeclName() || D->isPlaceholderVar(Writer.getLangOpts()))
1092 Record.AddDeclRef(
1093 Record.getASTContext().getInstantiatedFromUnnamedFieldDecl(D));
1094
1095 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1096 !D->hasAttrs() &&
1097 !D->isImplicit() &&
1098 !D->isUsed(false) &&
1099 !D->isInvalidDecl() &&
1100 !D->isReferenced() &&
1102 !D->isModulePrivate() &&
1103 !D->getBitWidth() &&
1104 !D->hasInClassInitializer() &&
1105 !D->hasCapturedVLAType() &&
1106 !D->hasExtInfo() &&
1109 D->getDeclName())
1110 AbbrevToUse = Writer.getDeclFieldAbbrev();
1111
1113}
1114
1117 Record.AddIdentifierRef(D->getGetterId());
1118 Record.AddIdentifierRef(D->getSetterId());
1120}
1121
1124 MSGuidDecl::Parts Parts = D->getParts();
1125 Record.push_back(Parts.Part1);
1126 Record.push_back(Parts.Part2);
1127 Record.push_back(Parts.Part3);
1128 Record.append(std::begin(Parts.Part4And5), std::end(Parts.Part4And5));
1130}
1131
1135 Record.AddAPValue(D->getValue());
1137}
1138
1141 Record.AddAPValue(D->getValue());
1143}
1144
1147 Record.push_back(D->getChainingSize());
1148
1149 for (const auto *P : D->chain())
1150 Record.AddDeclRef(P);
1152}
1153
1157
1158 // The order matters here. It will be better to put the bit with higher
1159 // probability to be 0 in the end of the bits. See the comments in VisitDecl
1160 // for details.
1161 BitsPacker VarDeclBits;
1162 VarDeclBits.addBits(llvm::to_underlying(D->getLinkageInternal()),
1163 /*BitWidth=*/3);
1164
1165 bool ModulesCodegen = false;
1166 if (Writer.WritingModule && D->getStorageDuration() == SD_Static &&
1167 !D->getDescribedVarTemplate()) {
1168 // When building a C++20 module interface unit or a partition unit, a
1169 // strong definition in the module interface is provided by the
1170 // compilation of that unit, not by its users. (Inline variables are still
1171 // emitted in module users.)
1172 ModulesCodegen = (Writer.WritingModule->isInterfaceOrPartition() ||
1173 (D->hasAttr<DLLExportAttr>() &&
1174 Writer.getLangOpts().BuildingPCHWithObjectFile)) &&
1175 Record.getASTContext().GetGVALinkageForVariable(D) >=
1177 }
1178 VarDeclBits.addBit(ModulesCodegen);
1179
1180 VarDeclBits.addBits(D->getStorageClass(), /*BitWidth=*/3);
1181 VarDeclBits.addBits(D->getTSCSpec(), /*BitWidth=*/2);
1182 VarDeclBits.addBits(D->getInitStyle(), /*BitWidth=*/2);
1183 VarDeclBits.addBit(D->isARCPseudoStrong());
1184
1185 bool HasDeducedType = false;
1186 if (!isa<ParmVarDecl>(D)) {
1187 VarDeclBits.addBit(D->isThisDeclarationADemotedDefinition());
1188 VarDeclBits.addBit(D->isExceptionVariable());
1189 VarDeclBits.addBit(D->isNRVOVariable());
1190 VarDeclBits.addBit(D->isCXXForRangeDecl());
1191
1192 VarDeclBits.addBit(D->isInline());
1193 VarDeclBits.addBit(D->isInlineSpecified());
1194 VarDeclBits.addBit(D->isConstexpr());
1195 VarDeclBits.addBit(D->isInitCapture());
1196 VarDeclBits.addBit(D->isPreviousDeclInSameBlockScope());
1197
1198 VarDeclBits.addBit(D->isEscapingByref());
1199 HasDeducedType = D->getType()->getContainedDeducedType();
1200 VarDeclBits.addBit(HasDeducedType);
1201
1202 if (const auto *IPD = dyn_cast<ImplicitParamDecl>(D))
1203 VarDeclBits.addBits(llvm::to_underlying(IPD->getParameterKind()),
1204 /*Width=*/3);
1205 else
1206 VarDeclBits.addBits(0, /*Width=*/3);
1207
1208 VarDeclBits.addBit(D->isObjCForDecl());
1209 }
1210
1211 Record.push_back(VarDeclBits);
1212
1213 if (ModulesCodegen)
1214 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1215
1216 if (D->hasAttr<BlocksAttr>()) {
1217 BlockVarCopyInit Init = Record.getASTContext().getBlockVarCopyInit(D);
1218 Record.AddStmt(Init.getCopyExpr());
1219 if (Init.getCopyExpr())
1220 Record.push_back(Init.canThrow());
1221 }
1222
1223 enum {
1224 VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
1225 };
1226 if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
1227 Record.push_back(VarTemplate);
1228 Record.AddDeclRef(TemplD);
1229 } else if (MemberSpecializationInfo *SpecInfo
1230 = D->getMemberSpecializationInfo()) {
1231 Record.push_back(StaticDataMemberSpecialization);
1232 Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
1233 Record.push_back(SpecInfo->getTemplateSpecializationKind());
1234 Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
1235 } else {
1236 Record.push_back(VarNotTemplate);
1237 }
1238
1239 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1242 D->getDeclName().getNameKind() == DeclarationName::Identifier &&
1243 !D->hasExtInfo() && D->getFirstDecl() == D->getMostRecentDecl() &&
1244 D->getKind() == Decl::Var && !D->isInline() && !D->isConstexpr() &&
1245 !D->isInitCapture() && !D->isPreviousDeclInSameBlockScope() &&
1246 !D->isEscapingByref() && !HasDeducedType &&
1247 D->getStorageDuration() != SD_Static && !D->getDescribedVarTemplate() &&
1248 !D->getMemberSpecializationInfo() && !D->isObjCForDecl() &&
1249 !isa<ImplicitParamDecl>(D) && !D->isEscapingByref())
1250 AbbrevToUse = Writer.getDeclVarAbbrev();
1251
1253}
1254
1256 VisitVarDecl(D);
1258}
1259
1261 VisitVarDecl(D);
1262
1263 // See the implementation of `ParmVarDecl::getParameterIndex()`, which may
1264 // exceed the size of the normal bitfield. So it may be better to not pack
1265 // these bits.
1266 Record.push_back(D->getFunctionScopeIndex());
1267
1268 BitsPacker ParmVarDeclBits;
1269 ParmVarDeclBits.addBit(D->isObjCMethodParameter());
1270 ParmVarDeclBits.addBits(D->getFunctionScopeDepth(), /*BitsWidth=*/7);
1271 // FIXME: stable encoding
1272 ParmVarDeclBits.addBits(D->getObjCDeclQualifier(), /*BitsWidth=*/7);
1273 ParmVarDeclBits.addBit(D->isKNRPromoted());
1274 ParmVarDeclBits.addBit(D->hasInheritedDefaultArg());
1275 ParmVarDeclBits.addBit(D->hasUninstantiatedDefaultArg());
1276 ParmVarDeclBits.addBit(D->getExplicitObjectParamThisLoc().isValid());
1277 Record.push_back(ParmVarDeclBits);
1278
1279 if (D->hasUninstantiatedDefaultArg())
1280 Record.AddStmt(D->getUninstantiatedDefaultArg());
1281 if (D->getExplicitObjectParamThisLoc().isValid())
1282 Record.AddSourceLocation(D->getExplicitObjectParamThisLoc());
1284
1285 // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
1286 // we dynamically check for the properties that we optimize for, but don't
1287 // know are true of all PARM_VAR_DECLs.
1288 if (D->getDeclContext() == D->getLexicalDeclContext() && !D->hasAttrs() &&
1289 !D->hasExtInfo() && D->getStorageClass() == 0 && !D->isInvalidDecl() &&
1291 D->getInitStyle() == VarDecl::CInit && // Can params have anything else?
1292 D->getInit() == nullptr) // No default expr.
1293 AbbrevToUse = Writer.getDeclParmVarAbbrev();
1294
1295 // Check things we know are true of *every* PARM_VAR_DECL, which is more than
1296 // just us assuming it.
1297 assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
1298 assert(!D->isThisDeclarationADemotedDefinition()
1299 && "PARM_VAR_DECL can't be demoted definition.");
1300 assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
1301 assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
1302 assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
1303 assert(!D->isStaticDataMember() &&
1304 "PARM_VAR_DECL can't be static data member");
1305}
1306
1308 // Record the number of bindings first to simplify deserialization.
1309 Record.push_back(D->bindings().size());
1310
1311 VisitVarDecl(D);
1312 for (auto *B : D->bindings())
1313 Record.AddDeclRef(B);
1315}
1316
1319 Record.AddStmt(D->getBinding());
1321}
1322
1324 VisitDecl(D);
1325 Record.AddStmt(D->getAsmString());
1326 Record.AddSourceLocation(D->getRParenLoc());
1328}
1329
1331 VisitDecl(D);
1332 Record.AddStmt(D->getStmt());
1334}
1335
1337 VisitDecl(D);
1339}
1340
1343 VisitDecl(D);
1344 Record.AddDeclRef(D->getExtendingDecl());
1345 Record.AddStmt(D->getTemporaryExpr());
1346 Record.push_back(static_cast<bool>(D->getValue()));
1347 if (D->getValue())
1348 Record.AddAPValue(*D->getValue());
1349 Record.push_back(D->getManglingNumber());
1351}
1353 VisitDecl(D);
1354 Record.AddStmt(D->getBody());
1355 Record.AddTypeSourceInfo(D->getSignatureAsWritten());
1356 Record.push_back(D->param_size());
1357 for (ParmVarDecl *P : D->parameters())
1358 Record.AddDeclRef(P);
1359 Record.push_back(D->isVariadic());
1360 Record.push_back(D->blockMissingReturnType());
1361 Record.push_back(D->isConversionFromLambda());
1362 Record.push_back(D->doesNotEscape());
1363 Record.push_back(D->canAvoidCopyToHeap());
1364 Record.push_back(D->capturesCXXThis());
1365 Record.push_back(D->getNumCaptures());
1366 for (const auto &capture : D->captures()) {
1367 Record.AddDeclRef(capture.getVariable());
1368
1369 unsigned flags = 0;
1370 if (capture.isByRef()) flags |= 1;
1371 if (capture.isNested()) flags |= 2;
1372 if (capture.hasCopyExpr()) flags |= 4;
1373 Record.push_back(flags);
1374
1375 if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
1376 }
1377
1379}
1380
1382 Record.push_back(D->getNumParams());
1383 VisitDecl(D);
1384 for (unsigned I = 0; I < D->getNumParams(); ++I)
1385 Record.AddDeclRef(D->getParam(I));
1386 Record.push_back(D->isNothrow() ? 1 : 0);
1387 Record.AddStmt(D->getBody());
1389}
1390
1392 Record.push_back(CD->getNumParams());
1393 VisitDecl(CD);
1394 Record.push_back(CD->getContextParamPosition());
1395 Record.push_back(CD->isNothrow() ? 1 : 0);
1396 // Body is stored by VisitCapturedStmt.
1397 for (unsigned I = 0; I < CD->getNumParams(); ++I)
1398 Record.AddDeclRef(CD->getParam(I));
1400}
1401
1403 static_assert(DeclContext::NumLinkageSpecDeclBits == 17,
1404 "You need to update the serializer after you change the"
1405 "LinkageSpecDeclBits");
1406
1407 VisitDecl(D);
1408 Record.push_back(llvm::to_underlying(D->getLanguage()));
1409 Record.AddSourceLocation(D->getExternLoc());
1410 Record.AddSourceLocation(D->getRBraceLoc());
1412}
1413
1415 VisitDecl(D);
1416 Record.AddSourceLocation(D->getRBraceLoc());
1418}
1419
1422 Record.AddSourceLocation(D->getBeginLoc());
1424}
1425
1426
1430
1431 BitsPacker NamespaceDeclBits;
1432 NamespaceDeclBits.addBit(D->isInline());
1433 NamespaceDeclBits.addBit(D->isNested());
1434 Record.push_back(NamespaceDeclBits);
1435
1436 Record.AddSourceLocation(D->getBeginLoc());
1437 Record.AddSourceLocation(D->getRBraceLoc());
1438
1439 if (D->isFirstDecl())
1440 Record.AddDeclRef(D->getAnonymousNamespace());
1442
1443 if (Writer.hasChain() && D->isAnonymousNamespace() &&
1444 D == D->getMostRecentDecl()) {
1445 // This is a most recent reopening of the anonymous namespace. If its parent
1446 // is in a previous PCH (or is the TU), mark that parent for update, because
1447 // the original namespace always points to the latest re-opening of its
1448 // anonymous namespace.
1449 Decl *Parent = cast<Decl>(
1450 D->getParent()->getRedeclContext()->getPrimaryContext());
1451 if (Parent->isFromASTFile() || isa<TranslationUnitDecl>(Parent)) {
1452 Writer.DeclUpdates[Parent].push_back(
1453 ASTWriter::DeclUpdate(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE, D));
1454 }
1455 }
1456}
1457
1461 Record.AddSourceLocation(D->getNamespaceLoc());
1462 Record.AddSourceLocation(D->getTargetNameLoc());
1463 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1464 Record.AddDeclRef(D->getNamespace());
1466}
1467
1470 Record.AddSourceLocation(D->getUsingLoc());
1471 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1472 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1473 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1474 Record.push_back(D->hasTypename());
1475 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingDecl(D));
1477}
1478
1481 Record.AddSourceLocation(D->getUsingLoc());
1482 Record.AddSourceLocation(D->getEnumLoc());
1483 Record.AddTypeSourceInfo(D->getEnumType());
1484 Record.AddDeclRef(D->FirstUsingShadow.getPointer());
1485 Record.AddDeclRef(Record.getASTContext().getInstantiatedFromUsingEnumDecl(D));
1487}
1488
1490 Record.push_back(D->NumExpansions);
1492 Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
1493 for (auto *E : D->expansions())
1494 Record.AddDeclRef(E);
1496}
1497
1501 Record.AddDeclRef(D->getTargetDecl());
1502 Record.push_back(D->getIdentifierNamespace());
1503 Record.AddDeclRef(D->UsingOrNextShadow);
1504 Record.AddDeclRef(
1505 Record.getASTContext().getInstantiatedFromUsingShadowDecl(D));
1506
1507 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1508 D->getFirstDecl() == D->getMostRecentDecl() && !D->hasAttrs() &&
1510 D->getDeclName().getNameKind() == DeclarationName::Identifier)
1511 AbbrevToUse = Writer.getDeclUsingShadowAbbrev();
1512
1514}
1515
1519 Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
1520 Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
1521 Record.push_back(D->IsVirtual);
1523}
1524
1527 Record.AddSourceLocation(D->getUsingLoc());
1528 Record.AddSourceLocation(D->getNamespaceKeyLocation());
1529 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1530 Record.AddDeclRef(D->getNominatedNamespace());
1531 Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
1533}
1534
1537 Record.AddSourceLocation(D->getUsingLoc());
1538 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1539 Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
1540 Record.AddSourceLocation(D->getEllipsisLoc());
1542}
1543
1547 Record.AddSourceLocation(D->getTypenameLoc());
1548 Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
1549 Record.AddSourceLocation(D->getEllipsisLoc());
1551}
1552
1557}
1558
1561
1562 enum {
1563 CXXRecNotTemplate = 0,
1564 CXXRecTemplate,
1565 CXXRecMemberSpecialization,
1566 CXXLambda
1567 };
1568 if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
1569 Record.push_back(CXXRecTemplate);
1570 Record.AddDeclRef(TemplD);
1571 } else if (MemberSpecializationInfo *MSInfo
1572 = D->getMemberSpecializationInfo()) {
1573 Record.push_back(CXXRecMemberSpecialization);
1574 Record.AddDeclRef(MSInfo->getInstantiatedFrom());
1575 Record.push_back(MSInfo->getTemplateSpecializationKind());
1576 Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
1577 } else if (D->isLambda()) {
1578 // For a lambda, we need some information early for merging.
1579 Record.push_back(CXXLambda);
1580 if (auto *Context = D->getLambdaContextDecl()) {
1581 Record.AddDeclRef(Context);
1582 Record.push_back(D->getLambdaIndexInContext());
1583 } else {
1584 Record.push_back(0);
1585 }
1586 // For lambdas inside canonical FunctionDecl remember the mapping.
1587 if (auto FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
1588 FD && FD->isCanonicalDecl()) {
1589 Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
1590 Writer.GetDeclRef(D));
1591 }
1592 } else {
1593 Record.push_back(CXXRecNotTemplate);
1594 }
1595
1596 Record.push_back(D->isThisDeclarationADefinition());
1597 if (D->isThisDeclarationADefinition())
1598 Record.AddCXXDefinitionData(D);
1599
1600 if (D->isCompleteDefinition() && D->isInNamedModule())
1601 Writer.AddDeclRef(D, Writer.ModularCodegenDecls);
1602
1603 // Store (what we currently believe to be) the key function to avoid
1604 // deserializing every method so we can compute it.
1605 //
1606 // FIXME: Avoid adding the key function if the class is defined in
1607 // module purview since in that case the key function is meaningless.
1608 if (D->isCompleteDefinition())
1609 Record.AddDeclRef(Record.getASTContext().getCurrentKeyFunction(D));
1610
1612}
1613
1616 if (D->isCanonicalDecl()) {
1617 Record.push_back(D->size_overridden_methods());
1618 for (const CXXMethodDecl *MD : D->overridden_methods())
1619 Record.AddDeclRef(MD);
1620 } else {
1621 // We only need to record overridden methods once for the canonical decl.
1622 Record.push_back(0);
1623 }
1624
1625 if (D->getDeclContext() == D->getLexicalDeclContext() &&
1626 D->getFirstDecl() == D->getMostRecentDecl() && !D->isInvalidDecl() &&
1628 D->getDeclName().getNameKind() == DeclarationName::Identifier &&
1629 !D->hasExtInfo() && !D->isExplicitlyDefaulted()) {
1630 if (D->getTemplatedKind() == FunctionDecl::TK_NonTemplate ||
1631 D->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate ||
1632 D->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization ||
1633 D->getTemplatedKind() == FunctionDecl::TK_DependentNonTemplate)
1634 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1635 else if (D->getTemplatedKind() ==
1638 D->getTemplateSpecializationInfo();
1639
1640 if (FTSInfo->TemplateArguments->size() == 1) {
1641 const TemplateArgument &TA = FTSInfo->TemplateArguments->get(0);
1642 if (TA.getKind() == TemplateArgument::Type &&
1643 !FTSInfo->TemplateArgumentsAsWritten &&
1644 !FTSInfo->getMemberSpecializationInfo())
1645 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1646 }
1647 } else if (D->getTemplatedKind() ==
1650 D->getDependentSpecializationInfo();
1651 if (!DFTSInfo->TemplateArgumentsAsWritten)
1652 AbbrevToUse = Writer.getDeclCXXMethodAbbrev(D->getTemplatedKind());
1653 }
1654 }
1655
1657}
1658
1660 static_assert(DeclContext::NumCXXConstructorDeclBits == 64,
1661 "You need to update the serializer after you change the "
1662 "CXXConstructorDeclBits");
1663
1664 Record.push_back(D->getTrailingAllocKind());
1665 addExplicitSpecifier(D->getExplicitSpecifier(), Record);
1666 if (auto Inherited = D->getInheritedConstructor()) {
1667 Record.AddDeclRef(Inherited.getShadowDecl());
1668 Record.AddDeclRef(Inherited.getConstructor());
1669 }
1670
1673}
1674
1677
1678 Record.AddDeclRef(D->getOperatorDelete());
1679 if (D->getOperatorDelete())
1680 Record.AddStmt(D->getOperatorDeleteThisArg());
1681
1683}
1684
1686 addExplicitSpecifier(D->getExplicitSpecifier(), Record);
1689}
1690
1692 VisitDecl(D);
1693 Record.push_back(Writer.getSubmoduleID(D->getImportedModule()));
1694 ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
1695 Record.push_back(!IdentifierLocs.empty());
1696 if (IdentifierLocs.empty()) {
1697 Record.AddSourceLocation(D->getEndLoc());
1698 Record.push_back(1);
1699 } else {
1700 for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
1701 Record.AddSourceLocation(IdentifierLocs[I]);
1702 Record.push_back(IdentifierLocs.size());
1703 }
1704 // Note: the number of source locations must always be the last element in
1705 // the record.
1707}
1708
1710 VisitDecl(D);
1711 Record.AddSourceLocation(D->getColonLoc());
1713}
1714
1716 // Record the number of friend type template parameter lists here
1717 // so as to simplify memory allocation during deserialization.
1718 Record.push_back(D->NumTPLists);
1719 VisitDecl(D);
1720 bool hasFriendDecl = isa<NamedDecl *>(D->Friend);
1721 Record.push_back(hasFriendDecl);
1722 if (hasFriendDecl)
1723 Record.AddDeclRef(D->getFriendDecl());
1724 else
1725 Record.AddTypeSourceInfo(D->getFriendType());
1726 for (unsigned i = 0; i < D->NumTPLists; ++i)
1727 Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
1728 Record.AddDeclRef(D->getNextFriend());
1729 Record.push_back(D->UnsupportedFriend);
1730 Record.AddSourceLocation(D->FriendLoc);
1731 Record.AddSourceLocation(D->EllipsisLoc);
1733}
1734
1736 VisitDecl(D);
1737 Record.push_back(D->getNumTemplateParameters());
1738 for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
1739 Record.AddTemplateParameterList(D->getTemplateParameterList(i));
1740 Record.push_back(D->getFriendDecl() != nullptr);
1741 if (D->getFriendDecl())
1742 Record.AddDeclRef(D->getFriendDecl());
1743 else
1744 Record.AddTypeSourceInfo(D->getFriendType());
1745 Record.AddSourceLocation(D->getFriendLoc());
1747}
1748
1751
1752 Record.AddTemplateParameterList(D->getTemplateParameters());
1753 Record.AddDeclRef(D->getTemplatedDecl());
1754}
1755
1758 Record.AddStmt(D->getConstraintExpr());
1760}
1761
1764 Record.push_back(D->getTemplateArguments().size());
1765 VisitDecl(D);
1766 for (const TemplateArgument &Arg : D->getTemplateArguments())
1767 Record.AddTemplateArgument(Arg);
1769}
1770
1773}
1774
1777
1778 // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that
1779 // getCommonPtr() can be used while this is still initializing.
1780 if (D->isFirstDecl()) {
1781 // This declaration owns the 'common' pointer, so serialize that data now.
1782 Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
1783 if (D->getInstantiatedFromMemberTemplate())
1784 Record.push_back(D->isMemberSpecialization());
1785 }
1786
1788 Record.push_back(D->getIdentifierNamespace());
1789}
1790
1793
1794 if (D->isFirstDecl())
1796
1797 // Force emitting the corresponding deduction guide in reduced BMI mode.
1798 // Otherwise, the deduction guide may be optimized out incorrectly.
1799 if (Writer.isGeneratingReducedBMI()) {
1800 auto Name =
1801 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(D);
1802 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1803 Writer.GetDeclRef(DG->getCanonicalDecl());
1804 }
1805
1807}
1808
1811 RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1812
1814
1815 llvm::PointerUnion<ClassTemplateDecl *,
1817 = D->getSpecializedTemplateOrPartial();
1818 if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
1819 Record.AddDeclRef(InstFromD);
1820 } else {
1821 Record.AddDeclRef(cast<ClassTemplatePartialSpecializationDecl *>(InstFrom));
1822 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1823 }
1824
1825 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1826 Record.AddSourceLocation(D->getPointOfInstantiation());
1827 Record.push_back(D->getSpecializationKind());
1828 Record.push_back(D->isCanonicalDecl());
1829
1830 if (D->isCanonicalDecl()) {
1831 // When reading, we'll add it to the folding set of the following template.
1832 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1833 }
1834
1835 bool ExplicitInstantiation =
1836 D->getTemplateSpecializationKind() ==
1838 D->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDefinition;
1839 Record.push_back(ExplicitInstantiation);
1840 if (ExplicitInstantiation) {
1841 Record.AddSourceLocation(D->getExternKeywordLoc());
1842 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1843 }
1844
1845 const ASTTemplateArgumentListInfo *ArgsWritten =
1846 D->getTemplateArgsAsWritten();
1847 Record.push_back(!!ArgsWritten);
1848 if (ArgsWritten)
1849 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1850
1851 // Mention the implicitly generated C++ deduction guide to make sure the
1852 // deduction guide will be rewritten as expected.
1853 //
1854 // FIXME: Would it be more efficient to add a callback register function
1855 // in sema to register the deduction guide?
1856 if (Writer.isWritingStdCXXNamedModules()) {
1857 auto Name =
1858 Record.getASTContext().DeclarationNames.getCXXDeductionGuideName(
1859 D->getSpecializedTemplate());
1860 for (auto *DG : D->getDeclContext()->noload_lookup(Name))
1861 Writer.GetDeclRef(DG->getCanonicalDecl());
1862 }
1863
1865}
1866
1869 Record.AddTemplateParameterList(D->getTemplateParameters());
1870
1872
1873 // These are read/set from/to the first declaration.
1874 if (D->getPreviousDecl() == nullptr) {
1875 Record.AddDeclRef(D->getInstantiatedFromMember());
1876 Record.push_back(D->isMemberSpecialization());
1877 }
1878
1880}
1881
1884
1885 if (D->isFirstDecl())
1888}
1889
1892 RegisterTemplateSpecialization(D->getSpecializedTemplate(), D);
1893
1894 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
1895 InstFrom = D->getSpecializedTemplateOrPartial();
1896 if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
1897 Record.AddDeclRef(InstFromD);
1898 } else {
1899 Record.AddDeclRef(cast<VarTemplatePartialSpecializationDecl *>(InstFrom));
1900 Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
1901 }
1902
1903 bool ExplicitInstantiation =
1904 D->getTemplateSpecializationKind() ==
1906 D->getTemplateSpecializationKind() == TSK_ExplicitInstantiationDefinition;
1907 Record.push_back(ExplicitInstantiation);
1908 if (ExplicitInstantiation) {
1909 Record.AddSourceLocation(D->getExternKeywordLoc());
1910 Record.AddSourceLocation(D->getTemplateKeywordLoc());
1911 }
1912
1913 const ASTTemplateArgumentListInfo *ArgsWritten =
1914 D->getTemplateArgsAsWritten();
1915 Record.push_back(!!ArgsWritten);
1916 if (ArgsWritten)
1917 Record.AddASTTemplateArgumentListInfo(ArgsWritten);
1918
1919 Record.AddTemplateArgumentList(&D->getTemplateArgs());
1920 Record.AddSourceLocation(D->getPointOfInstantiation());
1921 Record.push_back(D->getSpecializationKind());
1922 Record.push_back(D->IsCompleteDefinition);
1923
1924 VisitVarDecl(D);
1925
1926 Record.push_back(D->isCanonicalDecl());
1927
1928 if (D->isCanonicalDecl()) {
1929 // When reading, we'll add it to the folding set of the following template.
1930 Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
1931 }
1932
1934}
1935
1938 Record.AddTemplateParameterList(D->getTemplateParameters());
1939
1941
1942 // These are read/set from/to the first declaration.
1943 if (D->getPreviousDecl() == nullptr) {
1944 Record.AddDeclRef(D->getInstantiatedFromMember());
1945 Record.push_back(D->isMemberSpecialization());
1946 }
1947
1949}
1950
1953
1954 if (D->isFirstDecl())
1957}
1958
1960 Record.push_back(D->hasTypeConstraint());
1962
1963 Record.push_back(D->wasDeclaredWithTypename());
1964
1965 const TypeConstraint *TC = D->getTypeConstraint();
1966 if (D->hasTypeConstraint())
1967 Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
1968 if (TC) {
1969 auto *CR = TC->getConceptReference();
1970 Record.push_back(CR != nullptr);
1971 if (CR)
1972 Record.AddConceptReference(CR);
1974 Record.push_back(D->isExpandedParameterPack());
1975 if (D->isExpandedParameterPack())
1976 Record.push_back(D->getNumExpansionParameters());
1977 }
1978
1979 bool OwnsDefaultArg = D->hasDefaultArgument() &&
1980 !D->defaultArgumentWasInherited();
1981 Record.push_back(OwnsDefaultArg);
1982 if (OwnsDefaultArg)
1983 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
1984
1985 if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
1987 !D->isInvalidDecl() && !D->hasAttrs() &&
1989 D->getDeclName().getNameKind() == DeclarationName::Identifier)
1990 AbbrevToUse = Writer.getDeclTemplateTypeParmAbbrev();
1991
1993}
1994
1996 // For an expanded parameter pack, record the number of expansion types here
1997 // so that it's easier for deserialization to allocate the right amount of
1998 // memory.
1999 Expr *TypeConstraint = D->getPlaceholderTypeConstraint();
2000 Record.push_back(!!TypeConstraint);
2001 if (D->isExpandedParameterPack())
2002 Record.push_back(D->getNumExpansionTypes());
2003
2005 // TemplateParmPosition.
2006 Record.push_back(D->getDepth());
2007 Record.push_back(D->getPosition());
2008 if (TypeConstraint)
2009 Record.AddStmt(TypeConstraint);
2010
2011 if (D->isExpandedParameterPack()) {
2012 for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
2013 Record.AddTypeRef(D->getExpansionType(I));
2014 Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
2015 }
2016
2018 } else {
2019 // Rest of NonTypeTemplateParmDecl.
2020 Record.push_back(D->isParameterPack());
2021 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2022 !D->defaultArgumentWasInherited();
2023 Record.push_back(OwnsDefaultArg);
2024 if (OwnsDefaultArg)
2025 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2027 }
2028}
2029
2031 // For an expanded parameter pack, record the number of expansion types here
2032 // so that it's easier for deserialization to allocate the right amount of
2033 // memory.
2034 if (D->isExpandedParameterPack())
2035 Record.push_back(D->getNumExpansionTemplateParameters());
2036
2038 Record.push_back(D->wasDeclaredWithTypename());
2039 // TemplateParmPosition.
2040 Record.push_back(D->getDepth());
2041 Record.push_back(D->getPosition());
2042
2043 if (D->isExpandedParameterPack()) {
2044 for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
2045 I != N; ++I)
2046 Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
2048 } else {
2049 // Rest of TemplateTemplateParmDecl.
2050 Record.push_back(D->isParameterPack());
2051 bool OwnsDefaultArg = D->hasDefaultArgument() &&
2052 !D->defaultArgumentWasInherited();
2053 Record.push_back(OwnsDefaultArg);
2054 if (OwnsDefaultArg)
2055 Record.AddTemplateArgumentLoc(D->getDefaultArgument());
2057 }
2058}
2059
2063}
2064
2066 VisitDecl(D);
2067 Record.AddStmt(D->getAssertExpr());
2068 Record.push_back(D->isFailed());
2069 Record.AddStmt(D->getMessage());
2070 Record.AddSourceLocation(D->getRParenLoc());
2072}
2073
2074/// Emit the DeclContext part of a declaration context decl.
2076 static_assert(DeclContext::NumDeclContextBits == 13,
2077 "You need to update the serializer after you change the "
2078 "DeclContextBits");
2079
2080 uint64_t LexicalOffset = 0;
2081 uint64_t VisibleOffset = 0;
2082 uint64_t ModuleLocalOffset = 0;
2083 uint64_t TULocalOffset = 0;
2084
2085 if (Writer.isGeneratingReducedBMI() && isa<NamespaceDecl>(DC) &&
2086 cast<NamespaceDecl>(DC)->isFromExplicitGlobalModule()) {
2087 // In reduced BMI, delay writing lexical and visible block for namespace
2088 // in the global module fragment. See the comments of DelayedNamespace for
2089 // details.
2090 Writer.DelayedNamespace.push_back(cast<NamespaceDecl>(DC));
2091 } else {
2092 LexicalOffset =
2093 Writer.WriteDeclContextLexicalBlock(Record.getASTContext(), DC);
2094 Writer.WriteDeclContextVisibleBlock(Record.getASTContext(), DC,
2095 VisibleOffset, ModuleLocalOffset,
2096 TULocalOffset);
2097 }
2098
2099 Record.AddOffset(LexicalOffset);
2100 Record.AddOffset(VisibleOffset);
2101 Record.AddOffset(ModuleLocalOffset);
2102 Record.AddOffset(TULocalOffset);
2103}
2104
2106 assert(IsLocalDecl(D) && "expected a local declaration");
2107
2108 const Decl *Canon = D->getCanonicalDecl();
2109 if (IsLocalDecl(Canon))
2110 return Canon;
2111
2112 const Decl *&CacheEntry = FirstLocalDeclCache[Canon];
2113 if (CacheEntry)
2114 return CacheEntry;
2115
2116 for (const Decl *Redecl = D; Redecl; Redecl = Redecl->getPreviousDecl())
2117 if (IsLocalDecl(Redecl))
2118 D = Redecl;
2119 return CacheEntry = D;
2120}
2121
2122template <typename T>
2124 T *First = D->getFirstDecl();
2125 T *MostRecent = First->getMostRecentDecl();
2126 T *DAsT = static_cast<T *>(D);
2127 if (MostRecent != First) {
2128 assert(isRedeclarableDeclKind(DAsT->getKind()) &&
2129 "Not considered redeclarable?");
2130
2131 Record.AddDeclRef(First);
2132
2133 // Write out a list of local redeclarations of this declaration if it's the
2134 // first local declaration in the chain.
2135 const Decl *FirstLocal = Writer.getFirstLocalDecl(DAsT);
2136 if (DAsT == FirstLocal) {
2137 // Emit a list of all imported first declarations so that we can be sure
2138 // that all redeclarations visible to this module are before D in the
2139 // redecl chain.
2140 unsigned I = Record.size();
2141 Record.push_back(0);
2142 if (Writer.Chain)
2143 AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
2144 // This is the number of imported first declarations + 1.
2145 Record[I] = Record.size() - I;
2146
2147 // Collect the set of local redeclarations of this declaration, from
2148 // newest to oldest.
2149 ASTWriter::RecordData LocalRedecls;
2150 ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
2151 for (const Decl *Prev = FirstLocal->getMostRecentDecl();
2152 Prev != FirstLocal; Prev = Prev->getPreviousDecl())
2153 if (!Prev->isFromASTFile())
2154 LocalRedeclWriter.AddDeclRef(Prev);
2155
2156 // If we have any redecls, write them now as a separate record preceding
2157 // the declaration itself.
2158 if (LocalRedecls.empty())
2159 Record.push_back(0);
2160 else
2161 Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
2162 } else {
2163 Record.push_back(0);
2164 Record.AddDeclRef(FirstLocal);
2165 }
2166
2167 // Make sure that we serialize both the previous and the most-recent
2168 // declarations, which (transitively) ensures that all declarations in the
2169 // chain get serialized.
2170 //
2171 // FIXME: This is not correct; when we reach an imported declaration we
2172 // won't emit its previous declaration.
2173 (void)Writer.GetDeclRef(D->getPreviousDecl());
2174 (void)Writer.GetDeclRef(MostRecent);
2175 } else {
2176 // We use the sentinel value 0 to indicate an only declaration.
2177 Record.push_back(0);
2178 }
2179}
2180
2184 Record.push_back(D->isCBuffer());
2185 Record.AddSourceLocation(D->getLocStart());
2186 Record.AddSourceLocation(D->getLBraceLoc());
2187 Record.AddSourceLocation(D->getRBraceLoc());
2188
2190}
2191
2193 Record.writeOMPChildren(D->Data);
2194 VisitDecl(D);
2196}
2197
2199 Record.writeOMPChildren(D->Data);
2200 VisitDecl(D);
2202}
2203
2205 Record.writeOMPChildren(D->Data);
2206 VisitDecl(D);
2208}
2209
2212 "You need to update the serializer after you change the "
2213 "NumOMPDeclareReductionDeclBits");
2214
2216 Record.AddSourceLocation(D->getBeginLoc());
2217 Record.AddStmt(D->getCombinerIn());
2218 Record.AddStmt(D->getCombinerOut());
2219 Record.AddStmt(D->getCombiner());
2220 Record.AddStmt(D->getInitOrig());
2221 Record.AddStmt(D->getInitPriv());
2222 Record.AddStmt(D->getInitializer());
2223 Record.push_back(llvm::to_underlying(D->getInitializerKind()));
2224 Record.AddDeclRef(D->getPrevDeclInScope());
2226}
2227
2229 Record.writeOMPChildren(D->Data);
2231 Record.AddDeclarationName(D->getVarName());
2232 Record.AddDeclRef(D->getPrevDeclInScope());
2234}
2235
2237 VisitVarDecl(D);
2239}
2240
2241//===----------------------------------------------------------------------===//
2242// ASTWriter Implementation
2243//===----------------------------------------------------------------------===//
2244
2245namespace {
2246template <FunctionDecl::TemplatedKind Kind>
2247std::shared_ptr<llvm::BitCodeAbbrev>
2248getFunctionDeclAbbrev(serialization::DeclCode Code) {
2249 using namespace llvm;
2250
2251 auto Abv = std::make_shared<BitCodeAbbrev>();
2252 Abv->Add(BitCodeAbbrevOp(Code));
2253 // RedeclarableDecl
2254 Abv->Add(BitCodeAbbrevOp(0)); // CanonicalDecl
2255 Abv->Add(BitCodeAbbrevOp(Kind));
2256 if constexpr (Kind == FunctionDecl::TK_NonTemplate) {
2257
2258 } else if constexpr (Kind == FunctionDecl::TK_FunctionTemplate) {
2259 // DescribedFunctionTemplate
2260 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2261 } else if constexpr (Kind == FunctionDecl::TK_DependentNonTemplate) {
2262 // Instantiated From Decl
2263 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2264 } else if constexpr (Kind == FunctionDecl::TK_MemberSpecialization) {
2265 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedFrom
2266 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2267 3)); // TemplateSpecializationKind
2268 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Specialized Location
2269 } else if constexpr (Kind ==
2271 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template
2272 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2273 3)); // TemplateSpecializationKind
2274 Abv->Add(BitCodeAbbrevOp(1)); // Template Argument Size
2275 Abv->Add(BitCodeAbbrevOp(TemplateArgument::Type)); // Template Argument Kind
2276 Abv->Add(
2277 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Template Argument Type
2278 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Is Defaulted
2279 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2280 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2281 Abv->Add(BitCodeAbbrevOp(0));
2282 Abv->Add(
2283 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Canonical Decl of template
2284 } else if constexpr (Kind == FunctionDecl::
2286 // Candidates of specialization
2287 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2288 Abv->Add(BitCodeAbbrevOp(0)); // TemplateArgumentsAsWritten
2289 } else {
2290 llvm_unreachable("Unknown templated kind?");
2291 }
2292 // Decl
2293 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2294 8)); // Packed DeclBits: ModuleOwnershipKind,
2295 // isUsed, isReferenced, AccessSpecifier,
2296 // isImplicit
2297 //
2298 // The following bits should be 0:
2299 // HasStandaloneLexicalDC, HasAttrs,
2300 // TopLevelDeclInObjCContainer,
2301 // isInvalidDecl
2302 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2303 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2304 // NamedDecl
2305 Abv->Add(BitCodeAbbrevOp(DeclarationName::Identifier)); // NameKind
2306 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Identifier
2307 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2308 // ValueDecl
2309 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2310 // DeclaratorDecl
2311 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerLocStart
2312 Abv->Add(BitCodeAbbrevOp(0)); // HasExtInfo
2313 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2314 // FunctionDecl
2315 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2316 Abv->Add(BitCodeAbbrevOp(
2317 BitCodeAbbrevOp::Fixed,
2318 28)); // Packed Function Bits: StorageClass, Inline, InlineSpecified,
2319 // VirtualAsWritten, Pure, HasInheritedProto, HasWrittenProto,
2320 // Deleted, Trivial, TrivialForCall, Defaulted, ExplicitlyDefaulted,
2321 // IsIneligibleOrNotSelected, ImplicitReturnZero, Constexpr,
2322 // UsesSEHTry, SkippedBody, MultiVersion, LateParsed,
2323 // FriendConstraintRefersToEnclosingTemplate, Linkage,
2324 // ShouldSkipCheckingODR
2325 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LocEnd
2326 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // ODRHash
2327 // This Array slurps the rest of the record. Fortunately we want to encode
2328 // (nearly) all the remaining (variable number of) fields in the same way.
2329 //
2330 // This is:
2331 // NumParams and Params[] from FunctionDecl, and
2332 // NumOverriddenMethods, OverriddenMethods[] from CXXMethodDecl.
2333 //
2334 // Add an AbbrevOp for 'size then elements' and use it here.
2335 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2336 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2337 return Abv;
2338}
2339
2340template <FunctionDecl::TemplatedKind Kind>
2341std::shared_ptr<llvm::BitCodeAbbrev> getCXXMethodAbbrev() {
2342 return getFunctionDeclAbbrev<Kind>(serialization::DECL_CXX_METHOD);
2343}
2344} // namespace
2345
2346void ASTWriter::WriteDeclAbbrevs() {
2347 using namespace llvm;
2348
2349 std::shared_ptr<BitCodeAbbrev> Abv;
2350
2351 // Abbreviation for DECL_FIELD
2352 Abv = std::make_shared<BitCodeAbbrev>();
2353 Abv->Add(BitCodeAbbrevOp(serialization::DECL_FIELD));
2354 // Decl
2355 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2356 7)); // Packed DeclBits: ModuleOwnershipKind,
2357 // isUsed, isReferenced, AccessSpecifier,
2358 //
2359 // The following bits should be 0:
2360 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2361 // TopLevelDeclInObjCContainer,
2362 // isInvalidDecl
2363 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2364 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2365 // NamedDecl
2366 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2367 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2368 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2369 // ValueDecl
2370 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2371 // DeclaratorDecl
2372 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2373 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2374 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2375 // FieldDecl
2376 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2377 Abv->Add(BitCodeAbbrevOp(0)); // StorageKind
2378 // Type Source Info
2379 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2380 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2381 DeclFieldAbbrev = Stream.EmitAbbrev(std::move(Abv));
2382
2383 // Abbreviation for DECL_OBJC_IVAR
2384 Abv = std::make_shared<BitCodeAbbrev>();
2385 Abv->Add(BitCodeAbbrevOp(serialization::DECL_OBJC_IVAR));
2386 // Decl
2387 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2388 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2389 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2390 // isReferenced, TopLevelDeclInObjCContainer,
2391 // AccessSpecifier, ModuleOwnershipKind
2392 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2393 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2394 // NamedDecl
2395 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2396 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2397 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2398 // ValueDecl
2399 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2400 // DeclaratorDecl
2401 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2402 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2403 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2404 // FieldDecl
2405 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
2406 Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
2407 // ObjC Ivar
2408 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getAccessControl
2409 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getSynthesize
2410 // Type Source Info
2411 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2412 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2413 DeclObjCIvarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2414
2415 // Abbreviation for DECL_ENUM
2416 Abv = std::make_shared<BitCodeAbbrev>();
2417 Abv->Add(BitCodeAbbrevOp(serialization::DECL_ENUM));
2418 // Redeclarable
2419 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2420 // Decl
2421 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2422 7)); // Packed DeclBits: ModuleOwnershipKind,
2423 // isUsed, isReferenced, AccessSpecifier,
2424 //
2425 // The following bits should be 0:
2426 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2427 // TopLevelDeclInObjCContainer,
2428 // isInvalidDecl
2429 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2430 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2431 // NamedDecl
2432 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2433 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2434 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2435 // TypeDecl
2436 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2437 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2438 // TagDecl
2439 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2440 Abv->Add(BitCodeAbbrevOp(
2441 BitCodeAbbrevOp::Fixed,
2442 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2443 // EmbeddedInDeclarator, IsFreeStanding,
2444 // isCompleteDefinitionRequired, ExtInfoKind
2445 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2446 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2447 // EnumDecl
2448 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
2449 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IntegerType
2450 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getPromotionType
2451 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 20)); // Enum Decl Bits
2452 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));// ODRHash
2453 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InstantiatedMembEnum
2454 // DC
2455 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2456 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2457 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2458 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2459 DeclEnumAbbrev = Stream.EmitAbbrev(std::move(Abv));
2460
2461 // Abbreviation for DECL_RECORD
2462 Abv = std::make_shared<BitCodeAbbrev>();
2463 Abv->Add(BitCodeAbbrevOp(serialization::DECL_RECORD));
2464 // Redeclarable
2465 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2466 // Decl
2467 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2468 7)); // Packed DeclBits: ModuleOwnershipKind,
2469 // isUsed, isReferenced, AccessSpecifier,
2470 //
2471 // The following bits should be 0:
2472 // isImplicit, HasStandaloneLexicalDC, HasAttrs,
2473 // TopLevelDeclInObjCContainer,
2474 // isInvalidDecl
2475 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2476 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2477 // NamedDecl
2478 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2479 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2480 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2481 // TypeDecl
2482 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2483 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2484 // TagDecl
2485 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // IdentifierNamespace
2486 Abv->Add(BitCodeAbbrevOp(
2487 BitCodeAbbrevOp::Fixed,
2488 9)); // Packed Tag Decl Bits: getTagKind, isCompleteDefinition,
2489 // EmbeddedInDeclarator, IsFreeStanding,
2490 // isCompleteDefinitionRequired, ExtInfoKind
2491 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2492 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
2493 // RecordDecl
2494 Abv->Add(BitCodeAbbrevOp(
2495 BitCodeAbbrevOp::Fixed,
2496 13)); // Packed Record Decl Bits: FlexibleArrayMember,
2497 // AnonymousStructUnion, hasObjectMember, hasVolatileMember,
2498 // isNonTrivialToPrimitiveDefaultInitialize,
2499 // isNonTrivialToPrimitiveCopy, isNonTrivialToPrimitiveDestroy,
2500 // hasNonTrivialToPrimitiveDefaultInitializeCUnion,
2501 // hasNonTrivialToPrimitiveDestructCUnion,
2502 // hasNonTrivialToPrimitiveCopyCUnion,
2503 // hasUninitializedExplicitInitFields, isParamDestroyedInCallee,
2504 // getArgPassingRestrictions
2505 // ODRHash
2506 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 26));
2507
2508 // DC
2509 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalOffset
2510 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // VisibleOffset
2511 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ModuleLocalOffset
2512 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TULocalOffset
2513 DeclRecordAbbrev = Stream.EmitAbbrev(std::move(Abv));
2514
2515 // Abbreviation for DECL_PARM_VAR
2516 Abv = std::make_shared<BitCodeAbbrev>();
2517 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR));
2518 // Redeclarable
2519 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2520 // Decl
2521 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2522 8)); // Packed DeclBits: ModuleOwnershipKind, isUsed,
2523 // isReferenced, AccessSpecifier,
2524 // HasStandaloneLexicalDC, HasAttrs, isImplicit,
2525 // TopLevelDeclInObjCContainer,
2526 // isInvalidDecl,
2527 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2528 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2529 // NamedDecl
2530 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2531 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2532 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2533 // ValueDecl
2534 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2535 // DeclaratorDecl
2536 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2537 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2538 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2539 // VarDecl
2540 Abv->Add(
2541 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2542 12)); // Packed Var Decl bits: SClass, TSCSpec, InitStyle,
2543 // isARCPseudoStrong, Linkage, ModulesCodegen
2544 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2545 // ParmVarDecl
2546 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex
2547 Abv->Add(BitCodeAbbrevOp(
2548 BitCodeAbbrevOp::Fixed,
2549 19)); // Packed Parm Var Decl bits: IsObjCMethodParameter, ScopeDepth,
2550 // ObjCDeclQualifier, KNRPromoted,
2551 // HasInheritedDefaultArg, HasUninstantiatedDefaultArg
2552 // Type Source Info
2553 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2554 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2555 DeclParmVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2556
2557 // Abbreviation for DECL_TYPEDEF
2558 Abv = std::make_shared<BitCodeAbbrev>();
2559 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TYPEDEF));
2560 // Redeclarable
2561 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2562 // Decl
2563 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2564 7)); // Packed DeclBits: ModuleOwnershipKind,
2565 // isReferenced, isUsed, AccessSpecifier. Other
2566 // higher bits should be 0: isImplicit,
2567 // HasStandaloneLexicalDC, HasAttrs,
2568 // TopLevelDeclInObjCContainer, isInvalidDecl
2569 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2570 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2571 // NamedDecl
2572 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2573 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2574 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2575 // TypeDecl
2576 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2577 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2578 // TypedefDecl
2579 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2580 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2581 DeclTypedefAbbrev = Stream.EmitAbbrev(std::move(Abv));
2582
2583 // Abbreviation for DECL_VAR
2584 Abv = std::make_shared<BitCodeAbbrev>();
2585 Abv->Add(BitCodeAbbrevOp(serialization::DECL_VAR));
2586 // Redeclarable
2587 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2588 // Decl
2589 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2590 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2591 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2592 // isReferenced, TopLevelDeclInObjCContainer,
2593 // AccessSpecifier, ModuleOwnershipKind
2594 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2595 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2596 // NamedDecl
2597 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2598 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2599 Abv->Add(BitCodeAbbrevOp(0)); // AnonDeclNumber
2600 // ValueDecl
2601 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2602 // DeclaratorDecl
2603 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
2604 Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
2605 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TSIType
2606 // VarDecl
2607 Abv->Add(BitCodeAbbrevOp(
2608 BitCodeAbbrevOp::Fixed,
2609 21)); // Packed Var Decl bits: Linkage, ModulesCodegen,
2610 // SClass, TSCSpec, InitStyle,
2611 // isARCPseudoStrong, IsThisDeclarationADemotedDefinition,
2612 // isExceptionVariable, isNRVOVariable, isCXXForRangeDecl,
2613 // isInline, isInlineSpecified, isConstexpr,
2614 // isInitCapture, isPrevDeclInSameScope,
2615 // EscapingByref, HasDeducedType, ImplicitParamKind, isObjCForDecl
2616 Abv->Add(BitCodeAbbrevOp(0)); // VarKind (local enum)
2617 // Type Source Info
2618 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
2619 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
2620 DeclVarAbbrev = Stream.EmitAbbrev(std::move(Abv));
2621
2622 // Abbreviation for DECL_CXX_METHOD
2623 DeclCXXMethodAbbrev =
2624 Stream.EmitAbbrev(getCXXMethodAbbrev<FunctionDecl::TK_NonTemplate>());
2625 DeclTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2626 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplate>());
2627 DeclDependentNonTemplateCXXMethodAbbrev = Stream.EmitAbbrev(
2628 getCXXMethodAbbrev<FunctionDecl::TK_DependentNonTemplate>());
2629 DeclMemberSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2630 getCXXMethodAbbrev<FunctionDecl::TK_MemberSpecialization>());
2631 DeclTemplateSpecializedCXXMethodAbbrev = Stream.EmitAbbrev(
2632 getCXXMethodAbbrev<FunctionDecl::TK_FunctionTemplateSpecialization>());
2633 DeclDependentSpecializationCXXMethodAbbrev = Stream.EmitAbbrev(
2634 getCXXMethodAbbrev<
2636
2637 // Abbreviation for DECL_TEMPLATE_TYPE_PARM
2638 Abv = std::make_shared<BitCodeAbbrev>();
2639 Abv->Add(BitCodeAbbrevOp(serialization::DECL_TEMPLATE_TYPE_PARM));
2640 Abv->Add(BitCodeAbbrevOp(0)); // hasTypeConstraint
2641 // Decl
2642 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2643 7)); // Packed DeclBits: ModuleOwnershipKind,
2644 // isReferenced, isUsed, AccessSpecifier. Other
2645 // higher bits should be 0: isImplicit,
2646 // HasStandaloneLexicalDC, HasAttrs,
2647 // TopLevelDeclInObjCContainer, isInvalidDecl
2648 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2649 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2650 // NamedDecl
2651 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2652 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2653 Abv->Add(BitCodeAbbrevOp(0));
2654 // TypeDecl
2655 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2656 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Ref
2657 // TemplateTypeParmDecl
2658 Abv->Add(
2659 BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // wasDeclaredWithTypename
2660 Abv->Add(BitCodeAbbrevOp(0)); // OwnsDefaultArg
2661 DeclTemplateTypeParmAbbrev = Stream.EmitAbbrev(std::move(Abv));
2662
2663 // Abbreviation for DECL_USING_SHADOW
2664 Abv = std::make_shared<BitCodeAbbrev>();
2665 Abv->Add(BitCodeAbbrevOp(serialization::DECL_USING_SHADOW));
2666 // Redeclarable
2667 Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration
2668 // Decl
2669 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
2670 12)); // Packed DeclBits: HasStandaloneLexicalDC,
2671 // isInvalidDecl, HasAttrs, isImplicit, isUsed,
2672 // isReferenced, TopLevelDeclInObjCContainer,
2673 // AccessSpecifier, ModuleOwnershipKind
2674 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext
2675 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SubmoduleID
2676 // NamedDecl
2677 Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
2678 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
2679 Abv->Add(BitCodeAbbrevOp(0));
2680 // UsingShadowDecl
2681 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TargetDecl
2682 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 11)); // IDNS
2683 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // UsingOrNextShadow
2684 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR,
2685 6)); // InstantiatedFromUsingShadowDecl
2686 DeclUsingShadowAbbrev = Stream.EmitAbbrev(std::move(Abv));
2687
2688 // Abbreviation for EXPR_DECL_REF
2689 Abv = std::make_shared<BitCodeAbbrev>();
2690 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF));
2691 // Stmt
2692 // Expr
2693 // PackingBits: DependenceKind, ValueKind. ObjectKind should be 0.
2694 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2695 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2696 // DeclRefExpr
2697 // Packing Bits: , HadMultipleCandidates, RefersToEnclosingVariableOrCapture,
2698 // IsImmediateEscalating, NonOdrUseReason.
2699 // GetDeclFound, HasQualifier and ExplicitTemplateArgs should be 0.
2700 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2701 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclRef
2702 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2703 DeclRefExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2704
2705 // Abbreviation for EXPR_INTEGER_LITERAL
2706 Abv = std::make_shared<BitCodeAbbrev>();
2707 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL));
2708 //Stmt
2709 // Expr
2710 // DependenceKind, ValueKind, ObjectKind
2711 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2712 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2713 // Integer Literal
2714 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2715 Abv->Add(BitCodeAbbrevOp(32)); // Bit Width
2716 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Value
2717 IntegerLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2718
2719 // Abbreviation for EXPR_CHARACTER_LITERAL
2720 Abv = std::make_shared<BitCodeAbbrev>();
2721 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL));
2722 //Stmt
2723 // Expr
2724 // DependenceKind, ValueKind, ObjectKind
2725 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2726 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2727 // Character Literal
2728 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // getValue
2729 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location
2730 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // getKind
2731 CharacterLiteralAbbrev = Stream.EmitAbbrev(std::move(Abv));
2732
2733 // Abbreviation for EXPR_IMPLICIT_CAST
2734 Abv = std::make_shared<BitCodeAbbrev>();
2735 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST));
2736 // Stmt
2737 // Expr
2738 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2739 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2740 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2741 // CastExpr
2742 Abv->Add(BitCodeAbbrevOp(0)); // PathSize
2743 // Packing Bits: CastKind, StoredFPFeatures, isPartOfExplicitCast
2744 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 9));
2745 // ImplicitCastExpr
2746 ExprImplicitCastAbbrev = Stream.EmitAbbrev(std::move(Abv));
2747
2748 // Abbreviation for EXPR_BINARY_OPERATOR
2749 Abv = std::make_shared<BitCodeAbbrev>();
2750 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_BINARY_OPERATOR));
2751 // Stmt
2752 // Expr
2753 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2754 // be 0 in this case.
2755 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2756 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2757 // BinaryOperator
2758 Abv->Add(
2759 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2760 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2761 BinaryOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2762
2763 // Abbreviation for EXPR_COMPOUND_ASSIGN_OPERATOR
2764 Abv = std::make_shared<BitCodeAbbrev>();
2765 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_COMPOUND_ASSIGN_OPERATOR));
2766 // Stmt
2767 // Expr
2768 // Packing Bits: DependenceKind. ValueKind and ObjectKind should
2769 // be 0 in this case.
2770 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5));
2771 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2772 // BinaryOperator
2773 // Packing Bits: OpCode. The HasFPFeatures bit should be 0
2774 Abv->Add(
2775 BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpCode and HasFPFeatures
2776 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2777 // CompoundAssignOperator
2778 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHSType
2779 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Result Type
2780 CompoundAssignOperatorAbbrev = Stream.EmitAbbrev(std::move(Abv));
2781
2782 // Abbreviation for EXPR_CALL
2783 Abv = std::make_shared<BitCodeAbbrev>();
2784 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CALL));
2785 // Stmt
2786 // Expr
2787 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2788 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2789 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2790 // CallExpr
2791 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2792 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2793 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2794 CallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2795
2796 // Abbreviation for EXPR_CXX_OPERATOR_CALL
2797 Abv = std::make_shared<BitCodeAbbrev>();
2798 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_OPERATOR_CALL));
2799 // Stmt
2800 // Expr
2801 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2802 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2803 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2804 // CallExpr
2805 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2806 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2807 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2808 // CXXOperatorCallExpr
2809 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Operator Kind
2810 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2811 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2812 CXXOperatorCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2813
2814 // Abbreviation for EXPR_CXX_MEMBER_CALL
2815 Abv = std::make_shared<BitCodeAbbrev>();
2816 Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CXX_MEMBER_CALL));
2817 // Stmt
2818 // Expr
2819 // Packing Bits: DependenceKind, ValueKind, ObjectKind,
2820 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10));
2821 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type
2822 // CallExpr
2823 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // NumArgs
2824 Abv->Add(BitCodeAbbrevOp(0)); // ADLCallKind
2825 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2826 // CXXMemberCallExpr
2827 CXXMemberCallExprAbbrev = Stream.EmitAbbrev(std::move(Abv));
2828
2829 // Abbreviation for STMT_COMPOUND
2830 Abv = std::make_shared<BitCodeAbbrev>();
2831 Abv->Add(BitCodeAbbrevOp(serialization::STMT_COMPOUND));
2832 // Stmt
2833 // CompoundStmt
2834 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Num Stmts
2835 Abv->Add(BitCodeAbbrevOp(0)); // hasStoredFPFeatures
2836 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2837 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Source Location
2838 CompoundStmtAbbrev = Stream.EmitAbbrev(std::move(Abv));
2839
2840 Abv = std::make_shared<BitCodeAbbrev>();
2841 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL));
2842 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2843 DeclContextLexicalAbbrev = Stream.EmitAbbrev(std::move(Abv));
2844
2845 Abv = std::make_shared<BitCodeAbbrev>();
2846 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE));
2847 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2848 DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2849
2850 Abv = std::make_shared<BitCodeAbbrev>();
2851 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_MODULE_LOCAL_VISIBLE));
2852 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2853 DeclModuleLocalVisibleLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2854
2855 Abv = std::make_shared<BitCodeAbbrev>();
2856 Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_TU_LOCAL_VISIBLE));
2857 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2858 DeclTULocalLookupAbbrev = Stream.EmitAbbrev(std::move(Abv));
2859
2860 Abv = std::make_shared<BitCodeAbbrev>();
2861 Abv->Add(BitCodeAbbrevOp(serialization::DECL_SPECIALIZATIONS));
2862 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2863 DeclSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2864
2865 Abv = std::make_shared<BitCodeAbbrev>();
2866 Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARTIAL_SPECIALIZATIONS));
2867 Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
2868 DeclPartialSpecializationsAbbrev = Stream.EmitAbbrev(std::move(Abv));
2869}
2870
2871/// isRequiredDecl - Check if this is a "required" Decl, which must be seen by
2872/// consumers of the AST.
2873///
2874/// Such decls will always be deserialized from the AST file, so we would like
2875/// this to be as restrictive as possible. Currently the predicate is driven by
2876/// code generation requirements, if other clients have a different notion of
2877/// what is "required" then we may have to consider an alternate scheme where
2878/// clients can iterate over the top-level decls and get information on them,
2879/// without necessary deserializing them. We could explicitly require such
2880/// clients to use a separate API call to "realize" the decl. This should be
2881/// relatively painless since they would presumably only do it for top-level
2882/// decls.
2883static bool isRequiredDecl(const Decl *D, ASTContext &Context,
2884 Module *WritingModule) {
2885 // Named modules have different semantics than header modules. Every named
2886 // module units owns a translation unit. So the importer of named modules
2887 // doesn't need to deserilize everything ahead of time.
2888 if (WritingModule && WritingModule->isNamedModule()) {
2889 // The PragmaCommentDecl and PragmaDetectMismatchDecl are MSVC's extension.
2890 // And the behavior of MSVC for such cases will leak this to the module
2891 // users. Given pragma is not a standard thing, the compiler has the space
2892 // to do their own decision. Let's follow MSVC here.
2893 if (isa<PragmaCommentDecl, PragmaDetectMismatchDecl>(D))
2894 return true;
2895 return false;
2896 }
2897
2898 // An ObjCMethodDecl is never considered as "required" because its
2899 // implementation container always is.
2900
2901 // File scoped assembly or obj-c or OMP declare target implementation must be
2902 // seen.
2903 if (isa<FileScopeAsmDecl, TopLevelStmtDecl, ObjCImplDecl>(D))
2904 return true;
2905
2906 if (WritingModule && isPartOfPerModuleInitializer(D)) {
2907 // These declarations are part of the module initializer, and are emitted
2908 // if and when the module is imported, rather than being emitted eagerly.
2909 return false;
2910 }
2911
2912 return Context.DeclMustBeEmitted(D);
2913}
2914
2915void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
2916 PrettyDeclStackTraceEntry CrashInfo(Context, D, SourceLocation(),
2917 "serializing");
2918
2919 // Determine the ID for this declaration.
2921 assert(!D->isFromASTFile() && "should not be emitting imported decl");
2922 LocalDeclID &IDR = DeclIDs[D];
2923 if (IDR.isInvalid())
2924 IDR = NextDeclID++;
2925
2926 ID = IDR;
2927
2928 assert(ID >= FirstDeclID && "invalid decl ID");
2929
2931 ASTDeclWriter W(*this, Context, Record, GeneratingReducedBMI);
2932
2933 // Build a record for this declaration
2934 W.Visit(D);
2935
2936 // Emit this declaration to the bitstream.
2937 uint64_t Offset = W.Emit(D);
2938
2939 // Record the offset for this declaration
2942 getRawSourceLocationEncoding(getAdjustedLocation(Loc));
2943
2944 unsigned Index = ID.getRawValue() - FirstDeclID.getRawValue();
2945 if (DeclOffsets.size() == Index)
2946 DeclOffsets.emplace_back(RawLoc, Offset, DeclTypesBlockStartOffset);
2947 else if (DeclOffsets.size() < Index) {
2948 // FIXME: Can/should this happen?
2949 DeclOffsets.resize(Index+1);
2950 DeclOffsets[Index].setRawLoc(RawLoc);
2951 DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
2952 } else {
2953 llvm_unreachable("declarations should be emitted in ID order");
2954 }
2955
2956 SourceManager &SM = Context.getSourceManager();
2957 if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
2958 associateDeclWithFile(D, ID);
2959
2960 // Note declarations that should be deserialized eagerly so that we can add
2961 // them to a record in the AST file later.
2962 if (isRequiredDecl(D, Context, WritingModule))
2963 AddDeclRef(D, EagerlyDeserializedDecls);
2964}
2965
2967 // Switch case IDs are per function body.
2968 Writer->ClearSwitchCaseIDs();
2969
2970 assert(FD->doesThisDeclarationHaveABody());
2971 bool ModulesCodegen = false;
2972 if (!FD->isDependentContext()) {
2973 std::optional<GVALinkage> Linkage;
2974 if (Writer->WritingModule &&
2975 Writer->WritingModule->isInterfaceOrPartition()) {
2976 // When building a C++20 module interface unit or a partition unit, a
2977 // strong definition in the module interface is provided by the
2978 // compilation of that unit, not by its users. (Inline functions are still
2979 // emitted in module users.)
2980 Linkage = getASTContext().GetGVALinkageForFunction(FD);
2981 ModulesCodegen = *Linkage >= GVA_StrongExternal;
2982 }
2983 if (Writer->getLangOpts().ModulesCodegen ||
2984 (FD->hasAttr<DLLExportAttr>() &&
2985 Writer->getLangOpts().BuildingPCHWithObjectFile)) {
2986
2987 // Under -fmodules-codegen, codegen is performed for all non-internal,
2988 // non-always_inline functions, unless they are available elsewhere.
2989 if (!FD->hasAttr<AlwaysInlineAttr>()) {
2990 if (!Linkage)
2991 Linkage = getASTContext().GetGVALinkageForFunction(FD);
2992 ModulesCodegen =
2994 }
2995 }
2996 }
2997 Record->push_back(ModulesCodegen);
2998 if (ModulesCodegen)
2999 Writer->AddDeclRef(FD, Writer->ModularCodegenDecls);
3000 if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
3001 Record->push_back(CD->getNumCtorInitializers());
3002 if (CD->getNumCtorInitializers())
3003 AddCXXCtorInitializers(llvm::ArrayRef(CD->init_begin(), CD->init_end()));
3004 }
3005 AddStmt(FD->getBody());
3006}
NodeId Parent
Definition: ASTDiff.cpp:191
StringRef P
static void addExplicitSpecifier(ExplicitSpecifier ES, ASTRecordWriter &Record)
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.
#define SM(sm)
Definition: Cuda.cpp:85
const Decl * D
Expr * E
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
llvm::MachO::Record Record
Definition: MachO.h:31
This file defines OpenMP AST classes for clauses.
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines the SourceManager interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
SourceManager & getSourceManager()
Definition: ASTContext.h:741
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
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 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 VisitDecl(Decl *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)
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 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)
ModuleFile * getOwningModuleFile(const Decl *D) const
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:8015
bool haveUnloadedSpecializations(const Decl *D) const
If we have any unloaded specialization for D.
Definition: ASTReader.cpp:8585
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.
Definition: ASTWriter.cpp:7165
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:89
unsigned getDeclParmVarAbbrev() const
Definition: ASTWriter.h:849
unsigned getDeclTemplateTypeParmAbbrev() const
Definition: ASTWriter.h:873
bool isWritingStdCXXNamedModules() const
Definition: ASTWriter.h:897
unsigned getDeclObjCIvarAbbrev() const
Definition: ASTWriter.h:855
unsigned getDeclTypedefAbbrev() const
Definition: ASTWriter.h:851
bool hasChain() const
Definition: ASTWriter.h:892
unsigned getDeclUsingShadowAbbrev() const
Definition: ASTWriter.h:876
bool isGeneratingReducedBMI() const
Definition: ASTWriter.h:901
unsigned getDeclVarAbbrev() const
Definition: ASTWriter.h:852
unsigned getDeclEnumAbbrev() const
Definition: ASTWriter.h:854
bool IsLocalDecl(const Decl *D)
Is this a local declaration (that is, one that will be written to our AST file)? This is the case for...
Definition: ASTWriter.h:772
LocalDeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its local ID to the module file been writing.
Definition: ASTWriter.cpp:6829
unsigned getDeclCXXMethodAbbrev(FunctionDecl::TemplatedKind Kind) const
Definition: ASTWriter.h:856
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
SourceLocationEncoding::RawLocEncoding getRawSourceLocationEncoding(SourceLocation Loc, LocSeq *Seq=nullptr)
Return the raw encodings for source locations.
Definition: ASTWriter.cpp:6600
SmallVector< uint64_t, 64 > RecordData
Definition: ASTWriter.h:94
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
Definition: ASTWriter.cpp:6937
unsigned getDeclFieldAbbrev() const
Definition: ASTWriter.h:853
const LangOptions & getLangOpts() const
Definition: ASTWriter.cpp:5345
unsigned getDeclRecordAbbrev() const
Definition: ASTWriter.h:850
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Definition: ASTWriter.cpp:6825
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:86
A binding in a decomposition declaration.
Definition: DeclCXX.h:4130
A simple helper class to pack several bits in order into (a) 32 bit integer(s).
Definition: ASTWriter.h:1049
void addBit(bool Value)
Definition: ASTWriter.h:1069
void addBits(uint32_t Value, uint32_t BitsWidth)
Definition: ASTWriter.h:1070
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4496
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2553
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2885
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1967
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2817
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2078
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
static bool classofKind(Kind K)
Definition: DeclCXX.h:1904
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4772
unsigned getNumParams() const
Definition: Decl.h:4814
unsigned getContextParamPosition() const
Definition: Decl.h:4843
bool isNothrow() const
Definition: Decl.cpp:5510
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4816
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
Declaration of a C++20 concept.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
Definition: DeclCXX.h:3621
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:1439
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1345
@ NumOMPDeclareReductionDeclBits
Definition: DeclBase.h:1722
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
Definition: DeclBase.cpp:1939
DeclID getRawValue() const
Definition: DeclID.h:118
bool isInvalid() const
Definition: DeclID.h:126
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:67
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:1054
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:1069
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:438
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:645
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Definition: DeclBase.h:1219
bool hasAttrs() const
Definition: DeclBase.h:521
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:596
bool isInNamedModule() const
Whether this declaration comes from a named module.
Definition: DeclBase.cpp:1173
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:869
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:247
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: DeclBase.h:1080
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:582
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:977
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:835
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: DeclBase.h:1063
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:786
bool isInvalidDecl() const
Definition: DeclBase.h:591
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:882
SourceLocation getLocation() const
Definition: DeclBase.h:442
const char * getDeclKindName() const
Definition: DeclBase.cpp:150
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc....
Definition: DeclBase.h:631
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
Definition: DeclBase.cpp:557
DeclContext * getDeclContext()
Definition: DeclBase.h:451
AccessSpecifier getAccess() const
Definition: DeclBase.h:510
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:434
AttrVec & getAttrs()
Definition: DeclBase.h:527
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:911
bool hasAttr() const
Definition: DeclBase.h:580
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:971
Kind getKind() const
Definition: DeclBase.h:445
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:735
A decomposition declaration.
Definition: DeclCXX.h:4189
Provides information about a dependent function-template specialization declaration.
Definition: DeclTemplate.h:693
ArrayRef< FunctionTemplateDecl * > getCandidates() const
Returns the candidates for the primary function template.
Definition: DeclTemplate.h:712
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:705
Represents an empty-declaration.
Definition: Decl.h:5011
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3291
Represents an enum.
Definition: Decl.h:3861
Store information needed for an explicit specifier.
Definition: DeclCXX.h:1912
ExplicitSpecKind getKind() const
Definition: DeclCXX.h:1920
const Expr * getExpr() const
Definition: DeclCXX.h:1921
Represents a standard C++ module export declaration.
Definition: Decl.h:4964
This represents one expression.
Definition: Expr.h:110
Represents a member of a struct/union/class.
Definition: Decl.h:3033
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition: DeclFriend.h:54
Declaration of a friend template.
Represents a function declaration or definition.
Definition: Decl.h:1935
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:3243
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition: Decl.h:2261
@ TK_MemberSpecialization
Definition: Decl.h:1947
@ TK_DependentNonTemplate
Definition: Decl.h:1956
@ TK_FunctionTemplateSpecialization
Definition: Decl.h:1951
@ TK_DependentFunctionTemplateSpecialization
Definition: Decl.h:1954
Declaration of a template function.
Definition: DeclTemplate.h:958
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:471
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Definition: DeclTemplate.h:485
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Definition: DeclTemplate.h:526
MemberSpecializationInfo * getMemberSpecializationInfo() const
Get the specialization info if this function template specialization is also a member specialization:
Definition: DeclTemplate.h:597
const ASTTemplateArgumentListInfo * TemplateArgumentsAsWritten
The template arguments as written in the sources, if provided.
Definition: DeclTemplate.h:489
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this function template specialization.
Definition: DeclTemplate.h:557
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:529
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition: Decl.h:5026
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4885
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3335
Represents the declaration of a label.
Definition: Decl.h:503
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Definition: DeclCXX.h:3252
Represents a linkage specification.
Definition: DeclCXX.h:2957
A global _GUID constant.
Definition: DeclCXX.h:4312
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4258
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:619
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Definition: DeclTemplate.h:641
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
Definition: DeclTemplate.h:659
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Definition: DeclTemplate.h:638
Describes a module or submodule.
Definition: Module.h:115
bool isInterfaceOrPartition() const
Definition: Module.h:642
bool isNamedModule() const
Does this Module is a named module of a standard named module?
Definition: Module.h:195
This represents a decl that may have a name.
Definition: Decl.h:253
Represents a C++ namespace alias.
Definition: DeclCXX.h:3143
Represent a C++ namespace.
Definition: Decl.h:551
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
This represents '#pragma omp allocate ...' directive.
Definition: DeclOpenMP.h:474
Pseudo declaration for capturing expressions.
Definition: DeclOpenMP.h:383
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:287
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:177
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:417
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:110
Represents a field declaration created by an @defs(...).
Definition: DeclObjC.h:2029
static bool classofKind(Kind K)
Definition: DeclObjC.h:2050
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2328
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2544
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2774
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:947
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2596
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1951
static bool classofKind(Kind K)
Definition: DeclObjC.h:2014
T *const * iterator
Definition: DeclObjC.h:88
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:730
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2804
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
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:659
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:686
SourceLocation getRAngleLoc() const
Definition: DeclObjC.h:710
SourceLocation getLAngleLoc() const
Definition: DeclObjC.h:709
Represents a partial function definition.
Definition: Decl.h:4703
Represents a parameter to a function.
Definition: Decl.h:1725
Represents a #pragma comment line.
Definition: Decl.h:146
Represents a #pragma detect_mismatch line.
Definition: Decl.h:180
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
Definition: Type.h:929
Represents a struct/union/class.
Definition: Decl.h:4162
Declaration of a redeclarable template.
Definition: DeclTemplate.h:720
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
Represents the body of a requires-expression.
Definition: DeclCXX.h:2047
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:4081
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3578
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:286
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Definition: DeclTemplate.h:271
Represents a template argument.
Definition: TemplateBase.h:61
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:295
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:398
A template parameter object.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
A declaration that models statements at global scope.
Definition: Decl.h:4459
The top declaration context.
Definition: Decl.h:84
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Definition: Decl.h:3549
Declaration of an alias template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Definition: ASTConcept.h:227
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Definition: ASTConcept.h:242
ConceptReference * getConceptReference() const
Definition: ASTConcept.h:246
Represents a declaration of a type.
Definition: Decl.h:3384
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Definition: Decl.h:3528
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3427
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Definition: DeclCXX.h:4369
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
Definition: DeclCXX.h:4063
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3982
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3885
Represents a C++ using-declaration.
Definition: DeclCXX.h:3535
Represents C++ using-directive.
Definition: DeclCXX.h:3038
Represents a C++ using-enum-declaration.
Definition: DeclCXX.h:3736
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Definition: DeclCXX.h:3817
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3343
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
Represents a variable declaration or definition.
Definition: Decl.h:882
@ CInit
C-style initialization with assignment.
Definition: Decl.h:887
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
RetTy Visit(PTR(Decl) D)
Definition: DeclVisitor.h:37
const unsigned int LOCAL_REDECLARATIONS
Record code for a list of local redeclarations of a declaration.
Definition: ASTBitCodes.h:1223
DeclCode
Record codes for each kind of declaration.
Definition: ASTBitCodes.h:1231
@ DECL_EMPTY
An EmptyDecl record.
Definition: ASTBitCodes.h:1490
@ DECL_CAPTURED
A CapturedDecl record.
Definition: ASTBitCodes.h:1323
@ DECL_CXX_RECORD
A CXXRecordDecl record.
Definition: ASTBitCodes.h:1392
@ DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION
A VarTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1434
@ DECL_OMP_ALLOCATE
An OMPAllocateDcl record.
Definition: ASTBitCodes.h:1487
@ DECL_MS_PROPERTY
A MSPropertyDecl record.
Definition: ASTBitCodes.h:1287
@ DECL_OMP_DECLARE_MAPPER
An OMPDeclareMapperDecl record.
Definition: ASTBitCodes.h:1511
@ DECL_TOP_LEVEL_STMT_DECL
A TopLevelStmtDecl record.
Definition: ASTBitCodes.h:1314
@ DECL_REQUIRES_EXPR_BODY
A RequiresExprBodyDecl record.
Definition: ASTBitCodes.h:1496
@ DECL_STATIC_ASSERT
A StaticAssertDecl record.
Definition: ASTBitCodes.h:1458
@ DECL_INDIRECTFIELD
A IndirectFieldDecl record.
Definition: ASTBitCodes.h:1467
@ DECL_TEMPLATE_TEMPLATE_PARM
A TemplateTemplateParmDecl record.
Definition: ASTBitCodes.h:1446
@ DECL_IMPORT
An ImportDecl recording a module import.
Definition: ASTBitCodes.h:1478
@ DECL_UNNAMED_GLOBAL_CONSTANT
A UnnamedGlobalConstantDecl record.
Definition: ASTBitCodes.h:1517
@ DECL_ACCESS_SPEC
An AccessSpecDecl record.
Definition: ASTBitCodes.h:1410
@ DECL_OBJC_TYPE_PARAM
An ObjCTypeParamDecl record.
Definition: ASTBitCodes.h:1499
@ DECL_OBJC_CATEGORY_IMPL
A ObjCCategoryImplDecl record.
Definition: ASTBitCodes.h:1269
@ DECL_ENUM_CONSTANT
An EnumConstantDecl record.
Definition: ASTBitCodes.h:1245
@ DECL_PARM_VAR
A ParmVarDecl record.
Definition: ASTBitCodes.h:1302
@ DECL_TYPEDEF
A TypedefDecl record.
Definition: ASTBitCodes.h:1233
@ DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK
A TemplateTemplateParmDecl record that stores an expanded template template parameter pack.
Definition: ASTBitCodes.h:1475
@ DECL_HLSL_BUFFER
A HLSLBufferDecl record.
Definition: ASTBitCodes.h:1520
@ DECL_NAMESPACE_ALIAS
A NamespaceAliasDecl record.
Definition: ASTBitCodes.h:1359
@ DECL_TYPEALIAS
A TypeAliasDecl record.
Definition: ASTBitCodes.h:1236
@ DECL_FUNCTION_TEMPLATE
A FunctionTemplateDecl record.
Definition: ASTBitCodes.h:1437
@ DECL_MS_GUID
A MSGuidDecl record.
Definition: ASTBitCodes.h:1290
@ DECL_UNRESOLVED_USING_TYPENAME
An UnresolvedUsingTypenameDecl record.
Definition: ASTBitCodes.h:1383
@ DECL_CLASS_TEMPLATE_SPECIALIZATION
A ClassTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1422
@ DECL_FILE_SCOPE_ASM
A FileScopeAsmDecl record.
Definition: ASTBitCodes.h:1311
@ DECL_CXX_CONSTRUCTOR
A CXXConstructorDecl record.
Definition: ASTBitCodes.h:1401
@ DECL_CXX_CONVERSION
A CXXConversionDecl record.
Definition: ASTBitCodes.h:1407
@ DECL_FIELD
A FieldDecl record.
Definition: ASTBitCodes.h:1284
@ DECL_LINKAGE_SPEC
A LinkageSpecDecl record.
Definition: ASTBitCodes.h:1386
@ DECL_CONTEXT_TU_LOCAL_VISIBLE
A record that stores the set of declarations that are only visible to the TU.
Definition: ASTBitCodes.h:1350
@ DECL_NAMESPACE
A NamespaceDecl record.
Definition: ASTBitCodes.h:1356
@ DECL_NON_TYPE_TEMPLATE_PARM
A NonTypeTemplateParmDecl record.
Definition: ASTBitCodes.h:1443
@ DECL_USING_PACK
A UsingPackDecl record.
Definition: ASTBitCodes.h:1368
@ DECL_FUNCTION
A FunctionDecl record.
Definition: ASTBitCodes.h:1248
@ DECL_USING_DIRECTIVE
A UsingDirecitveDecl record.
Definition: ASTBitCodes.h:1377
@ DECL_RECORD
A RecordDecl record.
Definition: ASTBitCodes.h:1242
@ DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext.
Definition: ASTBitCodes.h:1333
@ DECL_OUTLINEDFUNCTION
A OutlinedFunctionDecl record.
Definition: ASTBitCodes.h:1320
@ DECL_BLOCK
A BlockDecl record.
Definition: ASTBitCodes.h:1317
@ DECL_UNRESOLVED_USING_VALUE
An UnresolvedUsingValueDecl record.
Definition: ASTBitCodes.h:1380
@ DECL_TYPE_ALIAS_TEMPLATE
A TypeAliasTemplateDecl record.
Definition: ASTBitCodes.h:1449
@ DECL_OBJC_CATEGORY
A ObjCCategoryDecl record.
Definition: ASTBitCodes.h:1266
@ DECL_VAR
A VarDecl record.
Definition: ASTBitCodes.h:1296
@ DECL_UNRESOLVED_USING_IF_EXISTS
An UnresolvedUsingIfExistsDecl record.
Definition: ASTBitCodes.h:1455
@ DECL_USING
A UsingDecl record.
Definition: ASTBitCodes.h:1362
@ DECL_OBJC_PROTOCOL
A ObjCProtocolDecl record.
Definition: ASTBitCodes.h:1257
@ DECL_TEMPLATE_TYPE_PARM
A TemplateTypeParmDecl record.
Definition: ASTBitCodes.h:1440
@ DECL_VAR_TEMPLATE_SPECIALIZATION
A VarTemplateSpecializationDecl record.
Definition: ASTBitCodes.h:1431
@ DECL_OBJC_IMPLEMENTATION
A ObjCImplementationDecl record.
Definition: ASTBitCodes.h:1272
@ DECL_LABEL
A LabelDecl record.
Definition: ASTBitCodes.h:1353
@ DECL_OBJC_COMPATIBLE_ALIAS
A ObjCCompatibleAliasDecl record.
Definition: ASTBitCodes.h:1275
@ DECL_CONSTRUCTOR_USING_SHADOW
A ConstructorUsingShadowDecl record.
Definition: ASTBitCodes.h:1374
@ DECL_USING_ENUM
A UsingEnumDecl record.
Definition: ASTBitCodes.h:1365
@ DECL_FRIEND_TEMPLATE
A FriendTemplateDecl record.
Definition: ASTBitCodes.h:1416
@ DECL_PRAGMA_DETECT_MISMATCH
A PragmaDetectMismatchDecl record.
Definition: ASTBitCodes.h:1508
@ DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK
A NonTypeTemplateParmDecl record that stores an expanded non-type template parameter pack.
Definition: ASTBitCodes.h:1471
@ DECL_OBJC_AT_DEFS_FIELD
A ObjCAtDefsFieldDecl record.
Definition: ASTBitCodes.h:1263
@ DECL_IMPLICIT_PARAM
An ImplicitParamDecl record.
Definition: ASTBitCodes.h:1299
@ DECL_FRIEND
A FriendDecl record.
Definition: ASTBitCodes.h:1413
@ DECL_CXX_METHOD
A CXXMethodDecl record.
Definition: ASTBitCodes.h:1398
@ DECL_EXPORT
An ExportDecl record.
Definition: ASTBitCodes.h:1389
@ DECL_BINDING
A BindingDecl record.
Definition: ASTBitCodes.h:1308
@ DECL_PRAGMA_COMMENT
A PragmaCommentDecl record.
Definition: ASTBitCodes.h:1505
@ DECL_ENUM
An EnumDecl record.
Definition: ASTBitCodes.h:1239
@ DECL_CONTEXT_MODULE_LOCAL_VISIBLE
A record containing the set of declarations that are only visible from DeclContext in the same module...
Definition: ASTBitCodes.h:1346
@ DECL_DECOMPOSITION
A DecompositionDecl record.
Definition: ASTBitCodes.h:1305
@ DECL_OMP_DECLARE_REDUCTION
An OMPDeclareReductionDecl record.
Definition: ASTBitCodes.h:1514
@ DECL_OMP_THREADPRIVATE
An OMPThreadPrivateDecl record.
Definition: ASTBitCodes.h:1481
@ DECL_OBJC_METHOD
A ObjCMethodDecl record.
Definition: ASTBitCodes.h:1251
@ DECL_CXX_DESTRUCTOR
A CXXDestructorDecl record.
Definition: ASTBitCodes.h:1404
@ DECL_OMP_CAPTUREDEXPR
An OMPCapturedExprDecl record.
Definition: ASTBitCodes.h:1502
@ DECL_CLASS_TEMPLATE
A ClassTemplateDecl record.
Definition: ASTBitCodes.h:1419
@ DECL_USING_SHADOW
A UsingShadowDecl record.
Definition: ASTBitCodes.h:1371
@ DECL_CONCEPT
A ConceptDecl record.
Definition: ASTBitCodes.h:1452
@ DECL_CXX_DEDUCTION_GUIDE
A CXXDeductionGuideDecl record.
Definition: ASTBitCodes.h:1395
@ DECL_OMP_REQUIRES
An OMPRequiresDecl record.
Definition: ASTBitCodes.h:1484
@ DECL_OBJC_IVAR
A ObjCIvarDecl record.
Definition: ASTBitCodes.h:1260
@ DECL_OBJC_PROPERTY
A ObjCPropertyDecl record.
Definition: ASTBitCodes.h:1278
@ DECL_TEMPLATE_PARAM_OBJECT
A TemplateParamObjectDecl record.
Definition: ASTBitCodes.h:1293
@ DECL_OBJC_INTERFACE
A ObjCInterfaceDecl record.
Definition: ASTBitCodes.h:1254
@ DECL_VAR_TEMPLATE
A VarTemplateDecl record.
Definition: ASTBitCodes.h:1428
@ DECL_LIFETIME_EXTENDED_TEMPORARY
An LifetimeExtendedTemporaryDecl record.
Definition: ASTBitCodes.h:1493
@ DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
A ClassTemplatePartialSpecializationDecl record.
Definition: ASTBitCodes.h:1425
@ DECL_IMPLICIT_CONCEPT_SPECIALIZATION
An ImplicitConceptSpecializationDecl record.
Definition: ASTBitCodes.h:1523
@ DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1342
@ DECL_OBJC_PROPERTY_IMPL
A ObjCPropertyImplDecl record.
Definition: ASTBitCodes.h:1281
@ EXPR_COMPOUND_ASSIGN_OPERATOR
A CompoundAssignOperator record.
Definition: ASTBitCodes.h:1670
@ EXPR_CXX_OPERATOR_CALL
A CXXOperatorCallExpr record.
Definition: ASTBitCodes.h:1828
@ EXPR_IMPLICIT_CAST
An ImplicitCastExpr record.
Definition: ASTBitCodes.h:1676
@ EXPR_CHARACTER_LITERAL
A CharacterLiteral record.
Definition: ASTBitCodes.h:1637
@ STMT_COMPOUND
A CompoundStmt record.
Definition: ASTBitCodes.h:1556
@ EXPR_CALL
A CallExpr record.
Definition: ASTBitCodes.h:1661
@ EXPR_BINARY_OPERATOR
A BinaryOperator record.
Definition: ASTBitCodes.h:1667
@ EXPR_DECL_REF
A DeclRefExpr record.
Definition: ASTBitCodes.h:1622
@ EXPR_INTEGER_LITERAL
An IntegerLiteral record.
Definition: ASTBitCodes.h:1625
@ EXPR_CXX_MEMBER_CALL
A CXXMemberCallExpr record.
Definition: ASTBitCodes.h:1831
bool isRedeclarableDeclKind(unsigned Kind)
Determine whether the given declaration kind is redeclarable.
Definition: ASTCommon.cpp:369
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:474
bool isPartOfPerModuleInitializer(const Decl *D)
Determine whether the given declaration will be included in the per-module initializer if it needs to...
Definition: ASTCommon.h:92
@ UPD_CXX_ADDED_ANONYMOUS_NAMESPACE
Definition: ASTCommon.h:27
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition: Address.h:328
@ 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...
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:331
bool CanElideDeclDef(const Decl *D)
If we can elide the definition of.
const FunctionProtoType * T
@ 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
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:194
@ AS_none
Definition: Specifiers.h:127
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>".
Definition: TemplateBase.h:676
Copy initialization expr of a __block variable and a boolean flag that indicates whether the expressi...
Definition: Expr.h:6460
Data that is common to all of the declarations of a given function template.
Definition: DeclTemplate.h:964
Parts of a decomposed MSGuidDecl.
Definition: DeclCXX.h:4287
uint16_t Part2
...-89ab-...
Definition: DeclCXX.h:4291
uint32_t Part1
{01234567-...
Definition: DeclCXX.h:4289
uint16_t Part3
...-cdef-...
Definition: DeclCXX.h:4293
uint8_t Part4And5[8]
...-0123-456789abcdef}
Definition: DeclCXX.h:4295
static DeclType * getDecl(EntryType *D)
Definition: DeclTemplate.h:741