[compiler-rt] b9fd724 - [sanitizer] Add Abs<T>

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 23 22:25:47 PST 2021


Author: Vitaly Buka
Date: 2021-11-23T22:25:36-08:00
New Revision: b9fd7247a71d7ab652c3e827b7018d6ea446024e

URL: https://github.com/llvm/llvm-project/commit/b9fd7247a71d7ab652c3e827b7018d6ea446024e
DIFF: https://github.com/llvm/llvm-project/commit/b9fd7247a71d7ab652c3e827b7018d6ea446024e.diff

LOG: [sanitizer] Add Abs<T>

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_common.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 065154496eb5..6ec6bb4bd856 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -460,6 +460,10 @@ template <class T>
 constexpr T Max(T a, T b) {
   return a > b ? a : b;
 }
+template <class T>
+constexpr T Abs(T a) {
+  return a < 0 ? -a : a;
+}
 template<class T> void Swap(T& a, T& b) {
   T tmp = a;
   a = b;


        


More information about the llvm-commits mailing list