Index: svn/upstream/tools/clang/lib/AST/StmtProfile.cpp
===================================================================
--- svn/upstream/tools/clang/lib/AST/StmtProfile.cpp	(revision 221593)
+++ svn/upstream/tools/clang/lib/AST/StmtProfile.cpp	(working copy)
@@ -501,6 +501,10 @@
 void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
   VisitExpr(S);
   S->getValue().Profile(ID);
+  SplitQualType splitType = S->getType().split();
+  const BuiltinType * builtinType = splitType.Ty->getAs<BuiltinType>();
+  if (builtinType)
+    ID.AddInteger(builtinType->getKind());
 }
 
 void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
@@ -513,6 +517,10 @@
   VisitExpr(S);
   S->getValue().Profile(ID);
   ID.AddBoolean(S->isExact());
+  SplitQualType splitType = S->getType().split();
+  const BuiltinType * builtinType = splitType.Ty->getAs<BuiltinType>();
+  if (builtinType)
+    ID.AddInteger(builtinType->getKind());
 }
 
 void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Index: svn/upstream/tools/clang/test/CodeGen/mips-wrong-template-mangling.cpp
===================================================================
--- svn/upstream/tools/clang/test/CodeGen/mips-wrong-template-mangling.cpp	(revision 0)
+++ svn/upstream/tools/clang/test/CodeGen/mips-wrong-template-mangling.cpp	(working copy)
@@ -0,0 +1,38 @@
+// This checks that the mangling of g4 and g6 is not dependent on the presence
+// of g3 and g5, the bug was due to the AST nodes for the array size expressions
+// being wrongly shared between g3/g4 and g5/g6 on targets where the single
+// "long" keyword has no effects
+// RUN: %clang_cc1 -triple mips-none-none -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips-none-none -DBAD -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-BAD %s
+
+#ifdef BAD
+template <class T> void g3(char (&buffer)[sizeof(T() + 5.0)]) {}
+void call_g3() {
+  char buffer[sizeof(double)];
+  // CHECK-BAD: _Z2g3IdEvRAszplcvT__ELd4014000000000000E_c
+  g3<double>(buffer);
+}
+#endif
+template <class T> void g4(char (&buffer)[sizeof(T() + 5.0L)]) {}
+void call_g4() {
+  char buffer[sizeof(long double)];
+  // CHECK: _Z2g4IeEvRAszplcvT__ELe4014000000000000E_c
+  // CHECK-BAD: _Z2g4IeEvRAszplcvT__ELe4014000000000000E_c
+  g4<long double>(buffer);
+}
+
+#ifdef BAD
+template <class T> void g5(char (&buffer)[sizeof(T() + 5)]) {}
+void call_g5() {
+  char buffer[sizeof(int)];
+  // CHECK-BAD: _Z2g5IiEvRAszplcvT__ELi5E_c 
+  g5<int>(buffer);
+}
+#endif
+template <class T> void g6(char (&buffer)[sizeof(T() + 5L)]) {}
+void call_g6() {
+  char buffer[sizeof(long int)];
+  // CHECK: _Z2g6IlEvRAszplcvT__ELl5E_c
+  // CHECK-BAD: _Z2g6IlEvRAszplcvT__ELl5E_c
+  g6<long int>(buffer);
+}
