From d4ae6535a667d515afc0af3e67ca287548aba985 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 21 Dec 2012 21:43:05 +0000 Subject: [PATCH] Fixes couple of friend declaration -ast-print bug found by running -ast-print on all-std-headers.cpp which caused it to go into infinite loop. Now -ast-print prints all declarations found in all-std-headers.cpp. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170928 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclPrinter.cpp | 8 +++----- test/Index/comment-cplus-decls.cpp | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 4a7344c982..b4005221f4 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -580,10 +580,8 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { void DeclPrinter::VisitFriendDecl(FriendDecl *D) { if (TypeSourceInfo *TSI = D->getFriendType()) { - if (CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl()) { - Out << "friend "; - VisitCXXRecordDecl(FriendD); - } + Out << "friend "; + Out << " " << TSI->getType().getAsString(Policy); } else if (FunctionDecl *FD = dyn_cast(D->getFriendDecl())) { @@ -598,7 +596,7 @@ void DeclPrinter::VisitFriendDecl(FriendDecl *D) { else if (ClassTemplateDecl *CTD = dyn_cast(D->getFriendDecl())) { Out << "friend "; - VisitClassTemplateDecl(CTD); + VisitRedeclarableTemplateDecl(CTD); } } diff --git a/test/Index/comment-cplus-decls.cpp b/test/Index/comment-cplus-decls.cpp index 3d997a5007..29af712e1c 100644 --- a/test/Index/comment-cplus-decls.cpp +++ b/test/Index/comment-cplus-decls.cpp @@ -77,7 +77,7 @@ template friend void TemplateFriend(); template friend class TemplateFriendClass; }; -// CHECK: friend class Test {\n} +// CHECK: friend class Test // CHECK: friend void foo() // CHECK: friend int int_func() // CHECK: friend bool operator==(const Test &, const Test &) @@ -144,3 +144,28 @@ namespace test3 { } // CHECK: void f(const T &t = T()) // CHECK: friend void f(const test3::A &) + +class MyClass +{ +/** + * \brief plain friend test. +*/ + friend class MyClass; +}; +// CHECK: friend class MyClass + +template class valarray +{ +private: +/** + * \brief template friend test. +*/ + template friend class valarray; +}; +// CHECK: template <class T = unsigned int> class valarray {\n}\ntemplate <class T> class valarray +// CHECK: friend template <class T> class valarray + +class gslice +{ + valarray __size_; +}; -- 2.50.1