[cfe-commits] r58304 - 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 test/CodeGen/function-attributes.c
Daniel Dunbar
daniel at zuster.org
Mon Oct 27 17:17:57 PDT 2008
Author: ddunbar
Date: Mon Oct 27 19:17:57 2008
New Revision: 58304
URL: http://llvm.org/viewvc/llvm-project?rev=58304&view=rev
Log:
Add attribute always_inline support.
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
cfe/trunk/test/CodeGen/function-attributes.c
Modified: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=58304&r1=58303&r2=58304&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Mon Oct 27 19:17:57 2008
@@ -27,6 +27,7 @@
enum Kind {
Alias,
Aligned,
+ AlwaysInline,
Annotate,
AsmLabel, // Represent GCC asm label extension.
Constructor,
@@ -140,6 +141,16 @@
static bool classof(const AsmLabelAttr *A) { return true; }
};
+class AlwaysInlineAttr : public Attr {
+public:
+ AlwaysInlineAttr() : Attr(AlwaysInline) {}
+
+ // Implement isa/cast/dyncast/etc.
+
+ static bool classof(const Attr *A) { return A->getKind() == AlwaysInline; }
+ static bool classof(const AlwaysInlineAttr *A) { return true; }
+};
+
class AliasAttr : public Attr {
std::string Aliasee;
public:
Modified: cfe/trunk/include/clang/Parse/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/AttributeList.h?rev=58304&r1=58303&r2=58304&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/AttributeList.h (original)
+++ cfe/trunk/include/clang/Parse/AttributeList.h Mon Oct 27 19:17:57 2008
@@ -45,6 +45,7 @@
AT_address_space,
AT_alias,
AT_aligned,
+ AT_always_inline,
AT_annotate,
AT_constructor,
AT_deprecated,
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=58304&r1=58303&r2=58304&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Oct 27 19:17:57 2008
@@ -274,6 +274,9 @@
if (!Features.Exceptions)
F->addFnAttr(llvm::Attribute::NoUnwind);
+
+ if (D->getAttr<AlwaysInlineAttr>())
+ F->addFnAttr(llvm::Attribute::AlwaysInline);
}
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=58304&r1=58303&r2=58304&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Mon Oct 27 19:17:57 2008
@@ -97,6 +97,7 @@
break;
case 13:
if (!memcmp(Str, "address_space", 13)) return AT_address_space;
+ if (!memcmp(Str, "always_inline", 13)) return AT_always_inline;
break;
case 15:
if (!memcmp(Str, "ext_vector_type", 15)) return AT_ext_vector_type;
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=58304&r1=58303&r2=58304&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Oct 27 19:17:57 2008
@@ -396,6 +396,18 @@
d->addAttr(new AliasAttr(std::string(Alias, AliasLen)));
}
+static void HandleAlwaysInlineAttr(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,
+ std::string("0"));
+ return;
+ }
+
+ d->addAttr(new AlwaysInlineAttr());
+}
+
static void HandleNoReturnAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// check the attribute arguments.
if (Attr.getNumArgs() != 0) {
@@ -1121,6 +1133,8 @@
break;
case AttributeList::AT_alias: HandleAliasAttr (D, Attr, S); break;
case AttributeList::AT_aligned: HandleAlignedAttr (D, Attr, S); break;
+ case AttributeList::AT_always_inline:
+ HandleAlwaysInlineAttr (D, Attr, S); break;
case AttributeList::AT_annotate: HandleAnnotateAttr (D, Attr, S); break;
case AttributeList::AT_constructor: HandleConstructorAttr(D, Attr, S); break;
case AttributeList::AT_deprecated: HandleDeprecatedAttr(D, Attr, S); break;
Modified: cfe/trunk/test/CodeGen/function-attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-attributes.c?rev=58304&r1=58303&r2=58304&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/function-attributes.c (original)
+++ cfe/trunk/test/CodeGen/function-attributes.c Mon Oct 27 19:17:57 2008
@@ -6,7 +6,8 @@
// RUN: grep 'define signext i16 @f4(i32 %x) nounwind' %t &&
// RUN: grep 'define zeroext i16 @f5(i32 %x) nounwind' %t &&
// RUN: grep 'define void @f6(i16 signext %x) nounwind' %t &&
-// RUN: grep 'define void @f7(i16 zeroext %x) nounwind' %t
+// RUN: grep 'define void @f7(i16 zeroext %x) nounwind' %t &&
+// RUN: grep 'define void @f8() nounwind alwaysinline' %t
signed char f0(int x) { return x; }
@@ -24,3 +25,4 @@
void f7(unsigned short x) { }
+void __attribute__((always_inline)) f8(void) { }
More information about the cfe-commits
mailing list