[llvm-commits] [llvm] r116920 - /llvm/trunk/include/llvm/Support/Compiler.h
Chandler Carruth
chandlerc at gmail.com
Wed Oct 20 01:44:27 PDT 2010
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.
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
More information about the llvm-commits
mailing list