aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-12-21 21:43:05 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-12-21 21:43:05 +0000
commitd4ae6535a667d515afc0af3e67ca287548aba985 (patch)
tree981992a037ab3a61405301227049650dd14ac629
parentccbb4027d9fec8247b7af08f9134515da8e470a4 (diff)
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
-rw-r--r--lib/AST/DeclPrinter.cpp8
-rw-r--r--test/Index/comment-cplus-decls.cpp27
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<FunctionDecl>(D->getFriendDecl())) {
@@ -598,7 +596,7 @@ void DeclPrinter::VisitFriendDecl(FriendDecl *D) {
else if (ClassTemplateDecl *CTD =
dyn_cast<ClassTemplateDecl>(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 <typename T> friend void TemplateFriend();
template <typename T> friend class TemplateFriendClass;
};
-// CHECK: <Declaration>friend class Test {\n}</Declaration>
+// CHECK: <Declaration>friend class Test</Declaration>
// CHECK: <Declaration>friend void foo()</Declaration>
// CHECK: <Declaration>friend int int_func()</Declaration>
// CHECK: <Declaration>friend bool operator==(const Test &amp;, const Test &amp;)</Declaration>
@@ -144,3 +144,28 @@ namespace test3 {
}
// CHECK: <Declaration>void f(const T &amp;t = T())</Declaration>
// CHECK: <Declaration>friend void f(const test3::A &amp;)</Declaration>
+
+class MyClass
+{
+/**
+ * \brief plain friend test.
+*/
+ friend class MyClass;
+};
+// CHECK: <Declaration>friend class MyClass</Declaration>
+
+template<class _Tp> class valarray
+{
+private:
+/**
+ * \brief template friend test.
+*/
+ template <class T> friend class valarray;
+};
+// CHECK: <Declaration>template &lt;class T = unsigned int&gt; class valarray {\n}\ntemplate &lt;class T&gt; class valarray</Declaration>
+// CHECK: <Declaration>friend template &lt;class T&gt; class valarray</Declaration>
+
+class gslice
+{
+ valarray<unsigned> __size_;
+};