summaryrefslogtreecommitdiffstats
path: root/clang
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
commitfafd8d1be93cd5a43a08dbba36264edfd693381c (patch)
treeef1af098e6c1c63199eec71b8d735191f0d50c3e /clang
parent6e5ca6bff9b209da8f3242ce7924a0b4557beace (diff)
downloadbcm5719-llvm-fafd8d1be93cd5a43a08dbba36264edfd693381c.tar.gz
bcm5719-llvm-fafd8d1be93cd5a43a08dbba36264edfd693381c.zip
correct and generalize computation of __INTMAX_MAX__.
llvm-svn: 63848
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 14bddd68266..f6a29dbd7c5 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/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)
OpenPOWER on IntegriCloud