From e6560761ced83883627cf1e441feed5e4b61848e Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 22 Feb 2013 05:54:51 +0000 Subject: [PATCH] Teach -ast-print how to print trailing-return-types. llvm-svn: 175864 --- clang/lib/AST/DeclPrinter.cpp | 8 ++++++-- clang/test/SemaCXX/cxx11-ast-print.cpp | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 333e321..dce4f9a 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -542,9 +542,13 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } if (!Proto.empty()) Out << Proto; - } - else + } else { + if (FT && FT->hasTrailingReturn()) { + Out << "auto " << Proto << " -> "; + Proto.clear(); + } AFT->getResultType().print(Out, Policy, Proto); + } } else { Ty.print(Out, Policy, Proto); } diff --git a/clang/test/SemaCXX/cxx11-ast-print.cpp b/clang/test/SemaCXX/cxx11-ast-print.cpp index afabf88..66ff0f0 100644 --- a/clang/test/SemaCXX/cxx11-ast-print.cpp +++ b/clang/test/SemaCXX/cxx11-ast-print.cpp @@ -1,7 +1,6 @@ // RUN: %clang_cc1 -std=c++11 -ast-print %s | FileCheck %s -// FIXME: Print the trailing-return-type properly. -// CHECK: decltype(nullptr) operator "" _foo(const char *p, decltype(sizeof(int))); +// CHECK: auto operator "" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr); auto operator"" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr); // CHECK: decltype(""_foo) operator "" _bar(unsigned long long); -- 2.7.4