Skip to content

Commit c6d7e27

Browse files
committed
friend work
1 parent def255f commit c6d7e27

File tree

15 files changed

+194
-8
lines changed

15 files changed

+194
-8
lines changed

source/lib/ast/ASTVisitor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ VisitCXXMethodDecl(
203203
return mapDecl(D);
204204
}
205205

206+
bool
207+
ASTVisitor::
208+
VisitFriendDecl(
209+
FriendDecl const* D)
210+
{
211+
return true;
212+
}
213+
206214
bool
207215
ASTVisitor::
208216
VisitFunctionDecl(

source/lib/ast/ASTVisitor.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class ASTVisitor
7272
bool VisitCXXDestructorDecl(CXXDestructorDecl const* D);
7373
bool VisitCXXConstructorDecl(CXXConstructorDecl const* D);
7474
bool VisitCXXMethodDecl(CXXMethodDecl const* D);
75+
bool VisitFriendDecl(FriendDecl const* D);
7576
bool VisitFunctionDecl(FunctionDecl const* D);
7677
bool VisitTypedefDecl(TypedefDecl const* D);
7778
bool VisitTypeAliasDecl(TypeAliasDecl const* D);

source/lib/ast/Serialize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "ParseJavadoc.hpp"
1515
#include <mrdox/Debug.hpp>
1616
#include <mrdox/Metadata.hpp>
17+
#include <clang/AST/DeclFriend.h>
1718
#include <clang/Index/USRGeneration.h>
1819
#include <clang/Lex/Lexer.h>
1920
#include <llvm/ADT/Hashing.h>

source/lib/format/xml/XML.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ writeJavadoc(Javadoc const& jd)
631631
return;
632632
openTag("doc");
633633
if(auto brief = jd.getBrief())
634-
writeBrief(brief);
634+
writeBrief(*brief);
635635
writeNodes(jd.getBlocks());
636636
closeTag("doc");
637637
}
@@ -666,6 +666,9 @@ writeNode(
666666
case Javadoc::Kind::paragraph:
667667
writeParagraph(static_cast<Javadoc::Paragraph const&>(node));
668668
break;
669+
case Javadoc::Kind::brief:
670+
writeBrief(static_cast<Javadoc::Brief const&>(node));
671+
break;
669672
case Javadoc::Kind::admonition:
670673
writeAdmonition(static_cast<Javadoc::Admonition const&>(node));
671674
break;
@@ -690,14 +693,10 @@ void
690693
XMLGenerator::
691694
Writer::
692695
writeBrief(
693-
Javadoc::Paragraph const* node)
696+
Javadoc::Paragraph const& node)
694697
{
695-
if(! node)
696-
return;
697-
if(node->empty())
698-
return;
699698
openTag("brief");
700-
writeNodes(node->children);
699+
writeNodes(node.children);
701700
closeTag("brief");
702701
}
703702

source/lib/format/xml/XML.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class XMLGenerator::Writer
128128
template<class T>
129129
void writeNodes(List<T> const& list);
130130
void writeNode(Javadoc::Node const& node);
131-
void writeBrief(Javadoc::Paragraph const* node);
131+
void writeBrief(Javadoc::Paragraph const& node);
132132
void writeText(Javadoc::Text const& node);
133133
void writeStyledText(Javadoc::StyledText const& node);
134134
void writeParagraph(Javadoc::Paragraph const& node, llvm::StringRef tag = "");

tests/javadoc/friend-1.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
struct T
2+
{
3+
/// f
4+
friend void f();
5+
};

tests/javadoc/friend-1.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE mrdox SYSTEM "mrdox.dtd">
3+
<mrdox>
4+
<symbols>
5+
<symbol name="" tag="namespace"/>
6+
<symbol name="f" tag="function" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs="/>
7+
<symbol name="T" tag="struct" id="CgGNdHpW5mG/i5741WPYQDw28OQ="/>
8+
</symbols>
9+
<namespace name="">
10+
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
11+
<file path="friend-1.cpp" line="1" class="def"/>
12+
</struct>
13+
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
14+
<file path="friend-1.cpp" line="4"/>
15+
<doc>
16+
<para>
17+
<text> f</text>
18+
</para>
19+
</doc>
20+
</function>
21+
</namespace>
22+
</mrdox>

tests/javadoc/friend-2.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
struct T
2+
{
3+
/// f
4+
friend void f();
5+
};
6+
7+
void f();

tests/javadoc/friend-2.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE mrdox SYSTEM "mrdox.dtd">
3+
<mrdox>
4+
<symbols>
5+
<symbol name="" tag="namespace"/>
6+
<symbol name="f" tag="function" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs="/>
7+
<symbol name="T" tag="struct" id="CgGNdHpW5mG/i5741WPYQDw28OQ="/>
8+
</symbols>
9+
<namespace name="">
10+
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
11+
<file path="friend-2.cpp" line="1" class="def"/>
12+
</struct>
13+
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
14+
<file path="friend-2.cpp" line="4"/>
15+
<file path="friend-2.cpp" line="7"/>
16+
<doc>
17+
<para>
18+
<text> f</text>
19+
</para>
20+
</doc>
21+
</function>
22+
</namespace>
23+
</mrdox>

tests/javadoc/friend-3.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
struct T
2+
{
3+
/// T::f
4+
friend void f();
5+
};
6+
7+
struct U
8+
{
9+
friend void f();
10+
};
11+
12+
void f();

0 commit comments

Comments
 (0)