enum Kind {
Alias,
Aligned,
+ AlwaysInline,
Annotate,
AsmLabel, // Represent GCC asm label extension.
Constructor,
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:
AT_address_space,
AT_alias,
AT_aligned,
+ AT_always_inline,
AT_annotate,
AT_constructor,
AT_deprecated,
if (!Features.Exceptions)
F->addFnAttr(llvm::Attribute::NoUnwind);
+
+ if (D->getAttr<AlwaysInlineAttr>())
+ F->addFnAttr(llvm::Attribute::AlwaysInline);
}
void CodeGenModule::SetMethodAttributes(const ObjCMethodDecl *MD,
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;
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) {
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;
// 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; }
void f7(unsigned short x) { }
+void __attribute__((always_inline)) f8(void) { }