diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-27 18:38:55 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-27 18:38:55 +0000 |
commit | a2d609e2f144e70892a04edceab28223d4bd838b (patch) | |
tree | 9a3a273264d668aeda14f910d6116a65984db2e1 | |
parent | 8680802b1f9022359c9d10ae57d1c2560536a113 (diff) | |
download | bcm5719-llvm-a2d609e2f144e70892a04edceab28223d4bd838b.tar.gz bcm5719-llvm-a2d609e2f144e70892a04edceab28223d4bd838b.zip |
Besides the warning, issue unsupported diagnostics in
ir gen. No intended change in functionality.
llvm-svn: 67857
-rw-r--r-- | clang/include/clang/AST/Attr.h | 10 | ||||
-rw-r--r-- | clang/include/clang/Parse/AttributeList.h | 1 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Parse/AttributeList.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 20 |
5 files changed, 38 insertions, 0 deletions
diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h index cd98ef1a8b0..f9081050c59 100644 --- a/clang/include/clang/AST/Attr.h +++ b/clang/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/clang/include/clang/Parse/AttributeList.h b/clang/include/clang/Parse/AttributeList.h index 2f71e4d758c..2113965bee9 100644 --- a/clang/include/clang/Parse/AttributeList.h +++ b/clang/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/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8a880516f66..0759abdd33f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -286,6 +286,9 @@ void CodeGenModule::SetFunctionAttributes(const Decl *D, 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 @@ void CodeGenModule::SetFunctionAttributesForDefinition(const Decl *D, if (D->getAttr<NoinlineAttr>()) F->addFnAttr(llvm::Attribute::NoInline); + + if (D->getAttr<RegparmAttr>()) + ErrorUnsupported(D, "regparm attribute"); } void CodeGenModule::SetMethodAttributes(const ObjCMethodDecl *MD, diff --git a/clang/lib/Parse/AttributeList.cpp b/clang/lib/Parse/AttributeList.cpp index 9cee6abebbd..cd192c92ef0 100644 --- a/clang/lib/Parse/AttributeList.cpp +++ b/clang/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/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 53c86ebaaec..c8d98cf0dcb 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/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; |