Skip to content

Commit edc9af3

Browse files
committed
javadocs are unique pointers
1 parent 8f26655 commit edc9af3

File tree

10 files changed

+25
-23
lines changed

10 files changed

+25
-23
lines changed

include/mrdox/Metadata/Info.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <llvm/ADT/StringRef.h>
2020
#include <llvm/ADT/SmallVector.h>
2121
#include <array>
22-
#include <optional>
22+
#include <memory>
2323
#include <string>
2424
#include <vector>
2525

@@ -48,7 +48,7 @@ struct Info
4848

4949
/** The extracted javadoc for this declaration.
5050
*/
51-
std::optional<Javadoc> javadoc;
51+
std::unique_ptr<Javadoc> javadoc;
5252

5353
//--------------------------------------------
5454

source/-XML/XMLWriter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,9 @@ writeTemplate(
578578
void
579579
XMLWriter::
580580
writeJavadoc(
581-
std::optional<Javadoc> const& javadoc)
581+
std::unique_ptr<Javadoc> const& javadoc)
582582
{
583-
if(! javadoc.has_value())
583+
if(! javadoc)
584584
return;
585585
tags_.open(javadocTagName);
586586
if(auto brief = javadoc->getBrief())

source/-XML/XMLWriter.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class XMLWriter
8484
void writeInfo(Info const&);
8585
void writeSymbol(SymbolInfo const& I);
8686
void writeLocation(Location const& loc, bool def = false);
87-
void writeJavadoc(std::optional<Javadoc> const& javadoc);
87+
void writeJavadoc(std::unique_ptr<Javadoc> const& javadoc);
8888
void writeTemplate(const TemplateInfo& I);
8989

9090
template<class T>

source/-adoc/AdocWriter.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,10 @@ writeNestedTypes(
529529
void
530530
AdocWriter::
531531
writeBrief(
532-
std::optional<Javadoc> const& javadoc,
532+
std::unique_ptr<Javadoc> const& javadoc,
533533
bool withNewline)
534534
{
535-
if(! javadoc.has_value())
535+
if(! javadoc)
536536
return;
537537
auto const node = javadoc->getBrief();
538538
if(! node)
@@ -547,9 +547,9 @@ writeBrief(
547547
void
548548
AdocWriter::
549549
writeDescription(
550-
std::optional<Javadoc> const& javadoc)
550+
std::unique_ptr<Javadoc> const& javadoc)
551551
{
552-
if(! javadoc.has_value())
552+
if(! javadoc)
553553
return;
554554

555555
//os_ << '\n';

source/-adoc/AdocWriter.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ class AdocWriter
109109
FunctionInfo const& I);
110110

111111
void writeBrief(
112-
std::optional<Javadoc> const& javadoc,
112+
std::unique_ptr<Javadoc> const& javadoc,
113113
bool withNewline = true);
114114
void writeDescription(
115-
std::optional<Javadoc> const& javadoc);
115+
std::unique_ptr<Javadoc> const& javadoc);
116116
void writeLocation(SymbolInfo const& I);
117117

118118
template<class T>

source/AST/ASTVisitor.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ applyDecayToParameters(
517517
void
518518
ASTVisitor::
519519
parseRawComment(
520-
std::optional<Javadoc>& javadoc,
520+
std::unique_ptr<Javadoc>& javadoc,
521521
Decl const* D,
522522
Reporter& R)
523523
{
@@ -528,7 +528,8 @@ parseRawComment(
528528
if(RC)
529529
{
530530
RC->setAttached();
531-
javadoc.emplace(parseJavadoc(RC, D, R));
531+
javadoc = std::make_unique<Javadoc>(
532+
parseJavadoc(RC, D, R));
532533
}
533534
else
534535
{

source/AST/ASTVisitor.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ASTVisitor
176176

177177
void
178178
parseRawComment(
179-
std::optional<Javadoc>& javadoc,
179+
std::unique_ptr<Javadoc>& javadoc,
180180
Decl const* D,
181181
Reporter& R);
182182

source/AST/AnyBlock.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,19 @@ class JavadocBlock
254254
: public BitcodeReader::AnyBlock
255255
{
256256
BitcodeReader& br_;
257-
std::optional<Javadoc>& I_;
257+
std::unique_ptr<Javadoc>& I_;
258258
AnyNodeList* stack_ = nullptr;
259259
AnyNodeList J_;
260260

261261
public:
262262
JavadocBlock(
263-
std::optional<Javadoc>& I,
263+
std::unique_ptr<Javadoc>& I,
264264
BitcodeReader& br) noexcept
265265
: br_(br)
266266
, I_(I)
267267
, J_(stack_)
268268
{
269-
I_.emplace();
269+
I_ = std::make_unique<Javadoc>();
270270
}
271271

272272
llvm::Error

source/AST/BitcodeWriter.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,7 @@ emitInfoPart(
747747
StreamSubBlockGuard Block(Stream, BI_INFO_PART_ID);
748748
emitRecord(I.id, INFO_PART_ID);
749749
emitRecord(I.Name, INFO_PART_NAME);
750-
if(I.javadoc)
751-
emitBlock(*I.javadoc);
750+
emitBlock(I.javadoc);
752751
for (const auto& N : I.Namespace)
753752
emitBlock(N, FieldId::F_namespace);
754753
}
@@ -849,12 +848,14 @@ emitBlock(
849848
void
850849
BitcodeWriter::
851850
emitBlock(
852-
Javadoc const& jd)
851+
std::unique_ptr<Javadoc> const& jd)
853852
{
854-
// If the optional<Javadoc> has a value then we
853+
if(! jd)
854+
return;
855+
// If the unique_ptr<Javadoc> has a value then we
855856
// always want to emit it, even if it is empty.
856857
StreamSubBlockGuard Block(Stream, BI_JAVADOC_BLOCK_ID);
857-
emitBlock(jd.getBlocks());
858+
emitBlock(jd->getBlocks());
858859
}
859860

860861
void

source/AST/BitcodeWriter.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class BitcodeWriter
124124
void emitBlock(EnumValueInfo const& I);
125125
void emitBlock(FunctionInfo const& I);
126126
void emitBlock(Param const& I);
127-
void emitBlock(Javadoc const& jd);
127+
void emitBlock(std::unique_ptr<Javadoc> const& jd);
128128
void emitBlock(Javadoc::Node const& I);
129129
void emitBlock(NamespaceInfo const& I);
130130
void emitBlock(RecordInfo const& I);

0 commit comments

Comments
 (0)