ubsan shift fixes
Use an inline function that does a normal shift. When built for the sanitizer, add casts so that the shift is unsigned.
Also make a few fixes to do unsigned shifts or avoid the shift altogether; and add an argument spec to some macros.
R=reed@google.com,mtklein@google.com
BUG=skia:4633
Review URL: https://codereview.chromium.org/1503423003
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index e4569f2..261fcae 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -306,6 +306,14 @@
return (uint16_t)x == x;
}
+static inline int32_t SkLeftShift(int32_t value, int32_t shift) {
+ return (int32_t) ((uint32_t) value << shift);
+}
+
+static inline int64_t SkLeftShift(int64_t value, int32_t shift) {
+ return (int64_t) ((uint64_t) value << shift);
+}
+
//////////////////////////////////////////////////////////////////////////////
/** Returns the number of entries in an array (not a pointer) */