Author: arphaman Date: Tue Apr 18 10:12:34 2017 New Revision: 300560 URL: http://llvm.org/viewvc/llvm-project?rev=300560&view=rev Log: [ASTPrinter] Print template parameter lists for out-of-line functions
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp Modified: cfe/trunk/lib/AST/DeclPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=300560&r1=300559&r2=300560&view=diff ============================================================================== --- cfe/trunk/lib/AST/DeclPrinter.cpp (original) +++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Apr 18 10:12:34 2017 @@ -478,6 +478,11 @@ void DeclPrinter::VisitFunctionDecl(Func if (D->isFunctionTemplateSpecialization()) Out << "template<> "; + else if (!D->getDescribedFunctionTemplate()) { + for (unsigned I = 0, NumTemplateParams = D->getNumTemplateParameterLists(); + I < NumTemplateParams; ++I) + printTemplateParameters(D->getTemplateParameterList(I)); + } CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D); CXXConversionDecl *ConversionDecl = dyn_cast<CXXConversionDecl>(D); @@ -1055,6 +1060,12 @@ void DeclPrinter::VisitTemplateDecl(cons void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { prettyPrintPragmas(D->getTemplatedDecl()); + // Print any leading template parameter lists. + if (const FunctionDecl *FD = D->getTemplatedDecl()) { + for (unsigned I = 0, NumTemplateParams = FD->getNumTemplateParameterLists(); + I < NumTemplateParams; ++I) + printTemplateParameters(FD->getTemplateParameterList(I)); + } VisitRedeclarableTemplateDecl(D); // Never print "instantiations" for deduction guides (they don't really Modified: cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp?rev=300560&r1=300559&r2=300560&view=diff ============================================================================== --- cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp (original) +++ cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp Tue Apr 18 10:12:34 2017 @@ -52,3 +52,44 @@ void Wrapper::Inner::staticMember() { } // CHECK: void Wrapper::Inner::staticMember() } + +template<int x, typename T> +class TemplateRecord { + void function(); + template<typename U> void functionTemplate(T, U); +}; + +template<int x, typename T> +void TemplateRecord<x, T>::function() { } +// CHECK: template <int x, typename T> void TemplateRecord<x, T>::function() + +template<int x, typename T> +template<typename U> +void TemplateRecord<x, T>::functionTemplate(T, U) { } +// CHECK: template <int x, typename T> template <typename U> void TemplateRecord<x, T>::functionTemplate(T, U) + +template<> +class TemplateRecord<0, int> { + void function(); + template<typename U> void functionTemplate(int, U); +}; + +void TemplateRecord<0, int>::function() { } +// CHECK: void TemplateRecord<0, int>::function() + +template<typename U> +void TemplateRecord<0, int>::functionTemplate(int, U) { } +// CHECK: template <typename U> void TemplateRecord<0, int>::functionTemplate(int, U) + +template<typename T> +struct OuterTemplateRecord { + template<typename U> + struct Inner { + void function(); + }; +}; + +template<typename T> +template<typename U> +void OuterTemplateRecord<T>::Inner<U>::function() { } +// CHECK: template <typename T> template <typename U> void OuterTemplateRecord<T>::Inner<U>::function() _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits