Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove BitField/BitFlag #684

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions include/mrdocs/ADT/BitField.hpp

This file was deleted.

23 changes: 8 additions & 15 deletions include/mrdocs/Metadata/Field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,11 @@
#include <mrdocs/Metadata/Info.hpp>
#include <mrdocs/Metadata/Source.hpp>
#include <mrdocs/Metadata/Type.hpp>
#include <mrdocs/ADT/BitField.hpp>
#include <utility>

namespace clang {
namespace mrdocs {

union FieldFlags
{
BitFieldFullValue raw{.value=0u};

// KRYSTIAN FIXME: nodiscard cannot be applied to fields; this should
// instead be isMaybeUnused. we should also store the spelling
BitFlag<0> isMaybeUnused;
BitFlag<1> isDeprecated;
BitFlag<2> hasNoUniqueAddress;
};

/** Info for fields (i.e. non-static data members)

Non-static data members cannot be redeclared.
Expand All @@ -50,9 +38,6 @@ struct FieldInfo
*/
ExprInfo Default;

// attributes (maybe_unused, no_unique_address, deprecated)
FieldFlags specs;

/** Whether the field is declared mutable */
bool IsMutable = false;

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

// KRYSTIAN FIXME: nodiscard cannot be applied to fields; this should
// instead be IsMaybeUnused. we should also store the spelling
bool IsMaybeUnused = false;

bool IsDeprecated = false;

bool HasNoUniqueAddress = false;

//--------------------------------------------

explicit FieldInfo(SymbolID ID) noexcept
Expand Down
65 changes: 22 additions & 43 deletions include/mrdocs/Metadata/Function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#define MRDOCS_API_METADATA_FUNCTION_HPP

#include <mrdocs/Platform.hpp>
#include <mrdocs/ADT/BitField.hpp>
#include <mrdocs/Metadata/Field.hpp>
#include <mrdocs/Metadata/Source.hpp>
#include <mrdocs/Metadata/Symbols.hpp>
Expand Down Expand Up @@ -68,45 +67,6 @@ enum class FunctionClass

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

/** Bit constants used with function specifiers.
*/
union FnFlags0
{
BitFieldFullValue raw;

BitFlag < 0> isVariadic;
BitFlag < 1> isVirtual;
BitFlag < 2> isVirtualAsWritten;
BitFlag < 3> isPure;
BitFlag < 4> isDefaulted;
BitFlag < 5> isExplicitlyDefaulted;
BitFlag < 6> isDeleted;
BitFlag < 7> isDeletedAsWritten;
BitFlag < 8> isNoReturn;
BitFlag < 9> hasOverrideAttr;
BitFlag <10> hasTrailingReturn;
BitFlag <11> isConst;
BitFlag <12> isVolatile;
BitField<13> isFinal;

BitField<14, 2, ConstexprKind> constexprKind;
BitField<16, 4, NoexceptKind> exceptionSpec;
BitField<20, 6, OperatorKind> overloadedOperator;
BitField<26, 3, StorageClassKind> storageClass;
BitField<29, 2, ReferenceKind> refQualifier;
};

/** Bit field used with function specifiers.
*/
union FnFlags1
{
BitFieldFullValue raw;

BitFlag<0> isNodiscard;

BitFlag<4> isExplicitObjectMemberFunction;
};

// KRYSTIAN TODO: attributes (nodiscard, deprecated, and carries_dependency)
// KRYSTIAN TODO: flag to indicate whether this is a function parameter pack
/** Represents a single function parameter */
Expand Down Expand Up @@ -152,15 +112,34 @@ struct FunctionInfo
// the class of function this is
FunctionClass Class = FunctionClass::Normal;

FnFlags0 specs0{.raw{0}};
FnFlags1 specs1{.raw{0}};

NoexceptInfo Noexcept;

ExplicitInfo Explicit;

ExprInfo Requires;

bool IsVariadic = false;
bool IsVirtual = false;
bool IsVirtualAsWritten = false;
bool IsPure = false;
bool IsDefaulted = false;
bool IsExplicitlyDefaulted = false;
bool IsDeleted = false;
bool IsDeletedAsWritten = false;
bool IsNoReturn = false;
bool HasOverrideAttr = false;
bool HasTrailingReturn = false;
bool IsConst = false;
bool IsVolatile = false;
bool IsFinal = false;
bool IsNodiscard = false;
bool IsExplicitObjectMemberFunction = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetical?


ConstexprKind Constexpr = ConstexprKind::None;
OperatorKind OverloadedOperator = OperatorKind::None;
StorageClassKind StorageClass = StorageClassKind::None;
ReferenceKind RefQualifier = ReferenceKind::None;

//--------------------------------------------

explicit FunctionInfo(SymbolID ID) noexcept
Expand Down
12 changes: 2 additions & 10 deletions include/mrdocs/Metadata/Namespace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,21 @@
#define MRDOCS_API_METADATA_NAMESPACE_HPP

#include <mrdocs/Platform.hpp>
#include <mrdocs/ADT/BitField.hpp>
#include <mrdocs/Metadata/Info.hpp>
#include <mrdocs/Metadata/Scope.hpp>
#include <vector>

namespace clang {
namespace mrdocs {

union NamespaceFlags
{
BitFieldFullValue raw{.value=0u};

BitFlag<0> isInline;
BitFlag<1> isAnonymous;
};

/** Describes a namespace.
*/
struct NamespaceInfo
: InfoCommonBase<InfoKind::Namespace>
, ScopeInfo
{
NamespaceFlags specs;
bool IsInline = false;
bool IsAnonymous = false;

/** Namespaces nominated by using-directives.
*/
Expand Down
14 changes: 2 additions & 12 deletions include/mrdocs/Metadata/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define MRDOCS_API_METADATA_RECORD_HPP

#include <mrdocs/Platform.hpp>
#include <mrdocs/ADT/BitField.hpp>
#include <mrdocs/Metadata/Info.hpp>
#include <mrdocs/Metadata/Scope.hpp>
#include <mrdocs/Metadata/Source.hpp>
Expand All @@ -27,16 +26,6 @@
namespace clang {
namespace mrdocs {

/** Bit constants used with Record metadata
*/
union RecFlags0
{
BitFieldFullValue raw{.value=0u};

BitFlag<0> isFinal;
BitFlag<1> isFinalDestructor;
};

/** Metadata for a direct base.
*/
struct BaseInfo
Expand Down Expand Up @@ -88,7 +77,8 @@ struct RecordInfo
// KRYSTIAN FIXME: this does not account for alias-declarations
bool IsTypeDef = false;

RecFlags0 specs;
bool IsFinal = false;
bool IsFinalDestructor = false;

/** List of immediate bases.
*/
Expand Down
21 changes: 8 additions & 13 deletions include/mrdocs/Metadata/Variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define MRDOCS_API_METADATA_VARIABLE_HPP

#include <mrdocs/Platform.hpp>
#include <mrdocs/ADT/BitField.hpp>
#include <mrdocs/Metadata/Expression.hpp>
#include <mrdocs/Metadata/Source.hpp>
#include <mrdocs/Metadata/Template.hpp>
Expand All @@ -23,16 +22,6 @@
namespace clang {
namespace mrdocs {

union VariableFlags0
{
BitFieldFullValue raw;

BitField<0, 3, StorageClassKind> storageClass;
BitField<3, 2, ConstexprKind> constexprKind;
BitFlag<5> isConstinit;
BitFlag<6> isThreadLocal;
};

/** A variable.

This includes variables at namespace
Expand All @@ -47,10 +36,16 @@ struct VariableInfo

std::unique_ptr<TemplateInfo> Template;

VariableFlags0 specs{.raw={0}};

ExprInfo Initializer;

StorageClassKind StorageClass = StorageClassKind::None;

ConstexprKind Constexpr = ConstexprKind::None;

bool IsConstinit = false;

bool IsThreadLocal = false;

//--------------------------------------------

explicit VariableInfo(SymbolID ID) noexcept
Expand Down
6 changes: 0 additions & 6 deletions include/mrdocs/MetadataFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ struct StaticDataMember;

struct OverloadSet;

template<unsigned char Offset,
unsigned char Size,
typename T>
struct BitField;
using BitFieldFullValue = BitField<0, 32, std::uint32_t>;

} // mrdocs
} // clang

Expand Down
Loading
Loading