Remove Inheritable/NonInheritable flags from ProcessDeclAttributes. They don't

do anything useful.

llvm-svn: 189548
This commit is contained in:
Richard Smith 2013-08-29 00:47:48 +00:00
parent 673bcfea83
commit f8a75c3793
5 changed files with 25 additions and 63 deletions

View File

@ -2521,12 +2521,8 @@ public:
void ProcessPragmaWeak(Scope *S, Decl *D); void ProcessPragmaWeak(Scope *S, Decl *D);
// Decl attributes - this routine is the top level dispatcher. // Decl attributes - this routine is the top level dispatcher.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD, void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
bool NonInheritable = true,
bool Inheritable = true);
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
bool NonInheritable = true,
bool Inheritable = true,
bool IncludeCXX11Attributes = true); bool IncludeCXX11Attributes = true);
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl,
const AttributeList *AttrList); const AttributeList *AttrList);

View File

@ -55,8 +55,7 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS,
TemplateParams, 0, TemplateParams, 0,
VS, ICIS_NoInit); VS, ICIS_NoInit);
if (FnD) { if (FnD) {
Actions.ProcessDeclAttributeList(getCurScope(), FnD, AccessAttrs, false, Actions.ProcessDeclAttributeList(getCurScope(), FnD, AccessAttrs);
true);
bool TypeSpecContainsAuto = D.getDeclSpec().containsPlaceholderType(); bool TypeSpecContainsAuto = D.getDeclSpec().containsPlaceholderType();
if (Init.isUsable()) if (Init.isUsable())
Actions.AddInitializerToDecl(FnD, Init.get(), false, Actions.AddInitializerToDecl(FnD, Init.get(), false,

View File

@ -2278,8 +2278,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ThisDecl = VT->getTemplatedDecl(); ThisDecl = VT->getTemplatedDecl();
if (ThisDecl && AccessAttrs) if (ThisDecl && AccessAttrs)
Actions.ProcessDeclAttributeList(getCurScope(), ThisDecl, AccessAttrs, Actions.ProcessDeclAttributeList(getCurScope(), ThisDecl, AccessAttrs);
false, true);
} }
// Handle the initializer. // Handle the initializer.

View File

@ -6851,10 +6851,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
::new(Context) C11NoReturnAttr(D.getDeclSpec().getNoreturnSpecLoc(), ::new(Context) C11NoReturnAttr(D.getDeclSpec().getNoreturnSpecLoc(),
Context)); Context));
// Process the non-inheritable attributes on this declaration.
ProcessDeclAttributes(S, NewFD, D,
/*NonInheritable=*/true, /*Inheritable=*/false);
// Functions returning a variably modified type violate C99 6.7.5.2p2 // Functions returning a variably modified type violate C99 6.7.5.2p2
// because all functions have linkage. // because all functions have linkage.
if (!NewFD->isInvalidDecl() && if (!NewFD->isInvalidDecl() &&
@ -6864,8 +6860,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
} }
// Handle attributes. // Handle attributes.
ProcessDeclAttributes(S, NewFD, D, ProcessDeclAttributes(S, NewFD, D);
/*NonInheritable=*/false, /*Inheritable=*/true);
QualType RetType = NewFD->getResultType(); QualType RetType = NewFD->getResultType();
const CXXRecordDecl *Ret = RetType->isRecordType() ? const CXXRecordDecl *Ret = RetType->isRecordType() ?

View File

@ -4675,18 +4675,20 @@ static void handleSelectAnyAttr(Sema &S, Decl *D, const AttributeList &Attr) {
// Top Level Sema Entry Points // Top Level Sema Entry Points
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static void ProcessNonInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, /// ProcessDeclAttribute - Apply the specific attribute to the specified decl if
const AttributeList &Attr) { /// the attribute applies to decls. If the attribute is a type attribute, just
switch (Attr.getKind()) { /// silently ignore it if a GNU attribute.
case AttributeList::AT_Overloadable:handleOverloadableAttr(S, D, Attr); break; static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case AttributeList::AT_Mode: handleModeAttr (S, D, Attr); break; const AttributeList &Attr,
default: bool IncludeCXX11Attributes) {
break; if (Attr.isInvalid())
} return;
}
// Ignore C++11 attributes on declarator chunks: they appertain to the type
// instead.
if (Attr.isCXX11Attribute() && !IncludeCXX11Attributes)
return;
static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
const AttributeList &Attr) {
switch (Attr.getKind()) { switch (Attr.getKind()) {
case AttributeList::AT_IBAction: handleIBAction(S, D, Attr); break; case AttributeList::AT_IBAction: handleIBAction(S, D, Attr); break;
case AttributeList::AT_IBOutlet: handleIBOutlet(S, D, Attr); break; case AttributeList::AT_IBOutlet: handleIBOutlet(S, D, Attr); break;
@ -4704,11 +4706,6 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
// Ignore these, these are type attributes, handled by // Ignore these, these are type attributes, handled by
// ProcessTypeAttributes. // ProcessTypeAttributes.
break; break;
case AttributeList::AT_Mode:
case AttributeList::AT_Overloadable:
// Ignore, this is a non-inheritable attribute, handled
// by ProcessNonInheritableDeclAttr.
break;
case AttributeList::AT_Alias: handleAliasAttr (S, D, Attr); break; case AttributeList::AT_Alias: handleAliasAttr (S, D, Attr); break;
case AttributeList::AT_Aligned: handleAlignedAttr (S, D, Attr); break; case AttributeList::AT_Aligned: handleAlignedAttr (S, D, Attr); break;
case AttributeList::AT_AllocSize: handleAllocSizeAttr (S, D, Attr); break; case AttributeList::AT_AllocSize: handleAllocSizeAttr (S, D, Attr); break;
@ -4749,8 +4746,10 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
break; break;
case AttributeList::AT_Malloc: handleMallocAttr (S, D, Attr); break; case AttributeList::AT_Malloc: handleMallocAttr (S, D, Attr); break;
case AttributeList::AT_MayAlias: handleMayAliasAttr (S, D, Attr); break; case AttributeList::AT_MayAlias: handleMayAliasAttr (S, D, Attr); break;
case AttributeList::AT_Mode: handleModeAttr (S, D, Attr); break;
case AttributeList::AT_NoCommon: handleNoCommonAttr (S, D, Attr); break; case AttributeList::AT_NoCommon: handleNoCommonAttr (S, D, Attr); break;
case AttributeList::AT_NonNull: handleNonNullAttr (S, D, Attr); break; case AttributeList::AT_NonNull: handleNonNullAttr (S, D, Attr); break;
case AttributeList::AT_Overloadable:handleOverloadableAttr(S, D, Attr); break;
case AttributeList::AT_ownership_returns: case AttributeList::AT_ownership_returns:
case AttributeList::AT_ownership_takes: case AttributeList::AT_ownership_takes:
case AttributeList::AT_ownership_holds: case AttributeList::AT_ownership_holds:
@ -5008,42 +5007,18 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
} }
} }
/// ProcessDeclAttribute - Apply the specific attribute to the specified decl if
/// the attribute applies to decls. If the attribute is a type attribute, just
/// silently ignore it if a GNU attribute.
static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
const AttributeList &Attr,
bool NonInheritable, bool Inheritable,
bool IncludeCXX11Attributes) {
if (Attr.isInvalid())
return;
// Ignore C++11 attributes on declarator chunks: they appertain to the type
// instead.
if (Attr.isCXX11Attribute() && !IncludeCXX11Attributes)
return;
if (NonInheritable)
ProcessNonInheritableDeclAttr(S, scope, D, Attr);
if (Inheritable)
ProcessInheritableDeclAttr(S, scope, D, Attr);
}
/// ProcessDeclAttributeList - Apply all the decl attributes in the specified /// ProcessDeclAttributeList - Apply all the decl attributes in the specified
/// attribute list to the specified decl, ignoring any type attributes. /// attribute list to the specified decl, ignoring any type attributes.
void Sema::ProcessDeclAttributeList(Scope *S, Decl *D, void Sema::ProcessDeclAttributeList(Scope *S, Decl *D,
const AttributeList *AttrList, const AttributeList *AttrList,
bool NonInheritable, bool Inheritable,
bool IncludeCXX11Attributes) { bool IncludeCXX11Attributes) {
for (const AttributeList* l = AttrList; l; l = l->getNext()) for (const AttributeList* l = AttrList; l; l = l->getNext())
ProcessDeclAttribute(*this, S, D, *l, NonInheritable, Inheritable, ProcessDeclAttribute(*this, S, D, *l, IncludeCXX11Attributes);
IncludeCXX11Attributes);
// GCC accepts // GCC accepts
// static int a9 __attribute__((weakref)); // static int a9 __attribute__((weakref));
// but that looks really pointless. We reject it. // but that looks really pointless. We reject it.
if (Inheritable && D->hasAttr<WeakRefAttr>() && !D->hasAttr<AliasAttr>()) { if (D->hasAttr<WeakRefAttr>() && !D->hasAttr<AliasAttr>()) {
Diag(AttrList->getLoc(), diag::err_attribute_weakref_without_alias) << Diag(AttrList->getLoc(), diag::err_attribute_weakref_without_alias) <<
cast<NamedDecl>(D)->getNameAsString(); cast<NamedDecl>(D)->getNameAsString();
D->dropAttr<WeakRefAttr>(); D->dropAttr<WeakRefAttr>();
@ -5196,11 +5171,10 @@ void Sema::ProcessPragmaWeak(Scope *S, Decl *D) {
/// ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in /// ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in
/// it, apply them to D. This is a bit tricky because PD can have attributes /// it, apply them to D. This is a bit tricky because PD can have attributes
/// specified in many different places, and we need to find and apply them all. /// specified in many different places, and we need to find and apply them all.
void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD, void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD) {
bool NonInheritable, bool Inheritable) {
// Apply decl attributes from the DeclSpec if present. // Apply decl attributes from the DeclSpec if present.
if (const AttributeList *Attrs = PD.getDeclSpec().getAttributes().getList()) if (const AttributeList *Attrs = PD.getDeclSpec().getAttributes().getList())
ProcessDeclAttributeList(S, D, Attrs, NonInheritable, Inheritable); ProcessDeclAttributeList(S, D, Attrs);
// Walk the declarator structure, applying decl attributes that were in a type // Walk the declarator structure, applying decl attributes that were in a type
// position to the decl itself. This handles cases like: // position to the decl itself. This handles cases like:
@ -5208,12 +5182,11 @@ void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD,
// when X is a decl attribute. // when X is a decl attribute.
for (unsigned i = 0, e = PD.getNumTypeObjects(); i != e; ++i) for (unsigned i = 0, e = PD.getNumTypeObjects(); i != e; ++i)
if (const AttributeList *Attrs = PD.getTypeObject(i).getAttrs()) if (const AttributeList *Attrs = PD.getTypeObject(i).getAttrs())
ProcessDeclAttributeList(S, D, Attrs, NonInheritable, Inheritable, ProcessDeclAttributeList(S, D, Attrs, /*IncludeCXX11Attributes=*/false);
/*IncludeCXX11Attributes=*/false);
// Finally, apply any attributes on the decl itself. // Finally, apply any attributes on the decl itself.
if (const AttributeList *Attrs = PD.getAttributes()) if (const AttributeList *Attrs = PD.getAttributes())
ProcessDeclAttributeList(S, D, Attrs, NonInheritable, Inheritable); ProcessDeclAttributeList(S, D, Attrs);
} }
/// Is the given declaration allowed to use a forbidden type? /// Is the given declaration allowed to use a forbidden type?