Index: clang/lib/AST/TemplateBase.cpp =================================================================== --- clang/lib/AST/TemplateBase.cpp +++ clang/lib/AST/TemplateBase.cpp @@ -76,13 +76,18 @@ Out.write_escaped(StringRef(&Ch, 1), /*UseHexEscapes=*/ true); Out << "'"; } else { - Out << Val; if (T->isBuiltinType()) { - if (Val.isUnsigned()) - Out << "U"; - if (Val.getBitWidth() == 64) - Out << "LL"; + if (T->isUnsignedIntegerType() && Val.getBitWidth() == 64) + Out << Val << "ULL"; + else if (T->isSignedIntegerType() && Val.getBitWidth() == 64) + Out << Val << "LL"; + else if (T->isUnsignedIntegerType()) + Out << Val << "U"; + else + Out << "(" << T->getCanonicalTypeInternal().getAsString(Policy) << ")" << Val; } + else + Out << Val; } } Index: clang/test/Misc/integer-literal-printing.cpp =================================================================== --- clang/test/Misc/integer-literal-printing.cpp +++ clang/test/Misc/integer-literal-printing.cpp @@ -2,7 +2,7 @@ // PR11179 template class Type1 {}; -template void Function1(Type1& x) {} // expected-note{{candidate function [with T = -42] not viable: expects an l-value for 1st argument}} +template void Function1(Type1& x) {} // expected-note{{candidate function [with T = (short)-42] not viable: expects an l-value for 1st argument}} template class Type2 {}; template void Function2(Type2& x) {} // expected-note{{candidate function [with T = 42U] not viable: expects an l-value for 1st argument}}