[PATCH] D103040: Print default template argument if manually specified in typedef declaration.
dblaikie added inline comments. Comment at: clang/test/SemaTemplate/class-template-id.cpp:12-14 +return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} else { +return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} dblaikie wrote: > FWIW, looks like this was a reduction in quality - printing the value of the > default argument in these error messages, when omitting it was probably > desirable? > > & doesn't seem to be a necessary consequence of the patch description's goals. Nevermind - I was looking at the parameter types, not the return type. I see the return type is written out more explicitly, so it makes sense that that fuller name be rendered in the message too. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103040/new/ https://reviews.llvm.org/D103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D103040: Print default template argument if manually specified in typedef declaration.
dblaikie added inline comments. Comment at: clang/test/SemaTemplate/class-template-id.cpp:12-14 +return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} else { +return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} FWIW, looks like this was a reduction in quality - printing the value of the default argument in these error messages, when omitting it was probably desirable? & doesn't seem to be a necessary consequence of the patch description's goals. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103040/new/ https://reviews.llvm.org/D103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D103040: Print default template argument if manually specified in typedef declaration.
This revision was automatically updated to reflect the committed changes. Closed by commit rGc33ebad73516: Print default template argument if manually specified in typedef declaration. (authored by reikdas, committed by v.g.vassilev). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103040/new/ https://reviews.llvm.org/D103040 Files: clang/lib/AST/TypePrinter.cpp clang/test/SemaTemplate/class-template-id.cpp clang/test/SemaTemplate/default-arguments-ast-print.cpp Index: clang/test/SemaTemplate/default-arguments-ast-print.cpp === --- clang/test/SemaTemplate/default-arguments-ast-print.cpp +++ clang/test/SemaTemplate/default-arguments-ast-print.cpp @@ -10,3 +10,15 @@ // CHECK: int Foo::method1() return 10; } + +int test_typedef() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} + +int test_typedef2() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} Index: clang/test/SemaTemplate/class-template-id.cpp === --- clang/test/SemaTemplate/class-template-id.cpp +++ clang/test/SemaTemplate/class-template-id.cpp @@ -9,9 +9,9 @@ if (ptr) return ptr; // okay else if (ptr2) -return ptr2; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'const A *'}} +return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} else { -return ptr3; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'A *'}} +return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} } } Index: clang/lib/AST/TypePrinter.cpp === --- clang/lib/AST/TypePrinter.cpp +++ clang/lib/AST/TypePrinter.cpp @@ -1449,8 +1449,7 @@ T->getTemplateName().print(OS, Policy); } - const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : nullptr; - printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL); + printTemplateArgumentList(OS, T->template_arguments(), Policy); spaceBeforePlaceHolder(OS); } Index: clang/test/SemaTemplate/default-arguments-ast-print.cpp === --- clang/test/SemaTemplate/default-arguments-ast-print.cpp +++ clang/test/SemaTemplate/default-arguments-ast-print.cpp @@ -10,3 +10,15 @@ // CHECK: int Foo::method1() return 10; } + +int test_typedef() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} + +int test_typedef2() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} Index: clang/test/SemaTemplate/class-template-id.cpp === --- clang/test/SemaTemplate/class-template-id.cpp +++ clang/test/SemaTemplate/class-template-id.cpp @@ -9,9 +9,9 @@ if (ptr) return ptr; // okay else if (ptr2) -return ptr2; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'const A *'}} +return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} else { -return ptr3; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'A *'}} +return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} } } Index: clang/lib/AST/TypePrinter.cpp === --- clang/lib/AST/TypePrinter.cpp +++ clang/lib/AST/TypePrinter.cpp @@ -1449,8 +1449,7 @@ T->getTemplateName().print(OS, Policy); } - const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : nullptr; - printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL); + printTemplateArgumentList(OS, T->template_arguments(), Policy); spaceBeforePlaceHolder(OS); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D103040: Print default template argument if manually specified in typedef declaration.
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103040/new/ https://reviews.llvm.org/D103040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D103040: Print default template argument if manually specified in typedef declaration.
reikdas created this revision. reikdas added a reviewer: rsmith. reikdas requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. If a default template type argument is manually specified to be of the default type, then it is committed when printing the template. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D103040 Files: clang/lib/AST/TypePrinter.cpp clang/test/SemaTemplate/class-template-id.cpp clang/test/SemaTemplate/default-arguments-ast-print.cpp Index: clang/test/SemaTemplate/default-arguments-ast-print.cpp === --- clang/test/SemaTemplate/default-arguments-ast-print.cpp +++ clang/test/SemaTemplate/default-arguments-ast-print.cpp @@ -10,3 +10,15 @@ // CHECK: int Foo::method1() return 10; } + +int test_typedef() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} + +int test_typedef2() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} Index: clang/test/SemaTemplate/class-template-id.cpp === --- clang/test/SemaTemplate/class-template-id.cpp +++ clang/test/SemaTemplate/class-template-id.cpp @@ -9,9 +9,9 @@ if (ptr) return ptr; // okay else if (ptr2) -return ptr2; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'const A *'}} +return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} else { -return ptr3; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'A *'}} +return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} } } Index: clang/lib/AST/TypePrinter.cpp === --- clang/lib/AST/TypePrinter.cpp +++ clang/lib/AST/TypePrinter.cpp @@ -1447,8 +1447,7 @@ T->getTemplateName().print(OS, Policy); } - const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : nullptr; - printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL); + printTemplateArgumentList(OS, T->template_arguments(), Policy); spaceBeforePlaceHolder(OS); } Index: clang/test/SemaTemplate/default-arguments-ast-print.cpp === --- clang/test/SemaTemplate/default-arguments-ast-print.cpp +++ clang/test/SemaTemplate/default-arguments-ast-print.cpp @@ -10,3 +10,15 @@ // CHECK: int Foo::method1() return 10; } + +int test_typedef() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} + +int test_typedef2() { + typedef Foo TypedefArg; + // CHECK: typedef Foo TypedefArg; + return 10; +} Index: clang/test/SemaTemplate/class-template-id.cpp === --- clang/test/SemaTemplate/class-template-id.cpp +++ clang/test/SemaTemplate/class-template-id.cpp @@ -9,9 +9,9 @@ if (ptr) return ptr; // okay else if (ptr2) -return ptr2; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'const A *'}} +return ptr2; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'const A *'}} else { -return ptr3; // expected-error{{cannot initialize return object of type 'A *' with an lvalue of type 'A *'}} +return ptr3; // expected-error{{cannot initialize return object of type 'A *' (aka 'A *') with an lvalue of type 'A *'}} } } Index: clang/lib/AST/TypePrinter.cpp === --- clang/lib/AST/TypePrinter.cpp +++ clang/lib/AST/TypePrinter.cpp @@ -1447,8 +1447,7 @@ T->getTemplateName().print(OS, Policy); } - const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : nullptr; - printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL); + printTemplateArgumentList(OS, T->template_arguments(), Policy); spaceBeforePlaceHolder(OS); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits