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