danix800 created this revision. danix800 added reviewers: aaron.ballman, cor3ntin, ychen, balazske. danix800 added a project: clang. Herald added a reviewer: shafik. Herald added a project: All. danix800 requested review of this revision. Herald added a subscriber: cfe-commits.
`FunctionDeclBitfields.NumFunctionDeclBits` is not updated when `DeductionCandidateKind` is incremented. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D158145 Files: clang/include/clang/AST/DeclBase.h clang/lib/Serialization/ASTWriterDecl.cpp clang/unittests/AST/ASTImporterTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp =================================================================== --- clang/unittests/AST/ASTImporterTest.cpp +++ clang/unittests/AST/ASTImporterTest.cpp @@ -7832,6 +7832,47 @@ CheckAST(ToTU, ToC); } +TEST_P(ASTImporterOptionSpecificTestBase, + ImportFunctionDeclBitShouldNotStampingOnCtorDeclBits) { + Decl *From, *To; + std::tie(From, To) = getImportedDecl( + R"s( + struct A { + A() : m() {} + int m; + }; + + A foo() { A a; return a; } + A bar() { return {}; } + )s", + Lang_CXX17, + R"s( + struct A { + A() : m() {} + int m; + }; + A baz() { return {}; } + )s", + Lang_CXX17, "A"); + + auto HasCtorInit = + hasAnyConstructorInitializer(cxxCtorInitializer(isMemberInitializer())); + auto ImpMoveCtor = + cxxConstructorDecl(isMoveConstructor(), isImplicit(), HasCtorInit); + + auto *FromImpMoveCtor = FirstDeclMatcher<CXXConstructorDecl>().match( + From, ImpMoveCtor); + auto *ToImpMoveCtor = FirstDeclMatcher<CXXConstructorDecl>().match( + To, ImpMoveCtor); + + EXPECT_TRUE(FromImpMoveCtor->getNumCtorInitializers() == 1); + EXPECT_FALSE(FromImpMoveCtor->FriendConstraintRefersToEnclosingTemplate()); + + EXPECT_TRUE(ToImpMoveCtor->getNumCtorInitializers() == 1); + EXPECT_FALSE(ToImpMoveCtor->FriendConstraintRefersToEnclosingTemplate()); + EXPECT_TRUE(*ToImpMoveCtor->init_begin()); +} + AST_MATCHER_P(UsingShadowDecl, hasIntroducerDecl, internal::Matcher<NamedDecl>, InnerMatcher) { return InnerMatcher.matches(*Node.getIntroducer(), Finder, Builder); Index: clang/lib/Serialization/ASTWriterDecl.cpp =================================================================== --- clang/lib/Serialization/ASTWriterDecl.cpp +++ clang/lib/Serialization/ASTWriterDecl.cpp @@ -580,7 +580,7 @@ } void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { - static_assert(DeclContext::NumFunctionDeclBits == 30, + static_assert(DeclContext::NumFunctionDeclBits == 31, "You need to update the serializer after you change the " "FunctionDeclBits"); @@ -1495,7 +1495,7 @@ } void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) { - static_assert(DeclContext::NumCXXConstructorDeclBits == 21, + static_assert(DeclContext::NumCXXConstructorDeclBits == 20, "You need to update the serializer after you change the " "CXXConstructorDeclBits"); Index: clang/include/clang/AST/DeclBase.h =================================================================== --- clang/include/clang/AST/DeclBase.h +++ clang/include/clang/AST/DeclBase.h @@ -1702,7 +1702,7 @@ }; /// Number of non-inherited bits in FunctionDeclBitfields. - enum { NumFunctionDeclBits = 30 }; + enum { NumFunctionDeclBits = 31 }; /// Stores the bits used by CXXConstructorDecl. If modified /// NumCXXConstructorDeclBits and the accessor @@ -1714,12 +1714,12 @@ /// For the bits in FunctionDeclBitfields. uint64_t : NumFunctionDeclBits; - /// 21 bits to fit in the remaining available space. + /// 20 bits to fit in the remaining available space. /// Note that this makes CXXConstructorDeclBitfields take /// exactly 64 bits and thus the width of NumCtorInitializers /// will need to be shrunk if some bit is added to NumDeclContextBitfields, /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields. - uint64_t NumCtorInitializers : 18; + uint64_t NumCtorInitializers : 17; uint64_t IsInheritingConstructor : 1; /// Whether this constructor has a trail-allocated explicit specifier.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits