[cfe-commits] r67857 - in /cfe/trunk: include/clang/AST/Attr.h include/clang/Parse/AttributeList.h lib/CodeGen/CodeGenModule.cpp lib/Parse/AttributeList.cpp lib/Sema/SemaDeclAttr.cpp

Fariborz Jahanian fjahanian at apple.com
Fri Mar 27 11:38:55 PDT 2009


Author: fjahanian
Date: Fri Mar 27 13:38:55 2009
New Revision: 67857

URL: http://llvm.org/viewvc/llvm-project?rev=67857&view=rev
Log:
Besides the warning, issue unsupported diagnostics in 
ir gen. No intended change in functionality.

Modified:
    cfe/trunk/include/clang/AST/Attr.h
    cfe/trunk/include/clang/Parse/AttributeList.h
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/Parse/AttributeList.cpp
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=67857&r1=67856&r2=67857&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Fri Mar 27 13:38:55 2009
@@ -52,6 +52,7 @@
     Overloadable, // Clang-specific
     Packed,
     Pure,
+    Regparm,
     Section,
     StdCall,
     TransparentUnion,
@@ -545,6 +546,15 @@
   static bool classof(const NoinlineAttr *A) { return true; }
 };
 
+class RegparmAttr : public Attr {
+public:
+  RegparmAttr() : Attr(Regparm) {}
+    
+  // Implement isa/cast/dyncast/etc.
+    
+  static bool classof(const Attr *A) { return A->getKind() == Regparm; }
+  static bool classof(const RegparmAttr *A) { return true; }
+};
 }  // end namespace clang
 
 #endif

Modified: cfe/trunk/include/clang/Parse/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/AttributeList.h?rev=67857&r1=67856&r2=67857&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/AttributeList.h (original)
+++ cfe/trunk/include/clang/Parse/AttributeList.h Fri Mar 27 13:38:55 2009
@@ -73,6 +73,7 @@
     AT_overloadable,      // Clang-specific
     AT_packed,
     AT_pure,
+    AT_regparm,
     AT_section,
     AT_sentinel,
     AT_stdcall,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=67857&r1=67856&r2=67857&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Mar 27 13:38:55 2009
@@ -286,6 +286,9 @@
 
   if (D->getAttr<StdCallAttr>())
     F->setCallingConv(llvm::CallingConv::X86_StdCall);
+
+  if (D->getAttr<RegparmAttr>())
+    ErrorUnsupported(D, "regparm attribute");
 }
 
 /// SetFunctionAttributesForDefinition - Set function attributes
@@ -308,6 +311,9 @@
   
   if (D->getAttr<NoinlineAttr>())
     F->addFnAttr(llvm::Attribute::NoInline);
+  
+  if (D->getAttr<RegparmAttr>())
+    ErrorUnsupported(D, "regparm attribute");
 }
 
 void CodeGenModule::SetMethodAttributes(const ObjCMethodDecl *MD,

Modified: cfe/trunk/lib/Parse/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/AttributeList.cpp?rev=67857&r1=67856&r2=67857&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Fri Mar 27 13:38:55 2009
@@ -80,6 +80,7 @@
     if (!memcmp(Str, "nonnull", 7)) return AT_nonnull;
     if (!memcmp(Str, "nothrow", 7)) return AT_nothrow;
     if (!memcmp(Str, "objc_gc", 7)) return AT_objc_gc;
+    if (!memcmp(Str, "regparm", 7)) return AT_regparm;
     if (!memcmp(Str, "section", 7)) return AT_section;
     if (!memcmp(Str, "stdcall", 7)) return AT_stdcall;
     break;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=67857&r1=67856&r2=67857&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Mar 27 13:38:55 2009
@@ -1444,6 +1444,22 @@
   d->addAttr(::new (S.Context) NoinlineAttr());
 }
 
+static void HandleRegparmAttr(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) << 0;
+    return;
+  }
+  
+  if (!isFunctionOrMethod(d)) {
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+    << "regparm" << 0 /*function*/;
+    return;
+  }
+  
+  d->addAttr(::new (S.Context) RegparmAttr());
+}
+
 //===----------------------------------------------------------------------===//
 // Top Level Sema Entry Points
 //===----------------------------------------------------------------------===//
@@ -1504,6 +1520,10 @@
   case AttributeList::AT_cleanup:     HandleCleanupAttr   (D, Attr, S); break;
   case AttributeList::AT_nodebug:     HandleNodebugAttr   (D, Attr, S); break;
   case AttributeList::AT_noinline:    HandleNoinlineAttr  (D, Attr, S); break;
+  case AttributeList::AT_regparm:
+    HandleRegparmAttr  (D, Attr, S);
+    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+    break;
   case AttributeList::IgnoredAttribute: 
     // Just ignore
     break;





More information about the cfe-commits mailing list