r198765 - Treating the RegParmAttr as a TypeAttr because that is what it is.

Aaron Ballman aaron at aaronballman.com
Wed Jan 8 05:23:02 PST 2014


Author: aaronballman
Date: Wed Jan  8 07:23:01 2014
New Revision: 198765

URL: http://llvm.org/viewvc/llvm-project?rev=198765&view=rev
Log:
Treating the RegParmAttr as a TypeAttr because that is what it is.

Patch reviewed by Rafael Espindola.

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=198765&r1=198764&r2=198765&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Jan  8 07:23:01 2014
@@ -779,9 +779,10 @@ def Pure : InheritableAttr {
   let Spellings = [GNU<"pure">, CXX11<"gnu", "pure">];
 }
 
-def Regparm : InheritableAttr {
+def Regparm : TypeAttr {
   let Spellings = [GNU<"regparm">, CXX11<"gnu", "regparm">];
   let Args = [UnsignedArgument<"NumParams">];
+  let ASTNode = 0;
 }
 
 def ReqdWorkGroupSize : InheritableAttr {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=198765&r1=198764&r2=198765&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan  8 07:23:01 2014
@@ -3228,24 +3228,6 @@ bool Sema::CheckCallingConvAttr(const At
   return false;
 }
 
-static void handleRegparmAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (hasDeclarator(D)) return;
-
-  unsigned numParams;
-  if (S.CheckRegparmAttr(Attr, numParams))
-    return;
-
-  if (!isa<ObjCMethodDecl>(D)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedFunctionOrMethod;
-    return;
-  }
-
-  D->addAttr(::new (S.Context)
-             RegparmAttr(Attr.getRange(), S.Context, numParams,
-                         Attr.getAttributeSpellingListIndex()));
-}
-
 /// Checks a regparm attribute, returning true if it is ill-formed and
 /// otherwise setting numParams to the appropriate value.
 bool Sema::CheckRegparmAttr(const AttributeList &Attr, unsigned &numParams) {
@@ -3799,6 +3781,7 @@ static void ProcessDeclAttribute(Sema &S
   case AttributeList::AT_Ptr64:
   case AttributeList::AT_SPtr:
   case AttributeList::AT_UPtr:
+  case AttributeList::AT_Regparm:
     // Ignore these, these are type attributes, handled by
     // ProcessTypeAttributes.
     break;
@@ -3963,7 +3946,6 @@ static void ProcessDeclAttribute(Sema &S
   case AttributeList::AT_NoDebug:     handleNoDebugAttr     (S, D, Attr); break;
   case AttributeList::AT_NoInline:
     handleSimpleAttribute<NoInlineAttr>(S, D, Attr); break;
-  case AttributeList::AT_Regparm:     handleRegparmAttr     (S, D, Attr); break;
   case AttributeList::IgnoredAttribute:
     // Just ignore
     break;





More information about the cfe-commits mailing list