reikdas updated this revision to Diff 261682. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79290/new/
https://reviews.llvm.org/D79290 Files: clang/lib/AST/TemplateBase.cpp clang/test/Misc/integer-literal-printing.cpp 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 <short T> class Type1 {}; -template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: expects an l-value for 1st argument}} +template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = (short)-42] not viable: expects an l-value for 1st argument}} template <unsigned short T> class Type2 {}; template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42U] not viable: expects an l-value for 1st argument}} 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 <short T> class Type1 {}; -template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: expects an l-value for 1st argument}} +template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = (short)-42] not viable: expects an l-value for 1st argument}} template <unsigned short T> class Type2 {}; template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42U] not viable: expects an l-value for 1st argument}} 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; } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits