From 33bddbd64ba4cd6970c6287419d902c2bad0aa21 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 4 Jan 2018 23:42:29 +0000 Subject: Make attribute instantiation instantiate all attributes, not just the first of each kind. Attribute instantiation would previously default to instantiating each kind of attribute only once. This was overridden by a flag whose intended purpose was to permit attributes from a prior declaration to be inherited onto a new declaration even if that new declaration had its own copy of the attribute. This is the wrong behavior: when instantiating attributes from a template, we should always instantiate all the attributes that were written on that template. This patch renames the flag in the Attr class (and TableGen sources) to more clearly identify what it's actually for, and removes the usage of the flag from template instantiation. I also removed the flag from AlignedAttr, which was only added to work around the incorrect suppression of duplicate attribute instantiation. llvm-svn: 321834 --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp') diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index ab68e7e671d..0d45835742f 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -343,14 +343,6 @@ static void instantiateOMPDeclareSimdDeclAttr( Attr.getRange()); } -static bool DeclContainsAttr(const Decl *D, const Attr *NewAttr) { - if (!D->hasAttrs() || NewAttr->duplicatesAllowed()) - return false; - return llvm::find_if(D->getAttrs(), [NewAttr](const Attr *Attr) { - return Attr->getKind() == NewAttr->getKind(); - }) != D->getAttrs().end(); -} - void Sema::InstantiateAttrsForDecl( const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Tmpl, Decl *New, LateInstantiatedAttrVec *LateAttrs, @@ -365,7 +357,7 @@ void Sema::InstantiateAttrsForDecl( Attr *NewAttr = sema::instantiateTemplateAttributeForDecl( TmplAttr, Context, *this, TemplateArgs); - if (NewAttr && !DeclContainsAttr(New, NewAttr)) + if (NewAttr) New->addAttr(NewAttr); } } @@ -470,8 +462,7 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, Attr *NewAttr = sema::instantiateTemplateAttribute(TmplAttr, Context, *this, TemplateArgs); - - if (NewAttr && !DeclContainsAttr(New, NewAttr)) + if (NewAttr) New->addAttr(NewAttr); } } -- cgit v1.2.3