[cfe-commits] r67868 - in /cfe/trunk: include/clang/AST/Attr.h include/clang/Basic/DiagnosticSemaKinds.td lib/CodeGen/CodeGenModule.cpp lib/Sema/SemaDeclAttr.cpp test/Sema/attr-regparm.c

Fariborz Jahanian fjahanian at apple.com
Fri Mar 27 14:58:13 PDT 2009


On Mar 27, 2009, at 2:06 PM, Eli Friedman wrote:

> Author: efriedma
> Date: Fri Mar 27 16:06:47 2009
> New Revision: 67868
>
> URL: http://llvm.org/viewvc/llvm-project?rev=67868&view=rev
> Log:
> Finish off semantic analysis for regparm, and remove the warning.   
> Also
> remove a redundant error in CodeGen.
>
>
> Added:
>    cfe/trunk/test/Sema/attr-regparm.c
> Modified:
>    cfe/trunk/include/clang/AST/Attr.h
>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>    cfe/trunk/lib/CodeGen/CodeGenModule.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=67868&r1=67867&r2=67868&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/AST/Attr.h (original)
> +++ cfe/trunk/include/clang/AST/Attr.h Fri Mar 27 16:06:47 2009
> @@ -547,9 +547,13 @@
> };
>
> class RegparmAttr : public Attr {
> +  unsigned NumParams;
> +
> public:
> -  RegparmAttr() : Attr(Regparm) {}
> -
> +  RegparmAttr(unsigned np) : Attr(Regparm), NumParams(np) {}
> +
> +  unsigned getNumParams() { return NumParams; }
> +
>   // Implement isa/cast/dyncast/etc.
>
>   static bool classof(const Attr *A) { return A->getKind() ==  
> Regparm; }
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=67868&r1=67867&r2=67868&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Mar 27  
> 16:06:47 2009
> @@ -435,6 +435,10 @@
> def err_attribute_cleanup_func_arg_incompatible_type : Error<
>   "'cleanup' function %0 parameter has type %1 which is incompatible  
> with "
>   "type %2">;
> +def err_attribute_regparm_wrong_platform : Error<
> +  "'regparm' is not valid on platforms other than x86-32">;
> +def err_attribute_regparm_invalid_number : Error<
> +  "'regparm' parameter must be between 0 and 3 inclusive">;
>
>
> // Clang-Specific Attributes
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=67868&r1=67867&r2=67868&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Mar 27 16:06:47 2009
> @@ -311,9 +311,6 @@
>
>   if (D->getAttr<NoinlineAttr>())
>     F->addFnAttr(llvm::Attribute::NoInline);
> -
> -  if (D->getAttr<RegparmAttr>())
> -    ErrorUnsupported(D, "regparm attribute");
> }
>

We want to catch this:

__attribute__((regparm(1)))void bar(void) {
     foo(1, 2);
}

- Fariborz

> void CodeGenModule::SetMethodAttributes(const ObjCMethodDecl *MD,
>



More information about the cfe-commits mailing list