Skip to content

Commit c56dcae

Browse files
committed
refactor: remove BitField/BitFlag
1 parent 62736e4 commit c56dcae

15 files changed

+212
-369
lines changed

include/mrdocs/ADT/BitField.hpp

-88
This file was deleted.

include/mrdocs/Metadata/Field.hpp

+8-15
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,11 @@
1818
#include <mrdocs/Metadata/Info.hpp>
1919
#include <mrdocs/Metadata/Source.hpp>
2020
#include <mrdocs/Metadata/Type.hpp>
21-
#include <mrdocs/ADT/BitField.hpp>
2221
#include <utility>
2322

2423
namespace clang {
2524
namespace mrdocs {
2625

27-
union FieldFlags
28-
{
29-
BitFieldFullValue raw{.value=0u};
30-
31-
// KRYSTIAN FIXME: nodiscard cannot be applied to fields; this should
32-
// instead be isMaybeUnused. we should also store the spelling
33-
BitFlag<0> isMaybeUnused;
34-
BitFlag<1> isDeprecated;
35-
BitFlag<2> hasNoUniqueAddress;
36-
};
37-
3826
/** Info for fields (i.e. non-static data members)
3927
4028
Non-static data members cannot be redeclared.
@@ -50,9 +38,6 @@ struct FieldInfo
5038
*/
5139
ExprInfo Default;
5240

53-
// attributes (maybe_unused, no_unique_address, deprecated)
54-
FieldFlags specs;
55-
5641
/** Whether the field is declared mutable */
5742
bool IsMutable = false;
5843

@@ -62,6 +47,14 @@ struct FieldInfo
6247
/** The width of the bitfield */
6348
ConstantExprInfo<std::uint64_t> BitfieldWidth;
6449

50+
// KRYSTIAN FIXME: nodiscard cannot be applied to fields; this should
51+
// instead be IsMaybeUnused. we should also store the spelling
52+
bool IsMaybeUnused = false;
53+
54+
bool IsDeprecated = false;
55+
56+
bool HasNoUniqueAddress = false;
57+
6558
//--------------------------------------------
6659

6760
explicit FieldInfo(SymbolID ID) noexcept

include/mrdocs/Metadata/Function.hpp

+22-43
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#define MRDOCS_API_METADATA_FUNCTION_HPP
1515

1616
#include <mrdocs/Platform.hpp>
17-
#include <mrdocs/ADT/BitField.hpp>
1817
#include <mrdocs/Metadata/Field.hpp>
1918
#include <mrdocs/Metadata/Source.hpp>
2019
#include <mrdocs/Metadata/Symbols.hpp>
@@ -68,45 +67,6 @@ enum class FunctionClass
6867

6968
MRDOCS_DECL dom::String toString(FunctionClass kind) noexcept;
7069

71-
/** Bit constants used with function specifiers.
72-
*/
73-
union FnFlags0
74-
{
75-
BitFieldFullValue raw;
76-
77-
BitFlag < 0> isVariadic;
78-
BitFlag < 1> isVirtual;
79-
BitFlag < 2> isVirtualAsWritten;
80-
BitFlag < 3> isPure;
81-
BitFlag < 4> isDefaulted;
82-
BitFlag < 5> isExplicitlyDefaulted;
83-
BitFlag < 6> isDeleted;
84-
BitFlag < 7> isDeletedAsWritten;
85-
BitFlag < 8> isNoReturn;
86-
BitFlag < 9> hasOverrideAttr;
87-
BitFlag <10> hasTrailingReturn;
88-
BitFlag <11> isConst;
89-
BitFlag <12> isVolatile;
90-
BitField<13> isFinal;
91-
92-
BitField<14, 2, ConstexprKind> constexprKind;
93-
BitField<16, 4, NoexceptKind> exceptionSpec;
94-
BitField<20, 6, OperatorKind> overloadedOperator;
95-
BitField<26, 3, StorageClassKind> storageClass;
96-
BitField<29, 2, ReferenceKind> refQualifier;
97-
};
98-
99-
/** Bit field used with function specifiers.
100-
*/
101-
union FnFlags1
102-
{
103-
BitFieldFullValue raw;
104-
105-
BitFlag<0> isNodiscard;
106-
107-
BitFlag<4> isExplicitObjectMemberFunction;
108-
};
109-
11070
// KRYSTIAN TODO: attributes (nodiscard, deprecated, and carries_dependency)
11171
// KRYSTIAN TODO: flag to indicate whether this is a function parameter pack
11272
/** Represents a single function parameter */
@@ -152,15 +112,34 @@ struct FunctionInfo
152112
// the class of function this is
153113
FunctionClass Class = FunctionClass::Normal;
154114

155-
FnFlags0 specs0{.raw{0}};
156-
FnFlags1 specs1{.raw{0}};
157-
158115
NoexceptInfo Noexcept;
159116

160117
ExplicitInfo Explicit;
161118

162119
ExprInfo Requires;
163120

121+
bool IsVariadic = false;
122+
bool IsVirtual = false;
123+
bool IsVirtualAsWritten = false;
124+
bool IsPure = false;
125+
bool IsDefaulted = false;
126+
bool IsExplicitlyDefaulted = false;
127+
bool IsDeleted = false;
128+
bool IsDeletedAsWritten = false;
129+
bool IsNoReturn = false;
130+
bool HasOverrideAttr = false;
131+
bool HasTrailingReturn = false;
132+
bool IsConst = false;
133+
bool IsVolatile = false;
134+
bool IsFinal = false;
135+
bool IsNodiscard = false;
136+
bool IsExplicitObjectMemberFunction = false;
137+
138+
ConstexprKind Constexpr = ConstexprKind::None;
139+
OperatorKind OverloadedOperator = OperatorKind::None;
140+
StorageClassKind StorageClass = StorageClassKind::None;
141+
ReferenceKind RefQualifier = ReferenceKind::None;
142+
164143
//--------------------------------------------
165144

166145
explicit FunctionInfo(SymbolID ID) noexcept

include/mrdocs/Metadata/Namespace.hpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,21 @@
1313
#define MRDOCS_API_METADATA_NAMESPACE_HPP
1414

1515
#include <mrdocs/Platform.hpp>
16-
#include <mrdocs/ADT/BitField.hpp>
1716
#include <mrdocs/Metadata/Info.hpp>
1817
#include <mrdocs/Metadata/Scope.hpp>
1918
#include <vector>
2019

2120
namespace clang {
2221
namespace mrdocs {
2322

24-
union NamespaceFlags
25-
{
26-
BitFieldFullValue raw{.value=0u};
27-
28-
BitFlag<0> isInline;
29-
BitFlag<1> isAnonymous;
30-
};
31-
3223
/** Describes a namespace.
3324
*/
3425
struct NamespaceInfo
3526
: InfoCommonBase<InfoKind::Namespace>
3627
, ScopeInfo
3728
{
38-
NamespaceFlags specs;
29+
bool IsInline = false;
30+
bool IsAnonymous = false;
3931

4032
/** Namespaces nominated by using-directives.
4133
*/

include/mrdocs/Metadata/Record.hpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define MRDOCS_API_METADATA_RECORD_HPP
1414

1515
#include <mrdocs/Platform.hpp>
16-
#include <mrdocs/ADT/BitField.hpp>
1716
#include <mrdocs/Metadata/Info.hpp>
1817
#include <mrdocs/Metadata/Scope.hpp>
1918
#include <mrdocs/Metadata/Source.hpp>
@@ -27,16 +26,6 @@
2726
namespace clang {
2827
namespace mrdocs {
2928

30-
/** Bit constants used with Record metadata
31-
*/
32-
union RecFlags0
33-
{
34-
BitFieldFullValue raw{.value=0u};
35-
36-
BitFlag<0> isFinal;
37-
BitFlag<1> isFinalDestructor;
38-
};
39-
4029
/** Metadata for a direct base.
4130
*/
4231
struct BaseInfo
@@ -88,7 +77,8 @@ struct RecordInfo
8877
// KRYSTIAN FIXME: this does not account for alias-declarations
8978
bool IsTypeDef = false;
9079

91-
RecFlags0 specs;
80+
bool IsFinal = false;
81+
bool IsFinalDestructor = false;
9282

9383
/** List of immediate bases.
9484
*/

include/mrdocs/Metadata/Variable.hpp

+8-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define MRDOCS_API_METADATA_VARIABLE_HPP
1414

1515
#include <mrdocs/Platform.hpp>
16-
#include <mrdocs/ADT/BitField.hpp>
1716
#include <mrdocs/Metadata/Expression.hpp>
1817
#include <mrdocs/Metadata/Source.hpp>
1918
#include <mrdocs/Metadata/Template.hpp>
@@ -23,16 +22,6 @@
2322
namespace clang {
2423
namespace mrdocs {
2524

26-
union VariableFlags0
27-
{
28-
BitFieldFullValue raw;
29-
30-
BitField<0, 3, StorageClassKind> storageClass;
31-
BitField<3, 2, ConstexprKind> constexprKind;
32-
BitFlag<5> isConstinit;
33-
BitFlag<6> isThreadLocal;
34-
};
35-
3625
/** A variable.
3726
3827
This includes variables at namespace
@@ -47,10 +36,16 @@ struct VariableInfo
4736

4837
std::unique_ptr<TemplateInfo> Template;
4938

50-
VariableFlags0 specs{.raw={0}};
51-
5239
ExprInfo Initializer;
5340

41+
StorageClassKind StorageClass = StorageClassKind::None;
42+
43+
ConstexprKind Constexpr = ConstexprKind::None;
44+
45+
bool IsConstinit = false;
46+
47+
bool IsThreadLocal = false;
48+
5449
//--------------------------------------------
5550

5651
explicit VariableInfo(SymbolID ID) noexcept

include/mrdocs/MetadataFwd.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ struct StaticDataMember;
7373

7474
struct OverloadSet;
7575

76-
template<unsigned char Offset,
77-
unsigned char Size,
78-
typename T>
79-
struct BitField;
80-
using BitFieldFullValue = BitField<0, 32, std::uint32_t>;
81-
8276
} // mrdocs
8377
} // clang
8478

0 commit comments

Comments
 (0)