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<int_type, double>::method1() return 10; } + +int test_typedef() { + typedef Foo<int, double> TypedefArg; + // CHECK: typedef Foo<int, double> TypedefArg; + return 10; +} + +int test_typedef2() { + typedef Foo<int> TypedefArg; + // CHECK: typedef Foo<int> 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<int> *' with an lvalue of type 'const A<int> *'}} + return ptr2; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'const A<int> *'}} else { - return ptr3; // expected-error{{cannot initialize return object of type 'A<int> *' with an lvalue of type 'A<int, double> *'}} + return ptr3; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'A<int, double> *'}} } } 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<int_type, double>::method1() return 10; } + +int test_typedef() { + typedef Foo<int, double> TypedefArg; + // CHECK: typedef Foo<int, double> TypedefArg; + return 10; +} + +int test_typedef2() { + typedef Foo<int> TypedefArg; + // CHECK: typedef Foo<int> 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<int> *' with an lvalue of type 'const A<int> *'}} + return ptr2; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'const A<int> *'}} else { - return ptr3; // expected-error{{cannot initialize return object of type 'A<int> *' with an lvalue of type 'A<int, double> *'}} + return ptr3; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'A<int, double> *'}} } } 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