Skip to content

Commit c6d7e27

Browse files
committed
friend work
1 parent def255f commit c6d7e27

15 files changed

+194
-8
lines changed

source/lib/ast/ASTVisitor.cpp

+8
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

+1
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

+1
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

+6-7
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

+1-1
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

+5
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

+22
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

+7
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

+23
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

+12
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();

tests/javadoc/friend-3.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
<symbol name="U" tag="struct" id="FLgkhM3m0U3Lo2o3XLPUizWPH00="/>
9+
</symbols>
10+
<namespace name="">
11+
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
12+
<file path="friend-3.cpp" line="1" class="def"/>
13+
</struct>
14+
<struct name="U" id="FLgkhM3m0U3Lo2o3XLPUizWPH00=">
15+
<file path="friend-3.cpp" line="7" class="def"/>
16+
</struct>
17+
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
18+
<file path="friend-3.cpp" line="4"/>
19+
<file path="friend-3.cpp" line="9"/>
20+
<file path="friend-3.cpp" line="12"/>
21+
<doc>
22+
<para>
23+
<text> T::f</text>
24+
</para>
25+
</doc>
26+
</function>
27+
</namespace>
28+
</mrdox>

tests/javadoc/friend-4.cpp

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

tests/javadoc/friend-4.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
<symbol name="U" tag="struct" id="FLgkhM3m0U3Lo2o3XLPUizWPH00="/>
9+
</symbols>
10+
<namespace name="">
11+
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
12+
<file path="friend-4.cpp" line="1" class="def"/>
13+
</struct>
14+
<struct name="U" id="FLgkhM3m0U3Lo2o3XLPUizWPH00=">
15+
<file path="friend-4.cpp" line="6" class="def"/>
16+
</struct>
17+
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
18+
<file path="friend-4.cpp" line="3"/>
19+
<file path="friend-4.cpp" line="9"/>
20+
<file path="friend-4.cpp" line="12"/>
21+
<doc>
22+
<para>
23+
<text> U::f</text>
24+
</para>
25+
</doc>
26+
</function>
27+
</namespace>
28+
</mrdox>

tests/javadoc/friend-5.cpp

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

tests/javadoc/friend-5.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
<symbol name="U" tag="struct" id="FLgkhM3m0U3Lo2o3XLPUizWPH00="/>
9+
</symbols>
10+
<namespace name="">
11+
<struct name="T" id="CgGNdHpW5mG/i5741WPYQDw28OQ=">
12+
<file path="friend-5.cpp" line="1" class="def"/>
13+
</struct>
14+
<struct name="U" id="FLgkhM3m0U3Lo2o3XLPUizWPH00=">
15+
<file path="friend-5.cpp" line="6" class="def"/>
16+
</struct>
17+
<function name="f" id="s6nsa+zVhpzzrN+yUVPP5rvdXqs=">
18+
<file path="friend-5.cpp" line="3"/>
19+
<file path="friend-5.cpp" line="8"/>
20+
<file path="friend-5.cpp" line="12"/>
21+
<doc>
22+
<para>
23+
<text> f</text>
24+
</para>
25+
</doc>
26+
</function>
27+
</namespace>
28+
</mrdox>

0 commit comments

Comments
 (0)