Skip to content

Commit cc0617c

Browse files
committed
initial support for variable and alias templates
1 parent ceb5fd3 commit cc0617c

File tree

14 files changed

+379
-46
lines changed

14 files changed

+379
-46
lines changed

include/mrdox/Metadata/Record.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <mrdox/Metadata/Reference.hpp>
2020
#include <mrdox/Metadata/Scope.hpp>
2121
#include <mrdox/Metadata/Symbol.hpp>
22-
#include <mrdox/Metadata/Template.hpp>
2322
#include <mrdox/Metadata/Symbols.hpp>
23+
#include <mrdox/Metadata/Template.hpp>
2424
#include <clang/AST/Type.h>
2525
#include <llvm/ADT/SmallVector.h>
2626
#include <optional>

include/mrdox/Metadata/Typedef.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
// Copyright (c) 2023 Vinnie Falco ([email protected])
8+
// Copyright (c) 2023 Krystian Stasiowski ([email protected])
89
//
910
// Official repository: https://github.com/cppalliance/mrdox
1011
//
@@ -14,6 +15,7 @@
1415

1516
#include <mrdox/Platform.hpp>
1617
#include <mrdox/Metadata/Symbol.hpp>
18+
#include <mrdox/Metadata/Template.hpp>
1719
#include <mrdox/Metadata/Type.hpp>
1820

1921
namespace clang {
@@ -23,6 +25,8 @@ namespace mrdox {
2325
struct TypedefInfo
2426
: SymbolInfo
2527
{
28+
friend class ASTVisitor;
29+
2630
TypeInfo Underlying;
2731

2832
// Indicates if this is a new C++ "using"-style typedef:
@@ -31,15 +35,29 @@ struct TypedefInfo
3135
// typedef std::vector<int> MyVector;
3236
bool IsUsing = false;
3337

38+
std::unique_ptr<TemplateInfo> Template;
39+
3440
//--------------------------------------------
3541

3642
static constexpr InfoType type_id = InfoType::IT_typedef;
3743

44+
explicit
3845
TypedefInfo(
3946
SymbolID id_ = SymbolID::zero)
4047
: SymbolInfo(InfoType::IT_typedef, id_)
4148
{
4249
}
50+
51+
private:
52+
// KRYSTIAN NOTE: if Template is non-null,
53+
// then IsUsing *must* be set; should we do it here?
54+
explicit
55+
TypedefInfo(
56+
std::unique_ptr<TemplateInfo>&& T)
57+
: SymbolInfo(InfoType::IT_typedef)
58+
, Template(std::move(T))
59+
{
60+
}
4361
};
4462

4563
} // mrdox

include/mrdox/Metadata/Var.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
//
66
// Copyright (c) 2023 Vinnie Falco ([email protected])
7+
// Copyright (c) 2023 Krystian Stasiowski ([email protected])
78
//
89
// Official repository: https://github.com/cppalliance/mrdox
910
//
@@ -14,6 +15,7 @@
1415
#include <mrdox/Platform.hpp>
1516
#include <mrdox/Metadata/Field.hpp>
1617
#include <mrdox/Metadata/Symbol.hpp>
18+
#include <mrdox/Metadata/Template.hpp>
1719
#include <mrdox/Metadata/Type.hpp>
1820
#include <clang/Basic/Specifiers.h>
1921

@@ -35,11 +37,15 @@ union VarFlags0
3537
struct VarInfo
3638
: SymbolInfo
3739
{
40+
friend class ASTVisitor;
41+
3842
/** The type of the variable */
3943
TypeInfo Type;
4044

4145
VarFlags0 specs{.raw={0}};
4246

47+
std::unique_ptr<TemplateInfo> Template;
48+
4349
//--------------------------------------------
4450

4551
static constexpr InfoType type_id = InfoType::IT_variable;
@@ -51,6 +57,16 @@ struct VarInfo
5157
: SymbolInfo(InfoType::IT_variable, ID, Name)
5258
{
5359
}
60+
61+
private:
62+
explicit
63+
VarInfo(
64+
std::unique_ptr<TemplateInfo>&& T)
65+
: SymbolInfo(InfoType::IT_variable)
66+
, Template(std::move(T))
67+
{
68+
69+
}
5470
};
5571

5672
} // mrdox

source/-XML/XMLWriter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ writeTypedef(
432432

433433
writeSymbol(I);
434434

435+
if(I.Template)
436+
writeTemplate(*I.Template);
437+
435438
tags_.write("type", "", {
436439
{ "name", I.Underlying.Name },
437440
{ I.Underlying.id } });
@@ -485,6 +488,9 @@ writeVar(
485488

486489
writeSymbol(I);
487490

491+
if(I.Template)
492+
writeTemplate(*I.Template);
493+
488494
write(I.specs, tags_);
489495

490496
tags_.write("type", {}, {

0 commit comments

Comments
 (0)