r196428 - Common functionality is already checked within SemaDeclAttr.cpp and so it does not need to be re-checked for each target.

Aaron Ballman aaron at aaronballman.com
Wed Dec 4 15:07:58 PST 2013


Author: aaronballman
Date: Wed Dec  4 17:07:58 2013
New Revision: 196428

URL: http://llvm.org/viewvc/llvm-project?rev=196428&view=rev
Log:
Common functionality is already checked within SemaDeclAttr.cpp and so it does not need to be re-checked for each target.

Modified:
    cfe/trunk/lib/Sema/TargetAttributesSema.cpp

Modified: cfe/trunk/lib/Sema/TargetAttributesSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TargetAttributesSema.cpp?rev=196428&r1=196427&r2=196428&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TargetAttributesSema.cpp (original)
+++ cfe/trunk/lib/Sema/TargetAttributesSema.cpp Wed Dec  4 17:07:58 2013
@@ -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<Expr *>(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(
 }
 
 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<FunctionDecl>(D);
   if (!FD && !isa<VarDecl>(D)) {
@@ -222,13 +201,6 @@ DLLExportAttr *Sema::mergeDLLExportAttr(
 }
 
 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<FunctionDecl>(D);
   if (!FD && !isa<VarDecl>(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<FunctionDecl>(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<FunctionDecl>(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;





More information about the cfe-commits mailing list