Skip to content

Commit 18210c1

Browse files
committed
child enums are refs
1 parent f446d15 commit 18210c1

File tree

12 files changed

+23
-38
lines changed

12 files changed

+23
-38
lines changed

include/mrdox/Metadata/Scope.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct Scope
3838
std::vector<Reference> Records;
3939
std::vector<Reference> Functions;
4040
std::vector<Reference> Typedefs;
41-
std::vector<EnumInfo> Enums;
41+
std::vector<Reference> Enums;
4242
std::vector<Reference> Variables;
4343

4444
explicit

source/api/AST/AnyBlock.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,20 +1213,6 @@ readSubBlock(
12131213
}
12141214
break;
12151215
}
1216-
case BI_ENUM_BLOCK_ID:
1217-
{
1218-
if constexpr(
1219-
std::derived_from<T, NamespaceInfo> ||
1220-
std::derived_from<T, RecordInfo>)
1221-
{
1222-
EnumBlock B(br_);
1223-
if(auto Err = br_.readBlock(B, ID))
1224-
return Err;
1225-
I->Children.Enums.emplace_back(std::move(*B.I));
1226-
return llvm::Error::success();
1227-
}
1228-
break;
1229-
}
12301216
default:
12311217
break;
12321218
}

source/api/AST/BitcodeIDs.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ enum class FieldId
134134
F_child_namespace,
135135
F_child_record,
136136
F_child_function,
137-
F_child_typedef
137+
F_child_typedef,
138+
F_child_enum
138139
};
139140

140141
} // mrdox

source/api/AST/BitcodeWriter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,8 @@ emitBlock(
900900
emitBlock(ref, FieldId::F_child_function);
901901
for (const auto& ref : I.Children.Typedefs)
902902
emitBlock(ref, FieldId::F_child_typedef);
903-
for (const auto& C : I.Children.Enums)
904-
emitBlock(C);
903+
for (const auto& ref : I.Children.Enums)
904+
emitBlock(ref, FieldId::F_child_enum);
905905
}
906906

907907
void
@@ -929,8 +929,8 @@ emitBlock(
929929
emitBlock(C, FieldId::F_child_function);
930930
for (const auto& ref : I.Children.Typedefs)
931931
emitBlock(ref, FieldId::F_child_typedef);
932-
for (const auto& C : I.Children.Enums)
933-
emitBlock(C);
932+
for (const auto& ref : I.Children.Enums)
933+
emitBlock(ref, FieldId::F_child_enum);
934934
if (I.Template)
935935
emitBlock(*I.Template);
936936
emitRecord(I.Friends, RECORD_FRIENDS);

source/api/AST/DecodeRecord.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ decodeRecord(
219219
case FieldId::F_child_record:
220220
case FieldId::F_child_function:
221221
case FieldId::F_child_typedef:
222+
case FieldId::F_child_enum:
222223
case FieldId::F_default:
223224
Field = F;
224225
return llvm::Error::success();

source/api/AST/Serializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ insertChild(Parent& parent, Child&& I)
473473
}
474474
else if constexpr(std::is_same_v<Child, EnumInfo>)
475475
{
476-
parent.Children.Enums.emplace_back(std::move(I));
476+
parent.Children.Enums.emplace_back(I.id, I.Name, Child::type_id);
477477
}
478478
else
479479
{

source/api/Corpus.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ visit(Scope const& I, Visitor& f) const
177177
for(auto const& ref : I.Typedefs)
178178
if(! visit(get<TypedefInfo>(ref.id), f))
179179
return false;
180-
for(auto const& J : I.Enums)
181-
if(! visit(J, f))
180+
for(auto const& ref : I.Enums)
181+
if(! visit(get<EnumInfo>(ref.id), f))
182182
return false;
183183
return true;
184184
}
@@ -230,8 +230,8 @@ visitWithOverloads(
230230
for(auto const& ref : I.Typedefs)
231231
if(! visit(get<TypedefInfo>(ref.id), f))
232232
return false;
233-
for(auto const& J : I.Enums)
234-
if(! visit(J, f))
233+
for(auto const& ref : I.Enums)
234+
if(! visit(get<EnumInfo>(ref.id), f))
235235
return false;
236236
return true;
237237
}

source/api/CorpusImpl.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ visit(Scope& I, MutableVisitor& f)
8080
visit(get<FunctionInfo>(ref.id), f);
8181
for(auto& ref : I.Typedefs)
8282
visit(get<TypedefInfo>(ref.id), f);
83-
for(auto& J : I.Enums)
84-
visit(J, f);
83+
for(auto& ref : I.Enums)
84+
visit(get<EnumInfo>(ref.id), f);
8585
}
8686

8787
void
@@ -171,11 +171,8 @@ class CorpusImpl::
171171
canonicalize(scope.Namespaces);
172172
canonicalize(scope.Records);
173173
canonicalize(scope.Functions);
174-
// VFALCO These are non-copyable and thus cannot be sorted yet
175-
#if 0
176174
canonicalize(scope.Typedefs);
177175
canonicalize(scope.Enums);
178-
#endif
179176
}
180177

181178
void canonicalize(std::vector<Reference>& list) noexcept

source/api/Metadata/Namespace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ merge(NamespaceInfo&& Other)
4747
reduceChildren(Children.Namespaces, std::move(Other.Children.Namespaces));
4848
reduceChildren(Children.Records, std::move(Other.Children.Records));
4949
reduceChildren(Children.Functions, std::move(Other.Children.Functions));
50-
reduceChildren(Children.Enums, std::move(Other.Children.Enums));
5150
reduceChildren(Children.Typedefs, std::move(Other.Children.Typedefs));
51+
reduceChildren(Children.Enums, std::move(Other.Children.Enums));
5252
mergeBase(std::move(Other));
5353
}
5454

source/api/Metadata/Record.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ merge(RecordInfo&& Other)
4949
// Reduce children if necessary.
5050
reduceChildren(Children.Records, std::move(Other.Children.Records));
5151
reduceChildren(Children.Functions, std::move(Other.Children.Functions));
52-
reduceChildren(Children.Enums, std::move(Other.Children.Enums));
5352
reduceChildren(Children.Typedefs, std::move(Other.Children.Typedefs));
53+
reduceChildren(Children.Enums, std::move(Other.Children.Enums));
5454
SymbolInfo::merge(std::move(Other));
5555
if (!Template)
5656
Template = Other.Template;

0 commit comments

Comments
 (0)