Author: rsmith Date: Tue Oct 25 21:31:56 2016 New Revision: 285160 URL: http://llvm.org/viewvc/llvm-project?rev=285160&view=rev Log: [modules] Fix assert if multiple update records provide a definition for a class template specialization and that specialization has attributes.
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/test/Modules/Inputs/templates-left.h cfe/trunk/test/Modules/Inputs/templates-right.h cfe/trunk/test/Modules/Inputs/templates-top.h cfe/trunk/test/Modules/templates.mm Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=285160&r1=285159&r2=285160&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Oct 25 21:31:56 2016 @@ -3930,7 +3930,10 @@ void ASTDeclReader::UpdateDecl(Decl *D, if (Record[Idx++]) { AttrVec Attrs; Reader.ReadAttributes(F, Attrs, Record, Idx); - D->setAttrsImpl(Attrs, Reader.getContext()); + // If the declaration already has attributes, we assume that some other + // AST file already loaded them. + if (!D->hasAttrs()) + D->setAttrsImpl(Attrs, Reader.getContext()); } break; } Modified: cfe/trunk/test/Modules/Inputs/templates-left.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-left.h?rev=285160&r1=285159&r2=285160&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/templates-left.h (original) +++ cfe/trunk/test/Modules/Inputs/templates-left.h Tue Oct 25 21:31:56 2016 @@ -70,3 +70,5 @@ namespace EmitDefaultedSpecialMembers { inline int *getStaticDataMemberLeft() { return WithUndefinedStaticDataMember<int[]>::undefined; } + +inline WithAttributes<int> make_with_attributes_left() { return WithAttributes<int>(); } Modified: cfe/trunk/test/Modules/Inputs/templates-right.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-right.h?rev=285160&r1=285159&r2=285160&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/templates-right.h (original) +++ cfe/trunk/test/Modules/Inputs/templates-right.h Tue Oct 25 21:31:56 2016 @@ -51,3 +51,5 @@ void outOfLineInlineUseRightH(void (OutO inline int *getStaticDataMemberRight() { return WithUndefinedStaticDataMember<int[]>::undefined; } + +inline WithAttributes<int> make_with_attributes_right() { return WithAttributes<int>(); } Modified: cfe/trunk/test/Modules/Inputs/templates-top.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-top.h?rev=285160&r1=285159&r2=285160&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/templates-top.h (original) +++ cfe/trunk/test/Modules/Inputs/templates-top.h Tue Oct 25 21:31:56 2016 @@ -58,3 +58,8 @@ namespace EmitDefaultedSpecialMembers { template<typename T> struct WithUndefinedStaticDataMember { static T undefined; }; + +template<typename T> struct __attribute__((packed, aligned(2))) WithAttributes { + T value; +}; +WithAttributes<int> *get_with_attributes(); Modified: cfe/trunk/test/Modules/templates.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/templates.mm?rev=285160&r1=285159&r2=285160&view=diff ============================================================================== --- cfe/trunk/test/Modules/templates.mm (original) +++ cfe/trunk/test/Modules/templates.mm Tue Oct 25 21:31:56 2016 @@ -116,4 +116,9 @@ void testStaticDataMember() { (void) getStaticDataMemberRight(); } - +void testWithAttributes() { + auto a = make_with_attributes_left(); + auto b = make_with_attributes_right(); + static_assert(alignof(decltype(a)) == 2, ""); + static_assert(alignof(decltype(b)) == 2, ""); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits