summaryrefslogtreecommitdiff
path: root/external/skia/help-msvc-analyzer.patch
blob: 73554111907fe6c2532bad97df58da4ca4af7148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--- skia/include/private/base/SkAssert.h.orig
+++ skia/include/private/base/SkAssert.h
@@ -60,6 +60,13 @@
     } while (false)
 #endif
 
+// when building with msvc and only when using these headers outside the skia build
+#if defined(_MSC_VER) && !SKIA_IMPLEMENTATION
+#    define SkANALYSIS_ASSUME(condition) __analysis_assume(condition)
+#else
+#    define SkANALYSIS_ASSUME(condition) static_cast<void>(0)
+#endif
+
 // SkASSERT, SkASSERTF and SkASSERT_RELEASE can be used as standalone assertion expressions, e.g.
 //    uint32_t foo(int x) {
 //        SkASSERT(x > 4);
@@ -77,7 +83,7 @@
         : []{ SK_ABORT("check(%s)", #cond); }() )
 #else
 #define SkASSERT_RELEASE(cond) \
-    static_cast<void>( (cond) ? static_cast<void>(0) : []{ SK_ABORT("check(%s)", #cond); }() )
+    static_cast<void>( (cond) ? static_cast<void>(0) : [&]{ SK_ABORT("check(%s)", #cond); SkANALYSIS_ASSUME(cond); }() )
 #endif

 #if defined(SK_DEBUG)