Index: test/Lexer/ms-extensions.c
===================================================================
--- test/Lexer/ms-extensions.c	(revision 168447)
+++ test/Lexer/ms-extensions.c	(working copy)
@@ -6,7 +6,6 @@
 __int32 x3 = 5i32;
 __int64 x5 = 0x42i64;
 __int64 x6 = 0x42I64;
-__int64 x4 = 70000000i128;
 
 __int64 y = 0x42i64u;  // expected-error {{invalid suffix}}
 __int64 w = 0x43ui64; 
Index: test/Sema/ms-integers.c
===================================================================
--- test/Sema/ms-integers.c	(revision 0)
+++ test/Sema/ms-integers.c	(revision 0)
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
+
+// Check that MS integer literals really are truncated to the specified width.
+int a[255i8 == -1 ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
+int a[256ui8 == 0 ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
+int a[65535i16 == -1 ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
+int a[65536ui16 == 0 ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
+int a[4294967295i32 == -1 ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
+int a[4294967296ui32 == 0 ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
+int a[18446744073709551615i64 == -1LL ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
+int a[18446744073709551616ui64 == 0LL ? 1 : -1]; // expected-warning {{integer constant is too large for its type}}
Index: test/Sema/alloc_size.c
===================================================================
--- test/Sema/alloc_size.c	(revision 168447)
+++ test/Sema/alloc_size.c	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-gcc-compat -verify %s
 
 void* my_malloc(unsigned char) __attribute__((alloc_size(1)));
 void* my_calloc(unsigned char, short) __attribute__((alloc_size(1,2)));
@@ -19,7 +19,7 @@
 
 void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK
 
-void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-warning {{integer constant is too large for its type}} // expected-error {{attribute parameter 1 is out of bounds}}
+void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-error {{attribute parameter 1 is out of bounds}}
 
 void* fn10(size_t, size_t) __attribute__((alloc_size(1,2))); // expected-error{{redefinition of parameter}} \
                                                              // expected-error{{a parameter list without types is only allowed in a function definition}} \
Index: test/Sema/128bitint.c
===================================================================
--- test/Sema/128bitint.c	(revision 168447)
+++ test/Sema/128bitint.c	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
 typedef int i128 __attribute__((__mode__(TI)));
 typedef unsigned u128 __attribute__((__mode__(TI)));
 
@@ -12,28 +12,28 @@
 __int128 i = (__int128)0;
 unsigned __int128 u = (unsigned __int128)-1;
 
-long long SignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}}
-__int128_t Signed128 = 123456789012345678901234567890i128;
-long long Signed64 = 123456789012345678901234567890i128; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}}
-unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}}
-__uint128_t Unsigned128 = 123456789012345678901234567890Ui128;
-unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}}
+__int128_t Signed128 = 123456789012345678901234567890; // expected-warning {{GCC interprets literal as uintmax_t}}
+__int128_t SignedTooBig = 170141183460469231731687303715884105728; // expected-warning {{integer constant is so large that it is unsigned}} expected-warning {{GCC interprets literal as uintmax_t}}
+long long Signed64 = 123456789012345678901234567890; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}} expected-warning {{GCC interprets literal as uintmax_t}}
+__uint128_t Unsigned128 = 123456789012345678901234567890; // expected-warning {{GCC interprets literal as uintmax_t}}
+__int128_t UnsignedTooBig = 340282366920938463463374607431768211456; // expected-warning {{integer constant is too large for its type}} expected-warning {{GCC interprets literal as uintmax_t}}
+unsigned long long Unsigned64 = 123456789012345678901234567890U; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}} expected-warning {{GCC interprets literal as uintmax_t}}
 
 // Ensure we don't crash when user passes 128-bit values to type safety
 // attributes.
 void pointer_with_type_tag_arg_num_1(void *buf, int datatype)
-    __attribute__(( pointer_with_type_tag(mpi,0x10000000000000001i128,1) )); // expected-error {{attribute parameter 2 is out of bounds}}
+    __attribute__(( pointer_with_type_tag(mpi,0x10000000000000001,1) )); // expected-error {{attribute parameter 2 is out of bounds}} expected-warning {{GCC interprets literal as uintmax_t}}
 
 void pointer_with_type_tag_arg_num_2(void *buf, int datatype)
-    __attribute__(( pointer_with_type_tag(mpi,1,0x10000000000000001i128) )); // expected-error {{attribute parameter 3 is out of bounds}}
+    __attribute__(( pointer_with_type_tag(mpi,1,0x10000000000000001) )); // expected-error {{attribute parameter 3 is out of bounds}} expected-warning {{GCC interprets literal as uintmax_t}}
 
 void MPI_Send(void *buf, int datatype) __attribute__(( pointer_with_type_tag(mpi,1,2) ));
 
-static const __uint128_t mpi_int_wrong __attribute__(( type_tag_for_datatype(mpi,int) )) = 0x10000000000000001i128; // expected-error {{'type_tag_for_datatype' attribute requires the initializer to be an integer constant expression that can be represented by a 64 bit integer}}
+static const __uint128_t mpi_int_wrong __attribute__(( type_tag_for_datatype(mpi,int) )) = 0x10000000000000001; // expected-error {{'type_tag_for_datatype' attribute requires the initializer to be an integer constant expression that can be represented by a 64 bit integer}} expected-warning {{GCC interprets literal as uintmax_t}}
 static const int mpi_int __attribute__(( type_tag_for_datatype(mpi,int) )) = 10;
 
 void test(int *buf)
 {
-  MPI_Send(buf, 0x10000000000000001i128); // expected-warning {{implicit conversion from '__int128' to 'int' changes value}}
+  MPI_Send(buf, 0x10000000000000001); // expected-warning {{implicit conversion from '__int128' to 'int' changes value}} expected-warning {{GCC interprets literal as uintmax_t}}
 }
 
Index: test/SemaCXX/MicrosoftExtensions.cpp
===================================================================
--- test/SemaCXX/MicrosoftExtensions.cpp	(revision 168447)
+++ test/SemaCXX/MicrosoftExtensions.cpp	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-compatibility -fexceptions -fcxx-exceptions
 
 
 // ::type_info is predeclared with forward class declartion
@@ -103,8 +103,8 @@
 {
   // This is an ambiguous call in standard C++.
   // This calls f(long long) in Microsoft mode because LL is always signed.
-  f(0xffffffffffffffffLL);
-  f(0xffffffffffffffffi64);
+  f(0xffffffffffffffffLL); // expected-warning{{integer constant is too large for its type}}
+  f(0xffffffffffffffffi64); // expected-warning{{integer constant is too large for its type}}
 }
 
 // Enumeration types with a fixed underlying type.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 168447)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -67,6 +67,9 @@
   InGroup<LiteralRange>;
 def warn_double_const_requires_fp64 : Warning<
   "double precision constant requires cl_khr_fp64, casting to single precision">;
+def warn_gcc_extended_integer_literal : Warning<
+  "GCC interprets literal as uintmax_t">,
+  InGroup<GccCompat>;
 
 // C99 variable-length arrays
 def ext_vla : Extension<"variable length arrays are a C99 feature">,
Index: include/clang/Lex/LiteralSupport.h
===================================================================
--- include/clang/Lex/LiteralSupport.h	(revision 168447)
+++ include/clang/Lex/LiteralSupport.h	(working copy)
@@ -59,6 +59,7 @@
   bool isFloat;       // 1.0f
   bool isImaginary;   // 1.0i
   bool isMicrosoftInteger;  // Microsoft suffix extension i8, i16, i32, or i64.
+  unsigned microsoftWidth;  // Used with microsoft suffixes to record width.
 
   bool isIntegerLiteral() const {
     return !saw_period && !saw_exponent;
Index: unittests/AST/StmtPrinterTest.cpp
===================================================================
--- unittests/AST/StmtPrinterTest.cpp	(revision 168447)
+++ unittests/AST/StmtPrinterTest.cpp	(working copy)
@@ -131,12 +131,16 @@
     "void A() {"
     "  1, -1, 1U, 1u,"
     "  1L, 1l, -1L, 1UL, 1ul,"
-    "  1LL, -1LL, 1ULL;"
+    "  1LL, -1LL, 1ULL,"
+    "  1000000000000000000000,"
+    "  1000000000000000000000U;"
     "}",
     "A",
     "1 , -1 , 1U , 1U , "
     "1L , 1L , -1L , 1UL , 1UL , "
-    "1LL , -1LL , 1ULL"));
+    "1LL , -1LL , 1ULL , "
+    "1000000000000000000000 , "
+    "1000000000000000000000U"));
     // Should be: with semicolon
 }
 
@@ -146,20 +150,14 @@
     "  1i8, -1i8, 1ui8, "
     "  1i16, -1i16, 1ui16, "
     "  1i32, -1i32, 1ui32, "
-    "  1i64, -1i64, 1ui64, "
-    "  1i128, -1i128, 1ui128, 1Ui128,"
-    "  0x10000000000000000i128;"
+    "  1i64, -1i64, 1ui64;"
     "}",
     "A",
     "1 , -1 , 1U , "
     "1 , -1 , 1U , "
     "1L , -1L , 1UL , "
-    "1LL , -1LL , 1ULL , "
-    "1 , -1 , 1U , 1U , "
-    "18446744073709551616i128"));
+    "1LL , -1LL , 1ULL"));
     // Should be: with semicolon
-    // WRONG; all 128-bit literals should be printed as 128-bit.
-    // (This is because currently we do semantic analysis incorrectly.)
 }
 
 TEST(StmtPrinter, TestFloatingPointLiteral) {
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp	(revision 168447)
+++ lib/Sema/SemaDeclAttr.cpp	(working copy)
@@ -1114,6 +1114,12 @@
       return;
     }
 
+    if (!ArgNum.isIntN(64)) {
+      S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
+      << "alloc_size" << I.getArgNum() << Ex->getSourceRange();
+      return;
+    }
+    
     uint64_t x = ArgNum.getZExtValue();
 
     if (x < 1 || x > NumArgs) {
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp	(revision 168447)
+++ lib/Sema/SemaExpr.cpp	(working copy)
@@ -2830,101 +2830,160 @@
       else
         Diag(Tok.getLocation(), diag::ext_c99_longlong);
     }
-
-    // Get the value in the widest-possible width.
-    unsigned MaxWidth = Context.getTargetInfo().getIntMaxTWidth();
-    // The microsoft literal suffix extensions support 128-bit literals, which
-    // may be wider than [u]intmax_t.
-    if (Literal.isMicrosoftInteger && MaxWidth < 128)
-      MaxWidth = 128;
-    llvm::APInt ResultVal(MaxWidth, 0);
-
-    if (Literal.GetIntegerValue(ResultVal)) {
-      // If this value didn't fit into uintmax_t, warn and force to ull.
-      Diag(Tok.getLocation(), diag::warn_integer_too_large);
-      Ty = Context.UnsignedLongLongTy;
-      assert(Context.getTypeSize(Ty) == ResultVal.getBitWidth() &&
-             "long long is not intmax_t?");
-    } else {
-      // If this value fits into a ULL, try to figure out what else it fits into
-      // according to the rules of C99 6.4.4.1p5.
-
-      // Octal, Hexadecimal, and integers with a U suffix are allowed to
-      // be an unsigned int.
-      bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
-
-      // Check from smallest to largest, picking the smallest type we can.
-      unsigned Width = 0;
-      if (!Literal.isLong && !Literal.isLongLong) {
-        // Are int/unsigned possibilities?
-        unsigned IntSize = Context.getTargetInfo().getIntWidth();
-
-        // Does it fit in a unsigned int?
-        if (ResultVal.isIntN(IntSize)) {
-          // Does it fit in a signed int?
-          if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
-            Ty = Context.IntTy;
-          else if (AllowUnsigned)
-            Ty = Context.UnsignedIntTy;
-          Width = IntSize;
-        }
+    
+    // If we are in MSVC mode, we pretend that "LL" is a microsoft literal
+    // suffix in order to get the expected (wrong) behavior.
+    if (getLangOpts().MicrosoftMode && Literal.isLongLong) {
+      Literal.isMicrosoftInteger = true;
+      Literal.microsoftWidth = 64;
+    }
+    
+    if (Literal.isMicrosoftInteger) {
+      // Handle Microsoft literals (those with i8, i16, i32, i64 suffixes)
+      // entirely separately, as they behave very differently from the suffixes
+      // specified by the C and C++ standards.
+      
+      // Try to get the literal value as a 64-bit integer, which is the widest
+      // type supported by MSVC literals.
+      unsigned Width = 64;
+      llvm::APInt ResultVal(Width, 0);
+      if (Literal.GetIntegerValue(ResultVal))
+        Diag(Tok.getLocation(), diag::warn_integer_too_large);
+      // Microsoft literals simply *are* the specified type, regardless of
+      // whether the value fits into it or not, or whether they are hex or
+      // decimal or octal.
+      if (Literal.isLongLong) {
+        Width = Context.getTargetInfo().getLongLongWidth();
+        Ty = Literal.isUnsigned ? Context.UnsignedLongLongTy :
+          Context.LongLongTy;
+      } else if (Literal.isLong) {
+        Width = Context.getTargetInfo().getLongWidth();
+        Ty = Literal.isUnsigned ? Context.UnsignedLongTy : Context.LongTy;
+      } else {
+        Width = Context.getTargetInfo().getIntWidth();
+        Ty = Literal.isUnsigned ? Context.UnsignedIntTy : Context.IntTy;
       }
-
-      // Are long/unsigned long possibilities?
-      if (Ty.isNull() && !Literal.isLongLong) {
-        unsigned LongSize = Context.getTargetInfo().getLongWidth();
-
-        // Does it fit in a unsigned long?
-        if (ResultVal.isIntN(LongSize)) {
-          // Does it fit in a signed long?
-          if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
-            Ty = Context.LongTy;
-          else if (AllowUnsigned)
-            Ty = Context.UnsignedLongTy;
-          Width = LongSize;
-        }
+      
+      // Issue a warning if the literal is too wide for its type, and truncate.
+      if (ResultVal.getActiveBits() > (Literal.isUnsigned ?
+                                       Literal.microsoftWidth :
+                                       Literal.microsoftWidth - 1)) {
+        Diag(Tok.getLocation(), diag::warn_integer_too_large);
+        // APInt asserts on NOP-truncations, so we need to be a little bit
+        // carefull; otherwise we would crash when the literal is signed and
+        // microsoftWidth == Width.
+        if (Literal.microsoftWidth < Width)
+          ResultVal = ResultVal.trunc(Literal.microsoftWidth);
       }
-
-      // Check long long if needed.
-      if (Ty.isNull()) {
-        unsigned LongLongSize = Context.getTargetInfo().getLongLongWidth();
-
-        // Does it fit in a unsigned long long?
-        if (ResultVal.isIntN(LongLongSize)) {
-          // Does it fit in a signed long long?
-          // To be compatible with MSVC, hex integer literals ending with the
-          // LL or i64 suffix are always signed in Microsoft mode.
-          if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
-              (getLangOpts().MicrosoftExt && Literal.isLongLong)))
-            Ty = Context.LongLongTy;
-          else if (AllowUnsigned)
-            Ty = Context.UnsignedLongLongTy;
-          Width = LongLongSize;
-        }
+      
+      // Unlike in the non-MS-literal case, we may have already truncated the
+      // APInt to be smaller than the final literal, so we may need to adjust
+      // the size in either direciton here; use sextOrTrunc instead of trunc.
+      if (ResultVal.getBitWidth() != Width)
+        ResultVal = ResultVal.sextOrTrunc(Width);
+      Res = IntegerLiteral::Create(Context, ResultVal, Ty, Tok.getLocation());
+    } else {
+      // We will evaluate literals in an "extended integer type" as allowed by
+      // the C and C++ standards.  On LP64 platforms (which have __[u]int128_t)
+      // we use that type.  However, we can't use it on other platforms, or
+      // else we would generate arithmetic using those types and crash when we
+      // try to codegen.  If we don't have LP64, we use [unsigned] long long
+      // instead.
+      QualType ExtendedSignedType = Context.LongLongTy;
+      QualType ExtendedUnsignedType = Context.UnsignedLongLongTy;
+      unsigned ExtendedWidth = Context.getTargetInfo().getLongLongWidth();
+      
+      // Checking for 64-bit pointers is perhaps not the correct way to detect
+      // i128 support, but it seems to be what is done elsewhere.
+      if (PP.getTargetInfo().getPointerWidth(0) >= 64) {
+        ExtendedSignedType = Context.Int128Ty;
+        ExtendedUnsignedType = Context.UnsignedInt128Ty;
+        ExtendedWidth = 128;
       }
+      
+      // Try to get the literal value in our extended unsigned type (which is
+      // the widest type we can support for the target).
+      unsigned Width = ExtendedWidth;
+      llvm::APInt ResultVal(ExtendedWidth, 0);
+      if (Literal.GetIntegerValue(ResultVal)) {
+        // If the literal cannot fit into even the extended type, it has no
+        // type defined by the standards; we issue a warning and truncate it
+        // to the extended type as that makes the most sense out of the
+        // available options.
+        Diag(Tok.getLocation(), diag::warn_integer_too_large);
+        Ty = ExtendedUnsignedType;
+      } else {
+        // We succeeded in getting the literal value as and extended integer;
+        // now figure out what type it really should have according to the
+        // rules of C11 [Integer Constants] and C++11 [lex.icon].  Those rules
+        // can be summarized as follows:
+        //
+        // - use the smallest type that can hold the specified value and is at
+        //   least as large as implied by the suffix.
+        // - if the literal is decimal (not octal or hex), and does not have a
+        //   'U' suffix, then the type must be signed
+        // - if the literal has a 'U' suffix, the type must be unsigned.
+        // - otherwise, the type may be either signed or unsigned.
+        //
+        // First determine which types are allowed by the spelling of the
+        // literal.
+        bool AllowSigned = !Literal.isUnsigned;
+        bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
+        bool AllowInt = !Literal.isLong && !Literal.isLongLong;
+        bool AllowLong = !Literal.isLongLong;
         
-      // If it doesn't fit in unsigned long long, and we're using Microsoft
-      // extensions, then its a 128-bit integer literal.
-      if (Ty.isNull() && Literal.isMicrosoftInteger) {
-        if (Literal.isUnsigned)
-          Ty = Context.UnsignedInt128Ty;
-        else
-          Ty = Context.Int128Ty;
-        Width = 128;
+        // Then pick the smallest of the allowed types that is large enough
+        // to hold the value of the literal.
+        unsigned LiteralWidth = ResultVal.getActiveBits();
+        unsigned IntWidth = Context.getTargetInfo().getIntWidth();
+        unsigned LongWidth = Context.getTargetInfo().getLongWidth();
+        unsigned LongLongWidth = Context.getTargetInfo().getLongLongWidth();
+        
+        if (AllowSigned && AllowInt && LiteralWidth < IntWidth) {
+          Ty = Context.IntTy;
+          Width = IntWidth;
+        } else if (AllowUnsigned && AllowInt && LiteralWidth <= IntWidth) {
+          Ty = Context.UnsignedIntTy;
+          Width = IntWidth;
+        } else if (AllowSigned && AllowLong && LiteralWidth < LongWidth) {
+          Ty = Context.LongTy;
+          Width = LongWidth;
+        } else if (AllowUnsigned && AllowLong && LiteralWidth <= LongWidth) {
+          Ty = Context.UnsignedLongTy;
+          Width = LongWidth;
+        } else if (AllowSigned && LiteralWidth < LongLongWidth) {
+          Ty = Context.LongLongTy;
+          Width = LongLongWidth;
+        } else if (AllowUnsigned && LiteralWidth <= LongLongWidth) {
+          Ty = Context.UnsignedLongLongTy;
+          Width = LongLongWidth;
+        } else if (AllowSigned && LiteralWidth < ExtendedWidth) {
+          Ty = ExtendedSignedType;
+          Width = ExtendedWidth;
+        } else {
+          // If the literal is signed, but doesn't fit in the extended signed
+          // type, issue a warning and deliver the "correct" value as unsigned
+          // instead.  This result isn't specified by the standards, but it
+          // satisfies the principle of least surprise.
+          if (!AllowUnsigned)
+            Diag(Tok.getLocation(), diag::warn_integer_too_large_for_signed);
+          Ty = ExtendedUnsignedType;
+          Width = ExtendedWidth;
+        }
       }
-
-      // If we still couldn't decide a type, we probably have something that
-      // does not fit in a signed long long, but has no U suffix.
-      if (Ty.isNull()) {
-        Diag(Tok.getLocation(), diag::warn_integer_too_large_for_signed);
-        Ty = Context.UnsignedLongLongTy;
-        Width = Context.getTargetInfo().getLongLongWidth();
-      }
-
+      
+      // If the literal has extended integer type, and that type is not long
+      // long, then we are delivering a different result than does GCC (which
+      // truncates over-large literals to unsigned long long), so we provide
+      // a compatibility warning.
+      if (Width == ExtendedWidth &&
+          Width != Context.getTargetInfo().getLongLongWidth())
+        Diag(Tok.getLocation(), diag::warn_gcc_extended_integer_literal);
+      
       if (ResultVal.getBitWidth() != Width)
         ResultVal = ResultVal.trunc(Width);
+      Res = IntegerLiteral::Create(Context, ResultVal, Ty, Tok.getLocation());
     }
-    Res = IntegerLiteral::Create(Context, ResultVal, Ty, Tok.getLocation());
   }
 
   // If this is an imaginary literal, create the ImaginaryLiteral wrapper.
Index: lib/AST/StmtPrinter.cpp
===================================================================
--- lib/AST/StmtPrinter.cpp	(revision 168447)
+++ lib/AST/StmtPrinter.cpp	(working copy)
@@ -739,8 +739,8 @@
   case BuiltinType::ULong:     OS << "UL"; break;
   case BuiltinType::LongLong:  OS << "LL"; break;
   case BuiltinType::ULongLong: OS << "ULL"; break;
-  case BuiltinType::Int128:    OS << "i128"; break;
-  case BuiltinType::UInt128:   OS << "Ui128"; break;
+  case BuiltinType::Int128:    break; // no suffix.
+  case BuiltinType::UInt128:   OS << 'U'; break;
   }
 }
 
Index: lib/Lex/LiteralSupport.cpp
===================================================================
--- lib/Lex/LiteralSupport.cpp	(revision 168447)
+++ lib/Lex/LiteralSupport.cpp	(working copy)
@@ -480,6 +480,7 @@
   isFloat = false;
   isImaginary = false;
   isMicrosoftInteger = false;
+  microsoftWidth = 0;
   hadError = false;
 
   if (*s == '0') { // parse radix
@@ -565,20 +566,15 @@
             case '8':
               s += 2; // i8 suffix
               isMicrosoftInteger = true;
+              microsoftWidth = 8;
               break;
             case '1':
               if (s + 2 == ThisTokEnd) break;
               if (s[2] == '6') {
                 s += 3; // i16 suffix
                 isMicrosoftInteger = true;
+                microsoftWidth = 16;
               }
-              else if (s[2] == '2') {
-                if (s + 3 == ThisTokEnd) break;
-                if (s[3] == '8') {
-                  s += 4; // i128 suffix
-                  isMicrosoftInteger = true;
-                }
-              }
               break;
             case '3':
               if (s + 2 == ThisTokEnd) break;
@@ -586,6 +582,7 @@
                 s += 3; // i32 suffix
                 isLong = true;
                 isMicrosoftInteger = true;
+                microsoftWidth = 32;
               }
               break;
             case '6':
@@ -594,6 +591,7 @@
                 s += 3; // i64 suffix
                 isLongLong = true;
                 isMicrosoftInteger = true;
+                microsoftWidth = 64;
               }
               break;
             default:
