[llvm] r340811 - [benchmark] Silence warning by applying upstream patch

Kirill Bobyrev via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 28 03:27:49 PDT 2018


Author: omtcyfz
Date: Tue Aug 28 03:27:49 2018
New Revision: 340811

URL: http://llvm.org/viewvc/llvm-project?rev=340811&view=rev
Log:
[benchmark] Silence warning by applying upstream patch

ompiling benchmark library (introduced in D50894) with the latest
bootstrapped Clang produces a lot of warnings, this issue was addressed
in the upstream patch I pushed earlier.

Upstream patch:
https://github.com/google/benchmark/commit/f85304e4e3a0e4e1bf15b91720df4a19e90b589f

`README.LLVM` notes were updated to reflect the latest changes.

Reviewed by: lebedev.ri

Differential Revision: https://reviews.llvm.org/D51342

Modified:
    llvm/trunk/utils/benchmark/README.LLVM
    llvm/trunk/utils/benchmark/include/benchmark/benchmark.h
    llvm/trunk/utils/benchmark/src/internal_macros.h

Modified: llvm/trunk/utils/benchmark/README.LLVM
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/benchmark/README.LLVM?rev=340811&r1=340810&r2=340811&view=diff
==============================================================================
--- llvm/trunk/utils/benchmark/README.LLVM (original)
+++ llvm/trunk/utils/benchmark/README.LLVM Tue Aug 28 03:27:49 2018
@@ -1,9 +1,13 @@
 LLVM notes
 ----------
 
-This directory contains the Google Benchmark source code. This directory is
-under a different license than LLVM.
+This directory contains the Google Benchmark source code. Currently, the checked
+Benchmark library version is v1.4.1.
+
+This directory is under a different license than LLVM.
 
 Changes:
 
 * Bazel BUILD files are removed from the library
+* https://github.com/google/benchmark/commit/f85304e4e3a0e4e1bf15b91720df4a19e90b589f
+  is applied on top of the v1.4.1 to silence compiler warnings

Modified: llvm/trunk/utils/benchmark/include/benchmark/benchmark.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/benchmark/include/benchmark/benchmark.h?rev=340811&r1=340810&r2=340811&view=diff
==============================================================================
--- llvm/trunk/utils/benchmark/include/benchmark/benchmark.h (original)
+++ llvm/trunk/utils/benchmark/include/benchmark/benchmark.h Tue Aug 28 03:27:49 2018
@@ -240,6 +240,18 @@ BENCHMARK(BM_test)->Unit(benchmark::kMil
 #define BENCHMARK_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
 #endif
 
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
+#if defined(__GNUC__) || __has_builtin(__builtin_unreachable)
+  #define BENCHMARK_UNREACHABLE() __builtin_unreachable()
+#elif defined(_MSC_VER)
+  #define BENCHMARK_UNREACHABLE() __assume(false)
+#else
+  #define BENCHMARK_UNREACHABLE() ((void)0)
+#endif
+
 namespace benchmark {
 class BenchmarkReporter;
 
@@ -1434,9 +1446,9 @@ inline const char* GetTimeUnitString(Tim
     case kMicrosecond:
       return "us";
     case kNanosecond:
-    default:
       return "ns";
   }
+  BENCHMARK_UNREACHABLE();
 }
 
 inline double GetTimeUnitMultiplier(TimeUnit unit) {
@@ -1446,9 +1458,9 @@ inline double GetTimeUnitMultiplier(Time
     case kMicrosecond:
       return 1e6;
     case kNanosecond:
-    default:
       return 1e9;
   }
+  BENCHMARK_UNREACHABLE();
 }
 
 } // namespace benchmark

Modified: llvm/trunk/utils/benchmark/src/internal_macros.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/benchmark/src/internal_macros.h?rev=340811&r1=340810&r2=340811&view=diff
==============================================================================
--- llvm/trunk/utils/benchmark/src/internal_macros.h (original)
+++ llvm/trunk/utils/benchmark/src/internal_macros.h Tue Aug 28 03:27:49 2018
@@ -6,9 +6,6 @@
 #ifndef __has_feature
 #define __has_feature(x) 0
 #endif
-#ifndef __has_builtin
-#define __has_builtin(x) 0
-#endif
 
 #if defined(__clang__)
   #if !defined(COMPILER_CLANG)
@@ -78,12 +75,4 @@
   #define BENCHMARK_MAYBE_UNUSED
 #endif
 
-#if defined(COMPILER_GCC) || __has_builtin(__builtin_unreachable)
-  #define BENCHMARK_UNREACHABLE() __builtin_unreachable()
-#elif defined(COMPILER_MSVC)
-  #define BENCHMARK_UNREACHABLE() __assume(false)
-#else
-  #define BENCHMARK_UNREACHABLE() ((void)0)
-#endif
-
 #endif  // BENCHMARK_INTERNAL_MACROS_H_




More information about the llvm-commits mailing list