#include "ASTCommon.h"
#include "ASTReaderInternals.h"
#include "clang/AST/ASTConcept.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTStructuralEquivalence.h"
#include "clang/AST/Attr.h"
#include "clang/AST/AttrIterator.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclFriend.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/LambdaCapture.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/OpenMPClause.h"
#include "clang/AST/Redeclarable.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/TemplateBase.h"
#include "clang/AST/Type.h"
#include "clang/AST/UnresolvedSet.h"
#include "clang/Basic/AttrKinds.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/ExceptionSpecificationType.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Lambda.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Linkage.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/PragmaKinds.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
#include "clang/Basic/Stack.h"
#include "clang/Sema/IdentifierResolver.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Serialization/ASTRecordReader.h"
#include "clang/Serialization/ContinuousRangeMap.h"
#include "clang/Serialization/ModuleFile.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Bitstream/BitstreamReader.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/SaveAndRestore.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <string>
#include <utility>
usingnamespaceclang;
usingnamespaceserialization;
namespace {
class RedeclarableResult { … };
}
namespace clang {
class ASTDeclMerger { … };
}
namespace clang {
class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> { … };
}
namespace {
template <typename DeclT> class MergedRedeclIterator { … };
}
template <typename DeclT>
static llvm::iterator_range<MergedRedeclIterator<DeclT>>
merged_redecls(DeclT *D) { … }
uint64_t ASTDeclReader::GetCurrentCursorOffset() { … }
void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) { … }
void ASTDeclReader::Visit(Decl *D) { … }
void ASTDeclReader::VisitDecl(Decl *D) { … }
void ASTDeclReader::VisitPragmaCommentDecl(PragmaCommentDecl *D) { … }
void ASTDeclReader::VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D) { … }
void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { … }
void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) { … }
void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) { … }
RedeclarableResult ASTDeclReader::VisitTypedefNameDecl(TypedefNameDecl *TD) { … }
void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) { … }
void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) { … }
RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) { … }
void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { … }
RedeclarableResult ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) { … }
void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) { … }
void ASTDeclReader::VisitValueDecl(ValueDecl *VD) { … }
void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { … }
void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { … }
void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { … }
void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { … }
void ASTDeclReader::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) { … }
void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { … }
ObjCTypeParamList *ASTDeclReader::ReadObjCTypeParamList() { … }
void ASTDeclReader::ReadObjCDefinitionData(
struct ObjCInterfaceDecl::DefinitionData &Data) { … }
void ASTDeclMerger::MergeDefinitionData(
ObjCInterfaceDecl *D, struct ObjCInterfaceDecl::DefinitionData &&NewDD) { … }
void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { … }
void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) { … }
void ASTDeclReader::ReadObjCDefinitionData(
struct ObjCProtocolDecl::DefinitionData &Data) { … }
void ASTDeclMerger::MergeDefinitionData(
ObjCProtocolDecl *D, struct ObjCProtocolDecl::DefinitionData &&NewDD) { … }
void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { … }
void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { … }
void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { … }
void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { … }
void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { … }
void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { … }
void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { … }
void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { … }
void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { … }
void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { … }
void ASTDeclReader::VisitMSPropertyDecl(MSPropertyDecl *PD) { … }
void ASTDeclReader::VisitMSGuidDecl(MSGuidDecl *D) { … }
void ASTDeclReader::VisitUnnamedGlobalConstantDecl(
UnnamedGlobalConstantDecl *D) { … }
void ASTDeclReader::VisitTemplateParamObjectDecl(TemplateParamObjectDecl *D) { … }
void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) { … }
RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) { … }
void ASTDeclReader::ReadVarDeclInit(VarDecl *VD) { … }
void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) { … }
void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { … }
void ASTDeclReader::VisitDecompositionDecl(DecompositionDecl *DD) { … }
void ASTDeclReader::VisitBindingDecl(BindingDecl *BD) { … }
void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { … }
void ASTDeclReader::VisitTopLevelStmtDecl(TopLevelStmtDecl *D) { … }
void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { … }
void ASTDeclReader::VisitCapturedDecl(CapturedDecl *CD) { … }
void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { … }
void ASTDeclReader::VisitExportDecl(ExportDecl *D) { … }
void ASTDeclReader::VisitLabelDecl(LabelDecl *D) { … }
void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { … }
void ASTDeclReader::VisitHLSLBufferDecl(HLSLBufferDecl *D) { … }
void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { … }
void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { … }
void ASTDeclReader::VisitUsingEnumDecl(UsingEnumDecl *D) { … }
void ASTDeclReader::VisitUsingPackDecl(UsingPackDecl *D) { … }
void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { … }
void ASTDeclReader::VisitConstructorUsingShadowDecl(
ConstructorUsingShadowDecl *D) { … }
void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { … }
void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { … }
void ASTDeclReader::VisitUnresolvedUsingTypenameDecl(
UnresolvedUsingTypenameDecl *D) { … }
void ASTDeclReader::VisitUnresolvedUsingIfExistsDecl(
UnresolvedUsingIfExistsDecl *D) { … }
void ASTDeclReader::ReadCXXDefinitionData(
struct CXXRecordDecl::DefinitionData &Data, const CXXRecordDecl *D,
Decl *LambdaContext, unsigned IndexInLambdaContext) { … }
void ASTDeclMerger::MergeDefinitionData(
CXXRecordDecl *D, struct CXXRecordDecl::DefinitionData &&MergeDD) { … }
void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update,
Decl *LambdaContext,
unsigned IndexInLambdaContext) { … }
RedeclarableResult ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) { … }
void ASTDeclReader::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) { … }
void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { … }
void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { … }
void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { … }
void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) { … }
void ASTDeclReader::VisitImportDecl(ImportDecl *D) { … }
void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { … }
void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { … }
void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { … }
void ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { … }
void ASTDeclReader::VisitConceptDecl(ConceptDecl *D) { … }
void ASTDeclReader::VisitImplicitConceptSpecializationDecl(
ImplicitConceptSpecializationDecl *D) { … }
void ASTDeclReader::VisitRequiresExprBodyDecl(RequiresExprBodyDecl *D) { … }
RedeclarableResult
ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { … }
void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { … }
void ASTDeclReader::VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D) { … }
void ASTDeclReader::VisitVarTemplateDecl(VarTemplateDecl *D) { … }
RedeclarableResult ASTDeclReader::VisitClassTemplateSpecializationDeclImpl(
ClassTemplateSpecializationDecl *D) { … }
void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *D) { … }
void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { … }
RedeclarableResult ASTDeclReader::VisitVarTemplateSpecializationDeclImpl(
VarTemplateSpecializationDecl *D) { … }
void ASTDeclReader::VisitVarTemplatePartialSpecializationDecl(
VarTemplatePartialSpecializationDecl *D) { … }
void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { … }
void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { … }
void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { … }
void ASTDeclReader::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { … }
void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { … }
void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) { … }
void ASTDeclReader::VisitLifetimeExtendedTemporaryDecl(
LifetimeExtendedTemporaryDecl *D) { … }
std::pair<uint64_t, uint64_t>
ASTDeclReader::VisitDeclContext(DeclContext *DC) { … }
template <typename T>
RedeclarableResult ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { … }
template <typename T>
void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase,
RedeclarableResult &Redecl) { … }
void ASTDeclMerger::mergeLambda(CXXRecordDecl *D, RedeclarableResult &Redecl,
Decl &Context, unsigned IndexInContext) { … }
void ASTDeclReader::mergeRedeclarableTemplate(RedeclarableTemplateDecl *D,
RedeclarableResult &Redecl) { … }
template<typename T> static T assert_cast(T t) { … }
template<typename T> static T assert_cast(...) { … }
void ASTDeclMerger::mergeTemplatePattern(RedeclarableTemplateDecl *D,
RedeclarableTemplateDecl *Existing,
bool IsKeyDecl) { … }
template <typename T>
void ASTDeclMerger::mergeRedeclarableImpl(Redeclarable<T> *DBase, T *Existing,
GlobalDeclID KeyDeclID) { … }
static bool allowODRLikeMergeInC(NamedDecl *ND) { … }
void ASTDeclReader::mergeMergeable(LifetimeExtendedTemporaryDecl *D) { … }
template<typename T>
void ASTDeclReader::mergeMergeable(Mergeable<T> *D) { … }
void ASTDeclReader::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { … }
void ASTDeclReader::VisitOMPAllocateDecl(OMPAllocateDecl *D) { … }
void ASTDeclReader::VisitOMPRequiresDecl(OMPRequiresDecl * D) { … }
void ASTDeclReader::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { … }
void ASTDeclReader::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) { … }
void ASTDeclReader::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { … }
namespace {
class AttrReader { … };
}
Attr *ASTRecordReader::readAttr() { … }
void ASTRecordReader::readAttributes(AttrVec &Attrs) { … }
inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { … }
bool ASTReader::isConsumerInterestedIn(Decl *D) { … }
ASTReader::RecordLocation ASTReader::DeclCursorForID(GlobalDeclID ID,
SourceLocation &Loc) { … }
ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) { … }
uint64_t ASTReader::getGlobalBitOffset(ModuleFile &M, uint64_t LocalOffset) { … }
CXXRecordDecl *
ASTDeclReader::getOrFakePrimaryClassDefinition(ASTReader &Reader,
CXXRecordDecl *RD) { … }
DeclContext *ASTDeclReader::getPrimaryContextForMerging(ASTReader &Reader,
DeclContext *DC) { … }
ASTDeclReader::FindExistingResult::~FindExistingResult() { … }
static NamedDecl *getDeclForMerging(NamedDecl *Found,
bool IsTypedefNameForLinkage) { … }
DeclContext *
ASTDeclReader::getPrimaryDCForAnonymousDecl(DeclContext *LexicalDC) { … }
NamedDecl *ASTDeclReader::getAnonymousDeclForMerging(ASTReader &Reader,
DeclContext *DC,
unsigned Index) { … }
void ASTDeclReader::setAnonymousDeclForMerging(ASTReader &Reader,
DeclContext *DC, unsigned Index,
NamedDecl *D) { … }
ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) { … }
template<typename DeclT>
Decl *ASTDeclReader::getMostRecentDeclImpl(Redeclarable<DeclT> *D) { … }
Decl *ASTDeclReader::getMostRecentDeclImpl(...) { … }
Decl *ASTDeclReader::getMostRecentDecl(Decl *D) { … }
Decl *ASTReader::getMostRecentExistingDecl(Decl *D) { … }
namespace {
void mergeInheritableAttributes(ASTReader &Reader, Decl *D, Decl *Previous) { … }
}
template<typename DeclT>
void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
Redeclarable<DeclT> *D,
Decl *Previous, Decl *Canon) { … }
namespace clang {
template<>
void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
Redeclarable<VarDecl> *D,
Decl *Previous, Decl *Canon) { … }
static bool isUndeducedReturnType(QualType T) { … }
template<>
void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
Redeclarable<FunctionDecl> *D,
Decl *Previous, Decl *Canon) { … }
}
void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader, ...) { … }
template <typename ParmDecl>
static bool inheritDefaultTemplateArgument(ASTContext &Context, ParmDecl *From,
Decl *ToD) { … }
static void inheritDefaultTemplateArguments(ASTContext &Context,
TemplateDecl *From,
TemplateDecl *To) { … }
void ASTDeclReader::checkMultipleDefinitionInNamedModules(ASTReader &Reader,
Decl *D,
Decl *Previous) { … }
void ASTDeclReader::attachPreviousDecl(ASTReader &Reader, Decl *D,
Decl *Previous, Decl *Canon) { … }
template<typename DeclT>
void ASTDeclReader::attachLatestDeclImpl(Redeclarable<DeclT> *D, Decl *Latest) { … }
void ASTDeclReader::attachLatestDeclImpl(...) { … }
void ASTDeclReader::attachLatestDecl(Decl *D, Decl *Latest) { … }
template<typename DeclT>
void ASTDeclReader::markIncompleteDeclChainImpl(Redeclarable<DeclT> *D) { … }
void ASTDeclReader::markIncompleteDeclChainImpl(...) { … }
void ASTReader::markIncompleteDeclChain(Decl *D) { … }
Decl *ASTReader::ReadDeclRecord(GlobalDeclID ID) { … }
void ASTReader::PassInterestingDeclsToConsumer() { … }
void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) { … }
void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) { … }
namespace {
class ObjCCategoriesVisitor { … };
}
void ASTReader::loadObjCCategories(GlobalDeclID ID, ObjCInterfaceDecl *D,
unsigned PreviousGeneration) { … }
template<typename DeclT, typename Fn>
static void forAllLaterRedecls(DeclT *D, Fn F) { … }
void ASTDeclReader::UpdateDecl(
Decl *D,
llvm::SmallVectorImpl<GlobalDeclID> &PendingLazySpecializationIDs) { … }