aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-05 07:27:41 +0000
committerChris Lattner <sabre@nondot.org>2009-02-05 07:27:41 +0000
commit659dc14559f7dc6e635810d5e0f6dca643549817 (patch)
tree4867c5c6a49660d6638e1f31290ef0e384a00249 /lib/Lex/Preprocessor.cpp
parent3fa8f7491a6a6c1445768ea23ec85d3554c3ba98 (diff)
correct and generalize computation of __INTMAX_MAX__.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63848 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 14bddd6826..f6a29dbd7c 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -531,10 +531,22 @@ static void InitializePredefinedMacros(Preprocessor &PP,
else
assert(0 && "Unknown long size");
char MacroBuf[60];
- sprintf(MacroBuf, "__INTMAX_MAX__=%lld",
- (TI.getIntMaxType() == TargetInfo::UnsignedLongLong?
- (1LL << (TI.getLongLongWidth() - 1)) :
- ((1LL << (TI.getLongLongWidth() - 2)) - 1)));
+ unsigned IntMaxWidth;
+ const char *IntMaxSuffix;
+ if (TI.getIntMaxType() == TargetInfo::SignedLongLong) {
+ IntMaxWidth = TI.getLongLongWidth();
+ IntMaxSuffix = "LL";
+ } else if (TI.getIntMaxType() == TargetInfo::SignedLong) {
+ IntMaxWidth = TI.getLongWidth();
+ IntMaxSuffix = "L";
+ } else {
+ assert(TI.getIntMaxType() == TargetInfo::SignedInt);
+ IntMaxWidth = TI.getIntWidth();
+ IntMaxSuffix = "";
+ }
+
+ sprintf(MacroBuf, "__INTMAX_MAX__=%lld%s", (1LL << (IntMaxWidth - 1)) - 1,
+ IntMaxSuffix);
DefineBuiltinMacro(Buf, MacroBuf);
if (TI.getIntMaxType() == TargetInfo::UnsignedLongLong)