Skip to content

Commit 573fc11

Browse files
committed
chore: remove OptionalSymbolID
1 parent df33bd6 commit 573fc11

File tree

9 files changed

+10
-47
lines changed

9 files changed

+10
-47
lines changed

include/mrdocs/Metadata/Symbols.hpp

-15
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ namespace mrdocs {
3232
class SymbolID
3333
{
3434
public:
35-
static const SymbolID zero;
36-
3735
static const SymbolID invalid;
38-
3936
static const SymbolID global;
4037

4138
using value_type = std::uint8_t;
@@ -54,11 +51,6 @@ class SymbolID
5451
return *this != SymbolID::invalid;
5552
}
5653

57-
constexpr bool empty() const noexcept
58-
{
59-
return *this == zero;
60-
}
61-
6254
constexpr auto data() const noexcept
6355
{
6456
return data_;
@@ -101,9 +93,6 @@ class SymbolID
10193
value_type data_[20];
10294
};
10395

104-
105-
constexpr inline SymbolID SymbolID::zero = SymbolID();
106-
10796
/** The invalid Symbol ID.
10897
*/
10998
// KRYSTIAN NOTE: msvc requires inline as it doesn't consider this
@@ -116,10 +105,6 @@ constexpr inline SymbolID SymbolID::global =
116105
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
117106
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
118107

119-
/** Like std::optional<SymbolID>
120-
*/
121-
using OptionalSymbolID = Optional<SymbolID>;
122-
123108
/** Return the result of comparing s0 to s1.
124109
125110
This function returns true if the string

include/mrdocs/Metadata/Template.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ struct TemplateInfo
286286

287287
/** Primary template ID for partial and explicit specializations.
288288
*/
289-
OptionalSymbolID Primary;
289+
SymbolID Primary = SymbolID::invalid;
290290

291291
// KRYSTIAN NOTE: using the presence of args/params
292292
// to determine the specialization kind *should* work.

src/lib/-XML/XMLWriter.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,10 @@ openTemplate(
481481
if(! I)
482482
return;
483483

484-
const SymbolID& id = I->Primary ?
485-
*I->Primary : SymbolID::invalid;
486-
487484
tags_.open(templateTagName, {
488485
{"class", toString(I->specializationKind()),
489486
I->specializationKind() != TemplateSpecKind::Primary},
490-
{id}
487+
{I->Primary}
491488
});
492489

493490
for(const auto& tparam : I->Params)

src/lib/AST/ASTVisitor.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ class ASTVisitor
14351435
ClassTemplateSpecializationDecl* spec)
14361436
{
14371437
if(Decl* primary = getInstantiatedFrom(spec->getSpecializedTemplate()))
1438-
extractSymbolID(primary, I.Primary.emplace());
1438+
extractSymbolID(primary, I.Primary);
14391439
// KRYSTIAN NOTE: when this is a partial specialization, we could use
14401440
// ClassTemplatePartialSpecializationDecl::getTemplateArgsAsWritten
14411441
const TypeSourceInfo* type_written = spec->getTypeAsWritten();
@@ -1458,7 +1458,7 @@ class ASTVisitor
14581458
// the USR of the templated VarDecl seems to be the correct one.
14591459
if(auto* primary = dyn_cast<VarTemplateDecl>(
14601460
getInstantiatedFrom(spec->getSpecializedTemplate())))
1461-
extractSymbolID(primary->getTemplatedDecl(), I.Primary.emplace());
1461+
extractSymbolID(primary->getTemplatedDecl(), I.Primary);
14621462
const ASTTemplateArgumentListInfo* args_written = nullptr;
14631463
// getTemplateArgsInfo returns nullptr for partial specializations,
14641464
// so we use getTemplateArgsAsWritten if this is a partial specialization
@@ -1480,7 +1480,7 @@ class ASTVisitor
14801480
{
14811481
// KRYSTIAN NOTE: do we need to check I->Primary.has_value()?
14821482
if(Decl* primary = getInstantiatedFrom(spec->getTemplate()))
1483-
extractSymbolID(primary, I.Primary.emplace());
1483+
extractSymbolID(primary, I.Primary);
14841484
// TemplateArguments is used instead of TemplateArgumentsAsWritten
14851485
// because explicit specializations of function templates may have
14861486
// template arguments deduced from their return type and parameters
@@ -1498,7 +1498,7 @@ class ASTVisitor
14981498
candidates.size() == 1)
14991499
{
15001500
if(Decl* primary = getInstantiatedFrom(candidates.front()))
1501-
extractSymbolID(primary, I.Primary.emplace());
1501+
extractSymbolID(primary, I.Primary);
15021502
}
15031503

15041504
if(auto* args_written = spec->TemplateArgumentsAsWritten)
@@ -1801,7 +1801,7 @@ class ASTVisitor
18011801
switch(parent_context->getDeclKind())
18021802
{
18031803
// the TranslationUnit DeclContext is the global namespace;
1804-
// it uses SymbolID::zero and should *always* exist
1804+
// it uses SymbolID::global and should *always* exist
18051805
case Decl::TranslationUnit:
18061806
{
18071807
parent_id = SymbolID::global;

src/lib/AST/AnyBlock.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ class TemplateBlock
11181118
switch(ID)
11191119
{
11201120
case TEMPLATE_PRIMARY_USR:
1121-
return decodeRecord(R, I_.Primary.emplace(), Blob);
1121+
return decodeRecord(R, I_.Primary, Blob);
11221122
default:
11231123
return AnyBlock::parseRecord(R, ID, Blob);
11241124
}

src/lib/AST/BitcodeWriter.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,7 @@ emitBlock(
10381038
const TemplateInfo& T)
10391039
{
10401040
StreamSubBlockGuard Block(Stream, BI_TEMPLATE_BLOCK_ID);
1041-
if(T.Primary)
1042-
emitRecord(*T.Primary, TEMPLATE_PRIMARY_USR);
1041+
emitRecord(T.Primary, TEMPLATE_PRIMARY_USR);
10431042
for(const auto& targ : T.Args)
10441043
emitBlock(targ);
10451044
for(const auto& tparam : T.Params)

src/lib/Metadata/DomMetadata.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ domCreate(
349349
return nullptr;
350350
return dom::Object({
351351
{ "kind", toString(I->specializationKind()) },
352-
{ "primary", domCorpus.get(*I->Primary) },
352+
{ "primary", domCorpus.get(I->Primary) },
353353
{ "params", dom::newArray<DomTParamArray>( I->Params, domCorpus) },
354354
{ "args", dom::newArray<DomTArgArray>(I->Args, domCorpus) }
355355
});

src/lib/Support/Debug.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ format(
4545
return fmt::formatter<std::string>::format(std::move(str), ctx);
4646
}
4747

48-
fmt::format_context::iterator
49-
fmt::formatter<clang::mrdocs::OptionalSymbolID>::
50-
format(
51-
const clang::mrdocs::OptionalSymbolID& s,
52-
fmt::format_context& ctx) const
53-
{
54-
return fmt::formatter<clang::mrdocs::SymbolID>::format(*s, ctx);
55-
}
56-
5748
fmt::format_context::iterator
5849
fmt::formatter<clang::mrdocs::InfoKind>::
5950
format(

src/lib/Support/Debug.hpp

-9
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ struct fmt::formatter<clang::mrdocs::SymbolID>
3131
fmt::format_context& ctx) const;
3232
};
3333

34-
template<>
35-
struct fmt::formatter<clang::mrdocs::OptionalSymbolID>
36-
: fmt::formatter<clang::mrdocs::SymbolID>
37-
{
38-
fmt::format_context::iterator format(
39-
const clang::mrdocs::OptionalSymbolID& s,
40-
fmt::format_context& ctx) const;
41-
};
42-
4334
template<>
4435
struct fmt::formatter<clang::mrdocs::InfoKind>
4536
: fmt::formatter<std::string>

0 commit comments

Comments
 (0)