Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
178 changes: 89 additions & 89 deletions include/ifc/abstract-sgraph.hxx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions include/ifc/basic-types.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <ifc/underlying.hxx>

namespace ifc {
enum class ColumnNumber : int32_t {
enum class ColumnNumber : std::int32_t {
Invalid = -1,
};
enum LineNumber : int32_t {
enum LineNumber : std::int32_t {
Max = 0x00ffffff,
};

Expand Down
6 changes: 3 additions & 3 deletions include/ifc/dom/node.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <vector>

namespace ifc::util {
enum class SortKind : uint16_t {
enum class SortKind : std::uint16_t {
Expr,
Decl,
Type,
Expand Down Expand Up @@ -116,8 +116,8 @@ namespace ifc::util {

private:
const SortKind index_kind;
const uint16_t index_sort;
const uint32_t index_value;
const std::uint16_t index_sort;
const std::uint32_t index_value;
};

template<typename F>
Expand Down
26 changes: 13 additions & 13 deletions include/ifc/file.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace ifc {
using index_like::Index;

// Type for the size of a partition entry
enum class EntitySize : uint32_t {};
enum class EntitySize : std::uint32_t {};

// Return the number of bytes in the object representation of type T.
// This is, of course, the same thing as sizeof(T), except that we insist
Expand All @@ -32,7 +32,7 @@ namespace ifc {
// Offset in a byte stream.
// TODO: abstract over large file support. For now, we expect module exports to be vastly smaller
// than the collection of all declarations from a header file content.
enum class ByteOffset : uint32_t {};
enum class ByteOffset : std::uint32_t {};

constexpr bool zero(ByteOffset x)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace ifc {
}

// Data type for assessing the 'size' of a collection.
enum class Cardinality : uint32_t {};
enum class Cardinality : std::uint32_t {};

constexpr bool zero(Cardinality n)
{
Expand Down Expand Up @@ -95,13 +95,13 @@ namespace ifc {
}

// Module Interface signature
inline constexpr uint8_t InterfaceSignature[4] = {0x54, 0x51, 0x45, 0x1A};
inline constexpr std::uint8_t InterfaceSignature[4] = {0x54, 0x51, 0x45, 0x1A};

// ABI description.
enum class Abi : uint8_t {};
enum class Abi : std::uint8_t {};

// Architecture description
enum class Architecture : uint8_t {
enum class Architecture : std::uint8_t {
Unknown = 0x00, // unknown target
X86 = 0x01, // x86 (32-bit) target
X64 = 0x02, // x64 (64-bit) target
Expand All @@ -112,21 +112,21 @@ namespace ifc {
};

// CplusPlus Version Info : defined by [cpp.predefined]/1
enum class CPlusPlus : uint32_t {};
enum class CPlusPlus : std::uint32_t {};

// Names and strings are stored in a global string table.
// The texts are referenced via offsets.
enum class TextOffset : uint32_t {};
enum class TextOffset : std::uint32_t {};

// Index into the scope table.
enum ScopeIndex : uint32_t {};
enum ScopeIndex : std::uint32_t {};

struct SHA256Hash {
std::array<uint32_t, 8> value;
std::array<std::uint32_t, 8> value;
};

// The various sort of translation units that can be represented in an IFC file.
enum class UnitSort : uint8_t {
enum class UnitSort : std::uint8_t {
Source, // General source translation unit.
Primary, // Module primary interface unit.
Partition, // Module interface partition unit.
Expand Down Expand Up @@ -232,7 +232,7 @@ namespace ifc {

SHA256Hash hash_bytes(const std::byte* first, const std::byte* last);

inline SHA256Hash bytes_to_hash(const uint8_t* first, const uint8_t* last)
inline SHA256Hash bytes_to_hash(const std::uint8_t* first, const std::uint8_t* last)
{
auto byte_count = std::distance(first, last);
if (byte_count != sizeof(SHA256Hash))
Expand All @@ -242,7 +242,7 @@ namespace ifc {
auto size = static_cast<std::size_t>(byte_count);

SHA256Hash hash{};
uint8_t* alias = reinterpret_cast<uint8_t*>(hash.value.data());
std::uint8_t* alias = reinterpret_cast<uint8_t*>(hash.value.data());
// std::copy in devcrt issues a warning whenever you try to copy
// an unbounded T* so we will just use std::memcpy instead.
std::memcpy(alias, first, size);
Expand Down
12 changes: 6 additions & 6 deletions include/ifc/index-utils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

// Provide support infrastructure for common operations for index-like types.
// These are types that have the same representational characteristics as
// the 32-bit unsigned integer type uint32_t.
// the 32-bit unsigned integer type std::uint32_t.
namespace index_like {
// Useful for generating sentinel values for enumerations. Typically placeholder for null values.
template<ifc::Enum E>
inline constexpr auto sentinel_for = std::numeric_limits<ifc::raw<E>>::max();

// Check whether the type parameter is uint32_t.
// Check whether the type parameter is std::uint32_t.
// In fact, it would be acceptable if values of that type
// promotes to an integer type with rank less than uint32_t. This concept
// promotes to an integer type with rank less than std::uint32_t. This concept
// is useful mainly to guard against the anarchic implicit conversions
// between builtin types. It is a best-effort attempt to prevent value truncation.
template<typename S>
Expand All @@ -30,10 +30,10 @@ namespace index_like {
concept U32Enum = ifc::Enum<T> and Uint32<ifc::raw<T>>;

template<U32Enum T>
inline constexpr uint32_t wilderness = sentinel_for<T>;
inline constexpr std::uint32_t wilderness = sentinel_for<T>;

// Generic representational index value type.
// Every other type is representationally isomorphic to this (or uint32_t).
// Every other type is representationally isomorphic to this (or std::uint32_t).
enum class Index : std::uint32_t {};

// Advance an index by a give amount.
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace index_like {
struct Over {
using SortType = S;
constexpr Over() : tag(), value() {}
constexpr Over(S s, uint32_t v) : tag(ifc::to_underlying(s)), value(v) {}
constexpr Over(S s, std::uint32_t v) : tag(ifc::to_underlying(s)), value(v) {}

constexpr S sort() const
{
Expand Down
22 changes: 11 additions & 11 deletions include/ifc/operators.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace ifc {
// The many sort of operators.
// Note: Valid values of this type must fit in 4 bits. See Operator class below.
enum class OperatorSort : uint8_t {
enum class OperatorSort : std::uint8_t {
Niladic, // no argument
Monadic, // one argument
Dyadic, // two arguments
Expand All @@ -30,7 +30,7 @@ namespace ifc {

// The set of operators taking exactly no argument.
// Note: Valid values of this type must fit in 12 bits. See Operator class below.
enum class NiladicOperator : uint16_t {
enum class NiladicOperator : std::uint16_t {
Unknown, // also serves as a placeholder for undefined
Phantom, // no expression -- not the same as Nil, which has type void
Constant, // scalar or string literal constants, constants of class types
Expand All @@ -46,7 +46,7 @@ namespace ifc {
// The set of operators taking exactly one argument.
// Note: Valid values of this type must fit in 12 bits. See Operator class below.
// clang-format off
enum class MonadicOperator : uint16_t {
enum class MonadicOperator : std::uint16_t {
Unknown,
Plus, // +x -- unethical on non-literals, operator at source level
Negate, // -x
Expand Down Expand Up @@ -153,7 +153,7 @@ namespace ifc {
// The set of operators taking exactly two arguments.
// Note: Valid values of this type must fit in 12 bits. See Operator class below.
// clang-format off
enum class DyadicOperator : uint16_t {
enum class DyadicOperator : std::uint16_t {
Unknown,
Plus, // x + y
Minus, // x - y
Expand Down Expand Up @@ -253,7 +253,7 @@ namespace ifc {
// The set of operators taking exactly three arguments.
// Note: Valid values of this type must fit in 12 bits. See Operator class below.
// clang-format off
enum class TriadicOperator : uint16_t {
enum class TriadicOperator : std::uint16_t {
Unknown,
Choice, // x ? : y: z
ConstructAt, // new(p) T(x)
Expand All @@ -271,7 +271,7 @@ namespace ifc {

// The set of operators for dynamic storage manipulation, not classified by arity.
// Note: Valid values of this type must fit in 12 bits. See Operator class below.
enum class StorageOperator : uint16_t {
enum class StorageOperator : std::uint16_t {
Unknown,
AllocateSingle, // operator new
AllocateArray, // operator new[]
Expand All @@ -285,7 +285,7 @@ namespace ifc {

// The set of operators taking any number of arguments.
// Note: Valid values of this type must fit in 12 bits. See Operator class below.
enum class VariadicOperator : uint16_t {
enum class VariadicOperator : std::uint16_t {
Unknown,
Collection, // x, y, z -- collection of expressions, not the comma expression; no order of evaluation
Sequence, // Like Collection, but with a left-to-right sequencing order of evaluation
Expand Down Expand Up @@ -351,7 +351,7 @@ namespace ifc {

// Universal representation of arity-graded operators
struct Operator {
enum class Index : uint16_t {};
enum class Index : std::uint16_t {};
constexpr Operator() : tag{}, value{} {}
template<OperatorCategory Category>
constexpr Operator(Category c) : tag(ifc::to_underlying(operator_sort(c))), value(ifc::to_underlying(c))
Expand All @@ -368,11 +368,11 @@ namespace ifc {
auto operator<=>(const Operator&) const = default;

private:
uint16_t tag : sort_precision;
uint16_t value : index_precision;
std::uint16_t tag : sort_precision;
std::uint16_t value : index_precision;
};

static_assert(sizeof(Operator) == sizeof(uint16_t));
static_assert(sizeof(Operator) == sizeof(std::uint16_t));
} // namespace ifc

#endif // IFC_OPERATORS
2 changes: 1 addition & 1 deletion include/ifc/pp-forms.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace ifc {
// Classification of pre-syntactic forms used to group
// pp-tokens during, and out of, translation phases 1-4.
enum class FormSort : uint8_t {
enum class FormSort : std::uint8_t {
Identifier, // identifier form
Number, // number form
Character, // built-in or ud-suffixed character literal form
Expand Down
4 changes: 2 additions & 2 deletions include/ifc/reader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace ifc {
IFCASSERT(!span.empty() and &item >= &span.front() and &item <= &span.back());

auto offset = &item - &span.front();
return {E::algebra_sort, static_cast<uint32_t>(offset)};
return {E::algebra_sort, static_cast<std::uint32_t>(offset)};
}

template<typename F>
Expand Down Expand Up @@ -369,7 +369,7 @@ namespace ifc {

// Outside of class due to GCC bug.
template <>
inline const int64_t& Reader::get<int64_t, LitIndex>(LitIndex index) const
inline const std::int64_t& Reader::get<int64_t, LitIndex>(LitIndex index) const
{
IFCASSERT(LiteralSort::Integer == index.sort());
return view_entry_at<int64_t>(toc.u64s.tell(index.index()));
Expand Down
22 changes: 11 additions & 11 deletions include/ifc/source-word.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace ifc {

// The many sorts of words that make up a sentence
enum class WordSort : uint8_t {
enum class WordSort : std::uint8_t {
Unknown, // Unclassified word.
Directive, // Implementation-defined control-line surviving Phase 4 of translation.
Punctuator, // punctuators as defined by ISO C++, along with C1xx internal markers
Expand All @@ -27,7 +27,7 @@ namespace ifc {
// shielded from the token-du-jour update vagaries. These temporary measures will be
// removed as c1xx gains more a principled internal representation.
namespace source {
enum class Directive : uint16_t {
enum class Directive : std::uint16_t {
Unknown = 0x0000,

Msvc = 0x1FFF,
Expand Down Expand Up @@ -90,7 +90,7 @@ namespace ifc {
MsvcPragmaP0line,
};

enum class Punctuator : uint16_t {
enum class Punctuator : std::uint16_t {
Unknown = 0x0000,
LeftParenthesis, // "("
RightParenthesis, // ")"
Expand All @@ -114,7 +114,7 @@ namespace ifc {
MsvcDefaultInitStart,
};

enum class Literal : uint16_t {
enum class Literal : std::uint16_t {
Unknown = 0x0000,
Scalar, // characters, integers, floating points, pointers
String, // string literals
Expand All @@ -131,7 +131,7 @@ namespace ifc {
MsvcTemplateId, // A reference to a known template template specialization.
};

enum class Operator : uint16_t {
enum class Operator : std::uint16_t {
Unknown = 0x0000,
Equal, // "="
Comma, // ","
Expand Down Expand Up @@ -177,7 +177,7 @@ namespace ifc {
Msvc = 0x1FFF,
};

enum class Keyword : uint16_t {
enum class Keyword : std::uint16_t {
Unknown = 0x0000,
Alignas, // "alignas"
Alignof, // "alignof"
Expand Down Expand Up @@ -370,7 +370,7 @@ namespace ifc {
MsvcConfusedAlignas, // Confusion in the token gatherer about "alignas"
};

enum class Identifier : uint16_t {
enum class Identifier : std::uint16_t {
Plain = 0x0000,

Msvc = 0x1FFF,
Expand All @@ -397,7 +397,7 @@ namespace ifc {

// Stores preprocessing operators and punctuators, before any semantic conversion is done.
struct PPOperator {
enum class Index : uint16_t {};
enum class Index : std::uint16_t {};
PPOperator() : tag{}, value{} {}
template<PPOperatorCategory Category>
PPOperator(Category c) : tag(ifc::to_underlying(pp_operator_sort(c))), value(ifc::to_underlying(c))
Expand All @@ -412,13 +412,13 @@ namespace ifc {
}

private:
uint16_t tag : 3;
uint16_t value : 13; // MSVC starts at 0x1FFF, so all values prior fit into 13 bits.
std::uint16_t tag : 3;
std::uint16_t value : 13; // MSVC starts at 0x1FFF, so all values prior fit into 13 bits.
static_assert(ifc::bit_length(ifc::to_underlying(WordSort::Count)) == 3);
static_assert(ifc::bit_length(ifc::to_underlying(source::Operator::Msvc)) == 13);
static_assert(ifc::bit_length(ifc::to_underlying(source::Punctuator::Msvc)) == 13);
};
static_assert(sizeof(PPOperator) == sizeof(uint16_t));
static_assert(sizeof(PPOperator) == sizeof(std::uint16_t));
} // namespace ifc

#endif
2 changes: 1 addition & 1 deletion src/ifc-printer/printer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <ostream>

namespace ifc::util {
enum class PrintOptions : int8_t {
enum class PrintOptions : std::int8_t {
None = 0,
Use_color = 1 << 0,
Top_level_index = 1 << 1,
Expand Down
Loading