[cfe-commits] r63848 - /cfe/trunk/lib/Lex/Preprocessor.cpp

Chris Lattner sabre at nondot.org
Wed Feb 4 23:27:41 PST 2009


Author: lattner
Date: Thu Feb  5 01:27:41 2009
New Revision: 63848

URL: http://llvm.org/viewvc/llvm-project?rev=63848&view=rev
Log:
correct and generalize computation of __INTMAX_MAX__.

Modified:
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=63848&r1=63847&r2=63848&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Thu Feb  5 01:27:41 2009
@@ -531,10 +531,22 @@
   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)





More information about the cfe-commits mailing list