Skip to content

Commit d5f5aa6

Browse files
committed
TypeInfo inherits from Reference, VarInfo does not
1 parent d308d29 commit d5f5aa6

File tree

10 files changed

+34
-38
lines changed

10 files changed

+34
-38
lines changed

include/mrdox/Metadata/Type.hpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,14 @@ namespace mrdox {
3434
@li unsigned long, unsigned long long
3535
*/
3636
struct TypeInfo
37+
: Reference
3738
{
38-
/** The type being referenced.
39-
40-
If this names a built-in type
41-
*/
42-
Reference Type;
43-
44-
//--------------------------------------------
45-
4639
TypeInfo() = default;
4740

4841
explicit
4942
TypeInfo(
5043
Reference const& R) noexcept
51-
: Type(R)
44+
: Reference(R)
5245
{
5346
}
5447

@@ -57,7 +50,7 @@ struct TypeInfo
5750
explicit
5851
TypeInfo(
5952
llvm::StringRef Name)
60-
: Type(
53+
: Reference(
6154
SymbolID::zero, Name, InfoType::IT_default)
6255
{
6356
}

include/mrdox/Metadata/Var.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ union VarFlags0
3434
*/
3535
struct VarInfo
3636
: SymbolInfo
37-
, TypeInfo // holds the type of this variable
3837
{
38+
/** The type of the variable */
39+
TypeInfo Type;
40+
3941
VarFlags0 specs{.raw={0}};
4042

4143
//--------------------------------------------

source/-XML/CXXTags.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,21 @@ inline void write(VarFlags0 const& bits, XMLTags& tags)
236236

237237
inline void writeReturnType(TypeInfo const& I, XMLTags& tags)
238238
{
239-
if(I.Type.Name == "void")
239+
if(I.Name == "void")
240240
return;
241241
tags.write(returnTagName, {}, {
242-
{ "type", I.Type.Name },
243-
{ I.Type.id }
242+
{ "type", I.Name },
243+
{ I.id }
244244
});
245245
}
246246

247247
inline void writeParam(Param const& P, XMLTags& tags)
248248
{
249249
tags.write(paramTagName, {}, {
250250
{ "name", P.Name, ! P.Name.empty() },
251-
{ "type", P.Type.Type.Name },
251+
{ "type", P.Type.Name },
252252
{ "default", P.Default, ! P.Default.empty() },
253-
{ P.Type.Type.id } });
253+
{ P.Type.id } });
254254
}
255255

256256
inline void writeTemplateParam(const TParam& I, XMLTags& tags)
@@ -262,7 +262,7 @@ inline void writeTemplateParam(const TParam& I, XMLTags& tags)
262262
const auto& t = I.get<TypeTParam>();
263263
std::string_view default_val;
264264
if(t.Default)
265-
default_val = t.Default->Type.Name.str();
265+
default_val = t.Default->Name.str();
266266

267267
tags.write(tparamTagName, {}, {
268268
{ "name", I.Name, ! I.Name.empty() },
@@ -281,7 +281,7 @@ inline void writeTemplateParam(const TParam& I, XMLTags& tags)
281281
tags.write(tparamTagName, {}, {
282282
{ "name", I.Name, ! I.Name.empty() },
283283
{ "class", "non-type" },
284-
{ "type", t.Type.Type.Name },
284+
{ "type", t.Type.Name },
285285
{ "default", default_val, ! default_val.empty() }
286286
});
287287
break;

source/-XML/XMLTags.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct Attribute
148148
Attribute(
149149
std::optional<TypeInfo> const& opt)
150150
: name("type")
151-
, value(opt ? opt->Type.Name.str() : std::string())
151+
, value(opt ? opt->Name.str() : std::string())
152152
, pred(opt)
153153
{
154154
}

source/-XML/XMLWriter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ writeTypedef(
431431
writeSymbol(I);
432432

433433
tags_.write("type", "", {
434-
{ "name", I.Underlying.Type.Name },
435-
{ I.Underlying.Type.id } });
434+
{ "name", I.Underlying.Name },
435+
{ I.Underlying.id } });
436436

437437
writeJavadoc(I.javadoc);
438438

@@ -459,8 +459,8 @@ writeField(
459459
write(I.specs, tags_);
460460

461461
tags_.write("type", {}, {
462-
{ "name", I.Type.Type.Name },
463-
{ I.Type.Type.id }
462+
{ "name", I.Type.Name },
463+
{ I.Type.id }
464464
});
465465

466466
writeJavadoc(I.javadoc);

source/-adoc/AdocWriter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct AdocWriter::FormalParam
116116
FormalParam const& f)
117117
{
118118
// KRYSTIAN FIXME: use AdocWriter::typeName
119-
os << f.P.Type.Type.Name;
119+
os << f.P.Type.Name;
120120
if(! f.P.Name.empty())
121121
os << ' ' << f.P.Name;
122122
// KRYSTIAN TODO: emit default argument
@@ -136,9 +136,9 @@ struct AdocWriter::TypeName
136136
llvm::raw_ostream& os,
137137
TypeName const& t)
138138
{
139-
if(t.I.Type.id == SymbolID::zero)
139+
if(t.I.id == SymbolID::zero)
140140
{
141-
os << t.I.Type.Name;
141+
os << t.I.Name;
142142
return os;
143143
}
144144
// VFALCO This is broken
@@ -151,8 +151,7 @@ struct AdocWriter::TypeName
151151
return os;
152152
}
153153
#endif
154-
auto const& T = t.I.Type;
155-
os << T.Name << "::" << T.Name;
154+
os << t.I.Name << "::" << t.I.Name;
156155
return os;
157156
}
158157
};

source/AST/ASTVisitor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ buildVar(
11601160
I.DefLoc.emplace(LineNumber, File, IsFileInRootDir);
11611161
else
11621162
I.Loc.emplace_back(LineNumber, File, IsFileInRootDir);
1163-
static_cast<TypeInfo&>(I) = getTypeInfoForType(
1163+
I.Type = getTypeInfoForType(
11641164
D->getTypeSourceInfo()->getType());
11651165
I.specs.storageClass = D->getStorageClass();
11661166
insertBitcode(ex_, writeBitcode(I));
@@ -1208,7 +1208,7 @@ buildTypedef(
12081208
return;
12091209
I.Underlying = getTypeInfoForType(
12101210
D->getUnderlyingType());
1211-
if(I.Underlying.Type.Name.empty())
1211+
if(I.Underlying.Name.empty())
12121212
{
12131213
// Typedef for an unnamed type. This is like
12141214
// "typedef struct { } Foo;". The record serializer

source/AST/AnyBlock.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ class TypeBlock
422422
if(auto Err = br_.readBlock(B, ID))
423423
return Err;
424424
F = B.F;
425-
I_.Type = std::move(B.I);
425+
static_cast<Reference&>(I_) =
426+
std::move(B.I);
426427
return llvm::Error::success();
427428
}
428429
default:
@@ -1193,7 +1194,7 @@ class VarBlock
11931194
{
11941195
case BI_TYPE_BLOCK_ID:
11951196
{
1196-
TypeBlock B(*I, br_);
1197+
TypeBlock B(I->Type, br_);
11971198
return br_.readBlock(B, ID);
11981199
}
11991200
default:
@@ -1247,8 +1248,9 @@ class FieldBlock
12471248
return br_.readBlock(B, ID);
12481249
}
12491250
default:
1250-
return TopLevelBlock::readSubBlock(ID);
1251+
break;
12511252
}
1253+
return TopLevelBlock::readSubBlock(ID);
12521254
}
12531255
};
12541256

source/AST/BitcodeWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ emitBlock(
10711071
TypeInfo const& T)
10721072
{
10731073
StreamSubBlockGuard Block(Stream, BI_TYPE_BLOCK_ID);
1074-
emitBlock(T.Type, FieldId::F_type);
1074+
emitBlock(static_cast<const Reference&>(T), FieldId::F_type);
10751075
}
10761076

10771077
void
@@ -1082,7 +1082,7 @@ emitBlock(
10821082
StreamSubBlockGuard Block(Stream, BI_VARIABLE_BLOCK_ID);
10831083
emitInfoPart(I);
10841084
emitSymbolPart(I);
1085-
emitBlock(static_cast<TypeInfo const&>(I));
1085+
emitBlock(I.Type);
10861086
emitRecord({I.specs.raw}, VARIABLE_BITS);
10871087
}
10881088

source/Metadata/Reduce.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void merge(RecordInfo& I, RecordInfo&& Other)
186186
void merge(FunctionInfo& I, FunctionInfo&& Other)
187187
{
188188
Assert(canMerge(I, Other));
189-
if (I.ReturnType.Type.id == SymbolID::zero && I.ReturnType.Type.Name == "")
189+
if (I.ReturnType.id == SymbolID::zero && I.ReturnType.Name == "")
190190
I.ReturnType = std::move(Other.ReturnType);
191191
if (I.Params.empty())
192192
I.Params = std::move(Other.Params);
@@ -202,7 +202,7 @@ void merge(TypedefInfo& I, TypedefInfo&& Other)
202202
Assert(canMerge(I, Other));
203203
if (!I.IsUsing)
204204
I.IsUsing = Other.IsUsing;
205-
if (I.Underlying.Type.Name == "")
205+
if (I.Underlying.Name == "")
206206
I.Underlying = Other.Underlying;
207207
mergeSymbolInfo(I, std::move(Other));
208208
}
@@ -220,7 +220,7 @@ void merge(EnumInfo& I, EnumInfo&& Other)
220220
void merge(FieldInfo& I, FieldInfo&& Other)
221221
{
222222
Assert(canMerge(I, Other));
223-
if(I.Type.Type.id == SymbolID::zero && I.Type.Type.Name.empty())
223+
if(I.Type.id == SymbolID::zero && I.Type.Name.empty())
224224
I.Type = std::move(Other.Type);
225225
mergeSymbolInfo(I, std::move(Other));
226226
I.specs.raw.value |= Other.specs.raw.value;

0 commit comments

Comments
 (0)