From ee760330a415635369556796a97afcfd6207f4dc Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 27 Mar 2009 18:38:55 +0000 Subject: [PATCH] Besides the warning, issue unsupported diagnostics in ir gen. No intended change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67857 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Attr.h | 10 ++++++++++ include/clang/Parse/AttributeList.h | 1 + lib/CodeGen/CodeGenModule.cpp | 6 ++++++ lib/Parse/AttributeList.cpp | 1 + lib/Sema/SemaDeclAttr.cpp | 20 ++++++++++++++++++++ 5 files changed, 38 insertions(+) diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index cd98ef1a8b..f9081050c5 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -52,6 +52,7 @@ public: Overloadable, // Clang-specific Packed, Pure, + Regparm, Section, StdCall, TransparentUnion, @@ -545,6 +546,15 @@ public: 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 diff --git a/include/clang/Parse/AttributeList.h b/include/clang/Parse/AttributeList.h index 2f71e4d758..2113965bee 100644 --- a/include/clang/Parse/AttributeList.h +++ b/include/clang/Parse/AttributeList.h @@ -73,6 +73,7 @@ public: AT_overloadable, // Clang-specific AT_packed, AT_pure, + AT_regparm, AT_section, AT_sentinel, AT_stdcall, diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 8a880516f6..0759abdd33 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -286,6 +286,9 @@ void CodeGenModule::SetFunctionAttributes(const Decl *D, if (D->getAttr()) F->setCallingConv(llvm::CallingConv::X86_StdCall); + + if (D->getAttr()) + ErrorUnsupported(D, "regparm attribute"); } /// SetFunctionAttributesForDefinition - Set function attributes @@ -308,6 +311,9 @@ void CodeGenModule::SetFunctionAttributesForDefinition(const Decl *D, if (D->getAttr()) F->addFnAttr(llvm::Attribute::NoInline); + + if (D->getAttr()) + ErrorUnsupported(D, "regparm attribute"); } void CodeGenModule::SetMethodAttributes(const ObjCMethodDecl *MD, diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index 9cee6abebb..cd192c92ef 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -80,6 +80,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { 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; diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 53c86ebaae..c8d98cf0dc 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1444,6 +1444,22 @@ static void HandleNoinlineAttr(Decl *d, const AttributeList &Attr, Sema &S) { 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 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) { 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; -- 2.40.0