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

Unified Diff: src/IceDefs.h

Issue 569033002: Split ConstantInteger into ConstantInteger32 and ConstantInteger64. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: rebase Created 6 years, 3 months 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
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceDefs.h
diff --git a/src/IceDefs.h b/src/IceDefs.h
index 5cd1282337383607b910ea0015e1f82cae081d40..44a61323ad769b684fbd2074693b18d4320abab0 100644
--- a/src/IceDefs.h
+++ b/src/IceDefs.h
@@ -21,6 +21,7 @@
#include <cassert>
#include <cstdio> // snprintf
#include <functional> // std::less
+#include <limits>
#include <list>
#include <map>
#include <set>
@@ -128,6 +129,11 @@ private:
Timer &operator=(const Timer &) LLVM_DELETED_FUNCTION;
};
+template <typename T> bool WouldOverflowAdd(T X, T Y) {
+ return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) ||
+ (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y)));
+}
+
} // end of namespace Ice
#endif // SUBZERO_SRC_ICEDEFS_H
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698