[llvm-commits] [llvm] r116920 - /llvm/trunk/include/llvm/Support/Compiler.h

Chandler Carruth chandlerc at gmail.com
Sat Oct 23 02:20:59 PDT 2010


On Wed, Oct 20, 2010 at 5:38 PM, Bill Wendling <wendling at apple.com> wrote:

> On Oct 20, 2010, at 1:44 AM, Chandler Carruth wrote:
>
> Author: chandlerc
> Date: Wed Oct 20 03:44:27 2010
> New Revision: 116920
>
> URL: http://llvm.org/viewvc/llvm-project?rev=116920&view=rev
> Log:
> Add a comment about ATTRIBUTE_UNUSED to avoid further confusion over when
> to
> use it.
>
> There's no reason not to use this for variables. And it avoids the
> void-casting hack.
>

Chris expressly asked for the void-cast for variables:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100705/032066.html

The comment I added was intended to help document this preference. I'll
happily change it if you change Chris's mind. ;]


>
> -bw
>
> Modified:
>    llvm/trunk/include/llvm/Support/Compiler.h
>
> Modified: llvm/trunk/include/llvm/Support/Compiler.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=116920&r1=116919&r2=116920&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/Compiler.h (original)
> +++ llvm/trunk/include/llvm/Support/Compiler.h Wed Oct 20 03:44:27 2010
> @@ -31,6 +31,14 @@
> #define ATTRIBUTE_USED
> #endif
>
> +// Some compilers warn about unused functions. When a function is
> sometimes
> +// used or not depending on build settings (e.g. a function only called
> from
> +// within "assert"), this attribute can be used to suppress such warnings.
> +//
> +// However, it shouldn't be used for unused *variables*, as those have a
> much
> +// more portable solution:
> +//   (void)unused_var_name;
> +// Prefer cast-to-void wherever it is sufficient.
> #if (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
> #define ATTRIBUTE_UNUSED __attribute__((__unused__))
> #else
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101023/ccaea671/attachment.html>


More information about the llvm-commits mailing list