summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Frontend/InitPreprocessor.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 9990fc42ba1..e5a4169502d 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -169,9 +169,10 @@ static void DefineTypeSize(llvm::StringRef MacroName, unsigned TypeWidth,
llvm::StringRef ValSuffix, bool isSigned,
MacroBuilder& Builder) {
long long MaxVal;
- if (isSigned)
- MaxVal = (1LL << (TypeWidth - 1)) - 1;
- else
+ if (isSigned) {
+ assert(TypeWidth != 1);
+ MaxVal = ~0ULL >> (65-TypeWidth);
+ } else
MaxVal = ~0LL >> (64-TypeWidth);
Builder.defineMacro(MacroName, llvm::Twine(MaxVal) + ValSuffix);
OpenPOWER on IntegriCloud