[cfe-commits] r78541 - in /cfe/trunk: include/clang/AST/Attr.h include/clang/Parse/AttributeList.h lib/CodeGen/CGCall.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriter.cpp lib/Parse/AttributeList.cpp lib/Sema/SemaDeclAttr.cpp test/Sema/at
Eli Friedman
eli.friedman at gmail.com
Sun Aug 9 14:29:37 PDT 2009
On Sun, Aug 9, 2009 at 1:07 PM, Ryan Flynn<pizza at parseerror.com> wrote:
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Aug 9 15:07:29 2009
> @@ -424,6 +424,22 @@
> d->addAttr(::new (S.Context) AlwaysInlineAttr());
> }
>
> +static void HandleMallocAttr(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) << 0;
> + return;
> + }
> +
> + if (!isFunctionOrMethod(d)) {
> + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
> + << Attr.getName() << 0 /*function*/;
> + return;
> + }
> +
> + d->addAttr(::new (S.Context) MallocAttr());
> +}
It might be a good idea to check that the function returns a pointer.
-Eli
More information about the cfe-commits
mailing list