Skip to content

Commit 8881634

Browse files
committed
format work
1 parent f372be6 commit 8881634

File tree

18 files changed

+126
-178
lines changed

18 files changed

+126
-178
lines changed

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
3939
set(MRDOX_CLANG ON)
4040
endif()
4141

42+
if (WIN32)
43+
add_definitions(
44+
-D_WIN32_WINNT=0x0601
45+
-D_CRT_SECURE_NO_WARNINGS
46+
-D_SILENCE_CXX20_CISO646_REMOVED_WARNING)
47+
if("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32") # 32-bit
48+
add_compile_options(
49+
/arch:SSE2
50+
)
51+
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win64") # 64-bit
52+
add_compile_options(
53+
/arch:AMD64
54+
)
55+
endif()
56+
endif()
57+
4258
#-------------------------------------------------
4359
#
4460
# Dependencies

include/mrdox/meta/Javadoc.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ struct Javadoc
258258

259259
//---
260260

261+
/** Return true if this is empty
262+
*/
263+
bool
264+
empty() const noexcept;
265+
261266
Paragraph const*
262267
getBrief() const noexcept
263268
{

include/mrdox/meta/List.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,14 @@ extract_first_of(
536536
return nullptr;
537537
if(pred(*reinterpret_cast<pointer>(head_->get())))
538538
{
539+
auto node = head_;
539540
auto result = std::make_shared<U>(std::move(
540541
*reinterpret_cast<U*>(head_->get())));
541542
head_ = head_->next;
542543
if(head_ == &end_)
543544
tail_ = &end_;
544545
--size_;
546+
delete node;
545547
return result;
546548
}
547549
auto prev = head_;
@@ -550,12 +552,14 @@ extract_first_of(
550552
{
551553
if(pred(*reinterpret_cast<pointer>(it->get())))
552554
{
555+
auto node = it;
553556
auto result = std::make_shared<U>(std::move(
554557
*reinterpret_cast<U*>(it->get())));
555558
prev->next = it->next;
556559
if(it == tail_)
557560
tail_ = prev;
558561
--size_;
562+
delete node;
559563
return result;
560564
}
561565
prev = it;

source/lib/ast/ParseJavadoc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ class JavadocVisitor
175175
// so we will trim the leading space.
176176
// Otherwise just trim trailing space
177177
if(para_->list.empty())
178-
s = C->getText().ltrim();
178+
s = C->getText().ltrim().rtrim();
179179
else
180-
s = C->getText().rtrim();
180+
s = C->getText().ltrim().rtrim();
181+
//s = C->getText().rtrim();
181182
para_->list.emplace_back(Javadoc::Text(
182183
ensureUTF8(s.str())));
183184
}

source/lib/format/Asciidoc.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ Writer::
312312
writeFunction(
313313
FunctionInfo const& I)
314314
{
315-
return;
316315
openSection(I.Name);
317316

318317
// Brief
@@ -325,11 +324,6 @@ return;
325324
"\n"
326325
"[,cpp]\n"
327326
"----\n";
328-
329-
// Description
330-
writeDescription(I.javadoc.getBlocks());
331-
332-
// params
333327
if(! I.Params.empty())
334328
{
335329
os_ <<
@@ -349,18 +343,12 @@ return;
349343
typeName(I.ReturnType) << '\n' <<
350344
I.Name << "();" << "\n";
351345
}
352-
353346
os_ <<
354347
"----\n";
355348
closeSection();
356349

357-
//if(! I.javadoc.desc.empty())
358-
{
359-
os_ << "\n";
360-
openSection("Description");
361-
//os_ << I.javadoc.desc << "\n";
362-
closeSection();
363-
}
350+
// Description
351+
writeDescription(I.javadoc.getBlocks());
364352

365353
closeSection();
366354
}
@@ -443,10 +431,8 @@ writeOverloadSet(
443431
os_ <<
444432
"|`" << J.name << "`\n" <<
445433
"|";
446-
#if 0
447434
for(auto const& K : J.list)
448-
os_ << K->javadoc.brief << "\n";
449-
#endif
435+
writeBrief(K->javadoc.getBrief());
450436
}
451437
os_ <<
452438
"|===\n" <<
@@ -462,6 +448,7 @@ writeMemberTypes(
462448
llvm::SmallVectorImpl<MemberTypeInfo> const& list,
463449
AccessSpecifier access)
464450
{
451+
return;
465452
if(list.empty())
466453
return;
467454

source/lib/format/XML.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,28 @@ writeFunction(
298298
{
299299
writeInfo(I);
300300
writeSymbol(I);
301-
writeTag("return", {
302-
{ "name", I.ReturnType.Type.Name },
303-
{ I.ReturnType.Type.USR }
304-
});
301+
writeReturnType(I.ReturnType);
305302
for(auto const& J : I.Params)
306303
writeParam(J);
307304
if(I.Template)
308305
for(TemplateParamInfo const& J : I.Template->Params)
309306
writeTemplateParam(J);
310307
}
311308

309+
void
310+
XMLGenerator::
311+
Writer::
312+
writeReturnType(
313+
TypeInfo const& I)
314+
{
315+
if(I.Type.Name == "void")
316+
return;
317+
writeTag("return", {
318+
{ "name", I.Type.Name },
319+
{ I.Type.USR }
320+
});
321+
}
322+
312323
void
313324
XMLGenerator::
314325
Writer::
@@ -461,6 +472,8 @@ XMLGenerator::
461472
Writer::
462473
writeJavadoc(Javadoc const& jd)
463474
{
475+
if(jd.empty())
476+
return;
464477
openTag("doc");
465478
adjustNesting(1);
466479
if(auto brief = jd.getBrief())

source/lib/format/XML.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class XMLGenerator::Writer
9898
void writeTemplateParam(TemplateParamInfo const& I);
9999
void writeMemberType(MemberTypeInfo const& I);
100100

101+
void writeReturnType(TypeInfo const& I);
101102
void writeJavadoc(Javadoc const& jd);
102103

103104
template<class T>

source/lib/meta/Javadoc.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ Javadoc(
5151
{
5252
}
5353

54+
bool
55+
Javadoc::
56+
empty() const noexcept
57+
{
58+
if( ! brief_ &&
59+
blocks_.empty() &&
60+
params_.empty() &&
61+
tparams_.empty() &&
62+
returns_.empty())
63+
return true;
64+
return false;
65+
}
66+
5467
void
5568
Javadoc::
5669
merge(Javadoc& other)

source/tests/TestMain.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
#include <clang/Tooling/AllTUsExecution.h>
1313
#include <llvm/Support/Signals.h>
1414

15+
#if 0
16+
#if defined(_MSC_VER) && ! defined(NDEBUG)
17+
#define WIN32_LEAN_AND_MEAN
18+
#include <windows.h>
19+
#include <debugapi.h>
20+
#include <crtdbg.h>
21+
#include <sstream>
22+
#endif
23+
#endif
24+
1525
namespace clang {
1626
namespace mrdox {
1727

@@ -62,6 +72,15 @@ testMain(
6272
int
6373
main(int argc, const char** argv)
6474
{
75+
#if 0
76+
#if defined(_MSC_VER) && ! defined(NDEBUG)
77+
int flags = _CrtSetDbgFlag(
78+
_CRTDBG_REPORT_FLAG);
79+
flags |= _CRTDBG_LEAK_CHECK_DF;
80+
_CrtSetDbgFlag(flags);
81+
#endif
82+
#endif
83+
6584
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
6685

6786
using namespace clang::mrdox;

source/tool/ToolMain.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
#include <llvm/Support/CommandLine.h>
2929
#include <llvm/Support/Signals.h>
3030

31+
#if 0
32+
#if defined(_MSC_VER) && ! defined(NDEBUG)
33+
#define WIN32_LEAN_AND_MEAN
34+
#include <debugapi.h>
35+
#include <crtdbg.h>
36+
#endif
37+
#endif
38+
3139
namespace clang {
3240
namespace mrdox {
3341

@@ -150,6 +158,15 @@ toolMain(
150158

151159
int main(int argc, char const** argv)
152160
{
161+
#if 0
162+
#if defined(_MSC_VER) && ! defined(NDEBUG)
163+
int flags = _CrtSetDbgFlag(
164+
_CRTDBG_REPORT_FLAG);
165+
flags |= _CRTDBG_LEAK_CHECK_DF;
166+
_CrtSetDbgFlag(flags);
167+
#endif
168+
#endif
169+
153170
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
154171

155172
clang::mrdox::Reporter R;

0 commit comments

Comments
 (0)