From: Aaron Ballman Date: Wed, 4 Dec 2013 23:07:58 +0000 (+0000) Subject: Common functionality is already checked within SemaDeclAttr.cpp and so it does not... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f43ed02c1215b8dd359ef2bbc64d91b4b1ac3d02;p=clang Common functionality is already checked within SemaDeclAttr.cpp and so it does not need to be re-checked for each target. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196428 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/TargetAttributesSema.cpp b/lib/Sema/TargetAttributesSema.cpp index 034e460eeb..80168480ac 100644 --- a/lib/Sema/TargetAttributesSema.cpp +++ b/lib/Sema/TargetAttributesSema.cpp @@ -72,13 +72,6 @@ namespace { static void HandleMSP430InterruptAttr(Decl *d, const AttributeList &Attr, Sema &S) { - // Check the attribute arguments. - if (Attr.getNumArgs() != 1) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 1; - return; - } - // FIXME: Check for decl - it should be void ()(void). Expr *NumParamsExpr = static_cast(Attr.getArgAsExpr(0)); @@ -122,13 +115,6 @@ namespace { static void HandleX86ForceAlignArgPointerAttr(Decl *D, const AttributeList& Attr, Sema &S) { - // Check the attribute arguments. - if (Attr.getNumArgs() != 0) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 0; - return; - } - // If we try to apply it to a function pointer, don't warn, but don't // do anything, either. It doesn't matter anyway, because there's nothing // special about calling a force_align_arg_pointer function. @@ -175,13 +161,6 @@ DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D, SourceRange Range, } static void HandleDLLImportAttr(Decl *D, const AttributeList &Attr, Sema &S) { - // check the attribute arguments. - if (Attr.getNumArgs() != 0) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 0; - return; - } - // Attribute can be applied only to functions or variables. FunctionDecl *FD = dyn_cast(D); if (!FD && !isa(D)) { @@ -222,13 +201,6 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range, } static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) { - // check the attribute arguments. - if (Attr.getNumArgs() != 0) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 0; - return; - } - // Attribute can be applied only to functions or variables. FunctionDecl *FD = dyn_cast(D); if (!FD && !isa(D)) { @@ -278,41 +250,6 @@ namespace { }; } -static void HandleMips16Attr(Decl *D, const AttributeList &Attr, Sema &S) { - // check the attribute arguments. - if (Attr.getNumArgs()) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 0; - return; - } - // Attribute can only be applied to function types. - if (!isa(D)) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type) - << Attr.getName() << /* function */0; - return; - } - D->addAttr(::new (S.Context) Mips16Attr(Attr.getRange(), S.Context, - Attr.getAttributeSpellingListIndex())); -} - -static void HandleNoMips16Attr(Decl *D, const AttributeList &Attr, Sema &S) { - // check the attribute arguments. - if (Attr.getNumArgs()) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 0; - return; - } - // Attribute can only be applied to function types. - if (!isa(D)) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type) - << Attr.getName() << /* function */0; - return; - } - D->addAttr(::new (S.Context) - NoMips16Attr(Attr.getRange(), S.Context, - Attr.getAttributeSpellingListIndex())); -} - namespace { class MipsAttributesSema : public TargetAttributesSema { public: @@ -320,10 +257,12 @@ namespace { bool ProcessDeclAttribute(Scope *scope, Decl *D, const AttributeList &Attr, Sema &S) const { if (Attr.getKind() == AttributeList::AT_Mips16) { - HandleMips16Attr(D, Attr, S); + D->addAttr(::new (S.Context) Mips16Attr(Attr.getRange(), S.Context, + Attr.getAttributeSpellingListIndex())); return true; } else if (Attr.getKind() == AttributeList::AT_NoMips16) { - HandleNoMips16Attr(D, Attr, S); + D->addAttr(::new (S.Context) NoMips16Attr(Attr.getRange(), S.Context, + Attr.getAttributeSpellingListIndex())); return true; } return false;