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