aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2013-02-27 18:25:41 +0000
committerAaron Ballman <aaron@aaronballman.com>2013-02-27 18:25:41 +0000
commitb3508821533854b1879e7d6a83824b4ba84ce633 (patch)
tree30585102cc36f46755a3a5e292e4453338bfbb22
parent512685dacf7978af2729e86d022fab4d78784d43 (diff)
downloadexternal_llvm-b3508821533854b1879e7d6a83824b4ba84ce633.zip
external_llvm-b3508821533854b1879e7d6a83824b4ba84ce633.tar.gz
external_llvm-b3508821533854b1879e7d6a83824b4ba84ce633.tar.bz2
Suppressing MSVC warnings; patch thanks to Peng Cheng!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176193 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Support/MathExtras.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h
index 214bb6c..d6ae58d 100644
--- a/include/llvm/Support/MathExtras.h
+++ b/include/llvm/Support/MathExtras.h
@@ -258,7 +258,10 @@ inline unsigned CountTrailingZeros_32(uint32_t Value) {
4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9,
5, 20, 8, 19, 18
};
- return Mod37BitPosition[(-Value & Value) % 37];
+ // Replace "-Value" by "1+~Value" in the following commented code to avoid
+ // MSVC warning C4146
+ // return Mod37BitPosition[(-Value & Value) % 37];
+ return Mod37BitPosition[((1 + ~Value) & Value) % 37];
#endif
}
@@ -285,7 +288,10 @@ inline unsigned CountTrailingZeros_64(uint64_t Value) {
29, 50, 43, 46, 31, 37, 21, 57, 52, 8, 26, 49, 45, 36, 56,
7, 48, 35, 6, 34, 33, 0
};
- return Mod67Position[(-Value & Value) % 67];
+ // Replace "-Value" by "1+~Value" in the following commented code to avoid
+ // MSVC warning C4146
+ // return Mod67Position[(-Value & Value) % 67];
+ return Mod67Position[((1 + ~Value) & Value) % 67];
#endif
}
@@ -420,7 +426,11 @@ int IsInf(double d);
/// alignment that may be assumed after adding the two together.
inline uint64_t MinAlign(uint64_t A, uint64_t B) {
// The largest power of 2 that divides both A and B.
- return (A | B) & -(A | B);
+ //
+ // Replace "-Value" by "1+~Value" in the following commented code to avoid
+ // MSVC warning C4146
+ // return (A | B) & -(A | B);
+ return (A | B) & (1 + ~(A | B));
}
/// NextPowerOf2 - Returns the next power of two (in 64-bits)