Index: clang/include/clang/AST/DeclBase.h =================================================================== --- clang/include/clang/AST/DeclBase.h +++ clang/include/clang/AST/DeclBase.h @@ -1389,6 +1389,8 @@ class DeclContext { /// For makeDeclVisibleInContextImpl friend class ASTDeclReader; + /// For checking the new bits in the Serialization part. + friend class ASTDeclWriter; /// For reconcileExternalVisibleStorage, CreateStoredDeclsMap, /// hasNeedToReconcileExternalVisibleStorage friend class ExternalASTSource; Index: clang/lib/Serialization/ASTWriterDecl.cpp =================================================================== --- clang/lib/Serialization/ASTWriterDecl.cpp +++ clang/lib/Serialization/ASTWriterDecl.cpp @@ -411,6 +411,10 @@ } void ASTDeclWriter::VisitTagDecl(TagDecl *D) { + static_assert(DeclContext::NumTagDeclBits == 10, + "You need to update the serializer after you change the " + "TagDeclBits"); + VisitRedeclarable(D); VisitTypeDecl(D); Record.push_back(D->getIdentifierNamespace()); @@ -435,6 +439,10 @@ } void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) { + static_assert(DeclContext::NumEnumDeclBits == 20, + "You need to update the serializer after you change the " + "EnumDeclBits"); + VisitTagDecl(D); Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo()); if (!D->getIntegerTypeSourceInfo()) @@ -478,6 +486,10 @@ } void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) { + static_assert(DeclContext::NumRecordDeclBits == 41, + "You need to update the serializer after you change the " + "RecordDeclBits"); + VisitTagDecl(D); Record.push_back(D->hasFlexibleArrayMember()); Record.push_back(D->isAnonymousStructOrUnion()); @@ -546,6 +558,10 @@ } void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { + static_assert(DeclContext::NumFunctionDeclBits == 29, + "You need to update the serializer after you change the " + "FunctionDeclBits"); + VisitRedeclarable(D); Record.push_back(D->getTemplatedKind()); @@ -697,6 +713,10 @@ } void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { + static_assert(DeclContext::NumObjCMethodDeclBits == 24, + "You need to update the serializer after you change the " + "ObjCMethodDeclBits"); + VisitNamedDecl(D); // FIXME: convert to LazyStmtPtr? // Unlike C/C++, method bodies will never be in header files. @@ -755,6 +775,10 @@ } void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) { + static_assert(DeclContext::NumObjCContainerDeclBits == 51, + "You need to update the serializer after you change the " + "ObjCContainerDeclBits"); + VisitNamedDecl(D); Record.AddSourceLocation(D->getAtStartLoc()); Record.AddSourceRange(D->getAtEndRange()); @@ -1241,6 +1265,10 @@ } void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { + static_assert(DeclContext::NumLinkageSpecDeclBits == 4, + "You need to update the serializer after you change the" + "LinkageSpecDeclBits"); + VisitDecl(D); Record.push_back(D->getLanguage()); Record.AddSourceLocation(D->getExternLoc()); @@ -1436,6 +1464,10 @@ } void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) { + static_assert(DeclContext::NumCXXConstructorDeclBits == 22, + "You need to update the serializer after you change the " + "CXXConstructorDeclBits"); + Record.push_back(D->getTrailingAllocKind()); addExplicitSpecifier(D->getExplicitSpecifier(), Record); if (auto Inherited = D->getInheritedConstructor()) { @@ -1812,6 +1844,10 @@ /// Emit the DeclContext part of a declaration context decl. void ASTDeclWriter::VisitDeclContext(DeclContext *DC) { + static_assert(DeclContext::NumDeclContextBits == 13, + "You need to update the serializer after you change the " + "DeclContextBits"); + Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC)); Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC)); } @@ -1922,6 +1958,10 @@ } void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { + static_assert(DeclContext::NumOMPDeclareReductionDeclBits == 2, + "You need to update the serializer after you change the " + "NumOMPDeclareReductionDeclBits"); + VisitValueDecl(D); Record.AddSourceLocation(D->getBeginLoc()); Record.AddStmt(D->getCombinerIn());