[llvm] r304120 - Disabled implicit-fallthrough warnings for ConvertUTF.cpp.

Galina Kistanova via llvm-commits llvm-commits at lists.llvm.org
Sun May 28 18:34:26 PDT 2017


Author: gkistanova
Date: Sun May 28 20:34:26 2017
New Revision: 304120

URL: http://llvm.org/viewvc/llvm-project?rev=304120&view=rev
Log:
Disabled implicit-fallthrough warnings for ConvertUTF.cpp.

ConvertUTF.cpp has a little dependency on LLVM, and since the code extensively uses fall-through switches,
I prefer disabling the warning for the whole file, rather than adding attributes for each case.


Modified:
    llvm/trunk/lib/Support/ConvertUTF.cpp

Modified: llvm/trunk/lib/Support/ConvertUTF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConvertUTF.cpp?rev=304120&r1=304119&r2=304120&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ConvertUTF.cpp (original)
+++ llvm/trunk/lib/Support/ConvertUTF.cpp Sun May 28 20:34:26 2017
@@ -53,6 +53,35 @@
 #endif
 #include <assert.h>
 
+
+/*
+ * This code extensively uses fall-through switches.
+ * Keep the compiler from warning about that.
+ */
+#if defined(__clang__) && defined(__has_warning)
+# if __has_warning("-Wimplicit-fallthrough")
+#  define ConvertUTF_DISABLE_WARNINGS \
+    _Pragma("clang diagnostic push")  \
+    _Pragma("clang diagnostic ignored \"-Wimplicit-fallthrough\"")
+#  define ConvertUTF_RESTORE_WARNINGS \
+    _Pragma("clang diagnostic pop")
+# endif
+#elif defined(__GNUC__) && __GNUC__ > 6
+# define ConvertUTF_DISABLE_WARNINGS \
+   _Pragma("GCC diagnostic push")    \
+   _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
+# define ConvertUTF_RESTORE_WARNINGS \
+   _Pragma("GCC diagnostic pop")
+#endif
+#ifndef ConvertUTF_DISABLE_WARNINGS
+# define ConvertUTF_DISABLE_WARNINGS
+#endif
+#ifndef ConvertUTF_RESTORE_WARNINGS
+# define ConvertUTF_RESTORE_WARNINGS
+#endif
+
+ConvertUTF_DISABLE_WARNINGS
+
 namespace llvm {
 
 static const int halfShift  = 10; /* used for shifting by 10 bits */
@@ -708,3 +737,5 @@ ConversionResult ConvertUTF8toUTF32(cons
    --------------------------------------------------------------------- */
 
 } // namespace llvm
+
+ConvertUTF_RESTORE_WARNINGS




More information about the llvm-commits mailing list