Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: include/core/SkTypes.h

Issue 1503423003: ubsan shift fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix typo Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/core/SkTypes.h
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 6c2e6361530ac9674da7f69f7b2dd978bb80ce32..77acbfded734821f3d599be8291d698c072e603f 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -303,6 +303,22 @@ static inline bool SkIsU16(long x) {
return (uint16_t)x == x;
}
+static inline int32_t SkLeftShift(int32_t value, int32_t shift) {
+#ifdef SK_BUILT_WITH_SANITIZER
+ return (int32_t) ((uint32_t) value << shift);
reed1 2015/12/09 15:54:26 do we think we can't always use the version here (
mtklein 2015/12/09 16:48:11 agree... both'll generate the same code.
caryclark 2015/12/09 19:13:12 Done.
+#else
+ return value << shift;
+#endif
+}
+
+static inline int64_t SkLeftShift(int64_t value, int32_t shift) {
+#ifdef SK_BUILT_WITH_SANITIZER
+ return (int64_t) ((uint64_t) value << shift);
+#else
+ return value << shift;
+#endif
+}
+
//////////////////////////////////////////////////////////////////////////////
/** Returns the number of entries in an array (not a pointer) */

Powered by Google App Engine
This is Rietveld 408576698