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

Chris Lattner sabre at nondot.org
Tue Apr 14 09:30:50 PDT 2009


Author: lattner
Date: Tue Apr 14 11:30:50 2009
New Revision: 69044

URL: http://llvm.org/viewvc/llvm-project?rev=69044&view=rev
Log:
recognize the gnuc_inline attribute.

Modified:
    cfe/trunk/include/clang/AST/Attr.h
    cfe/trunk/include/clang/Parse/AttributeList.h
    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=69044&r1=69043&r2=69044&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Tue Apr 14 11:30:50 2009
@@ -42,6 +42,7 @@
     Destructor,
     FastCall,    
     Format,
+    GNUCInline,
     IBOutletKind, // Clang-specific.  Use "Kind" suffix to not conflict with
     NoReturn,
     NoThrow,
@@ -220,6 +221,16 @@
   static bool classof(const DestructorAttr *A) { return true; }
 };  
     
+  
+class GNUCInlineAttr : public Attr {
+public:
+  GNUCInlineAttr() : Attr(GNUCInline) {}
+  
+  // Implement isa/cast/dyncast/etc.
+  static bool classof(const Attr *A) { return A->getKind() == GNUCInline; }
+  static bool classof(const GNUCInlineAttr *A) { return true; }
+};
+
 class IBOutletAttr : public Attr {
 public:
   IBOutletAttr() : Attr(IBOutletKind) {}

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

==============================================================================
--- cfe/trunk/include/clang/Parse/AttributeList.h (original)
+++ cfe/trunk/include/clang/Parse/AttributeList.h Tue Apr 14 11:30:50 2009
@@ -66,6 +66,7 @@
     AT_ext_vector_type,
     AT_fastcall,
     AT_format,
+    AT_gnuc_inline,
     AT_mode,
     AT_nodebug,
     AT_noinline,

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

==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Tue Apr 14 11:30:50 2009
@@ -111,6 +111,7 @@
     if (!memcmp(Str, "vector_size", 11)) return AT_vector_size;
     if (!memcmp(Str, "constructor", 11)) return AT_constructor;
     if (!memcmp(Str, "unavailable", 11)) return AT_unavailable;
+    if (!memcmp(Str, "gnuc_inline", 11)) return AT_gnuc_inline;
     break;
   case 12:
     if (!memcmp(Str, "overloadable", 12)) return AT_overloadable;

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Apr 14 11:30:50 2009
@@ -1456,6 +1456,22 @@
   d->addAttr(::new (S.Context) NoinlineAttr());
 }
 
+static void HandleGNUCInlineAttr(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) << 0;
+    return;
+  }
+  
+  if (!isFunctionOrMethod(d)) {
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << "gnuc_inline" << 0 /*function*/;
+    return;
+  }
+  
+  d->addAttr(::new (S.Context) GNUCInlineAttr());
+}
+
 static void HandleRegparmAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   // check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
@@ -1523,6 +1539,7 @@
     break;
   case AttributeList::AT_fastcall:    HandleFastCallAttr  (D, Attr, S); break;
   case AttributeList::AT_format:      HandleFormatAttr    (D, Attr, S); break;
+  case AttributeList::AT_gnuc_inline: HandleGNUCInlineAttr(D, Attr, S); break;
   case AttributeList::AT_mode:        HandleModeAttr      (D, Attr, S); break;
   case AttributeList::AT_nonnull:     HandleNonNullAttr   (D, Attr, S); break;
   case AttributeList::AT_noreturn:    HandleNoReturnAttr  (D, Attr, S); break;





More information about the cfe-commits mailing list