From c19859ba229814d5422dce416f1c6b457de6cb18 Mon Sep 17 00:00:00 2001 From: David Hunter Date: Tue, 23 Sep 2025 16:51:06 -0600 Subject: [PATCH 1/4] Add std:: qualification to types from the standard library that were assumed to be in the global namespace. These are all integral types like std::uint8_t --- include/ifc/abstract-sgraph.hxx | 178 ++++++++++++++++---------------- include/ifc/basic-types.hxx | 4 +- include/ifc/dom/node.hxx | 6 +- include/ifc/file.hxx | 26 ++--- include/ifc/index-utils.hxx | 12 +-- include/ifc/operators.hxx | 22 ++-- include/ifc/pp-forms.hxx | 2 +- include/ifc/reader.hxx | 4 +- include/ifc/source-word.hxx | 22 ++-- 9 files changed, 138 insertions(+), 138 deletions(-) diff --git a/include/ifc/abstract-sgraph.hxx b/include/ifc/abstract-sgraph.hxx index f2ebf94..64d7ea6 100644 --- a/include/ifc/abstract-sgraph.hxx +++ b/include/ifc/abstract-sgraph.hxx @@ -39,19 +39,19 @@ namespace ifc { constexpr auto count = std::underlying_type_t(S::Count); // Source line info index into the global line table. - enum class LineIndex : uint32_t {}; + enum class LineIndex : std::uint32_t {}; // Index into a word stream. - enum class WordIndex : uint32_t {}; + enum class WordIndex : std::uint32_t {}; // Index into the token stream table. - enum class SentenceIndex : uint32_t {}; + enum class SentenceIndex : std::uint32_t {}; // Index into the specialization form table. - enum class SpecFormIndex : uint32_t {}; + enum class SpecFormIndex : std::uint32_t {}; // The variety of string literals - enum class StringSort : uint8_t { + enum class StringSort : std::uint8_t { Ordinary, // Ordinary string literal -- no prefix. UTF8, // UTF-8 narrow string literal -- only u8 prefix. UTF16, // A char16_t string literal -- only u prefix. @@ -66,7 +66,7 @@ namespace ifc { }; // The sort of module ownership or entities. - enum class Ownership : uint8_t { + enum class Ownership : std::uint8_t { Unknown, // No particular information is known. Imported, // The reference is to an imported module. Exported, // The reference is to an exported module. @@ -75,7 +75,7 @@ namespace ifc { // Set of declarative properties reachable from any program points // outside from a module boundaries. - enum class ReachableProperties : uint8_t { + enum class ReachableProperties : std::uint8_t { Nothing = 0, // nothing beyond name, type, scope. Initializer = 1 << 0, // IPR-initializer exported. DefaultArguments = 1 << 1, // function or template default arguments exported @@ -84,7 +84,7 @@ namespace ifc { }; // Standard C++ access specifiers. - enum class Access : uint8_t { + enum class Access : std::uint8_t { None, // No access specified. Private, // "private" Protected, // "protected" @@ -93,7 +93,7 @@ namespace ifc { }; // Common declaration specifiers. By default, we assume the language linkage to C++. - enum class BasicSpecifiers : uint8_t { + enum class BasicSpecifiers : std::uint8_t { Cxx = 0, // C++ language linkage C = 1 << 0, // C language linkage Internal = 1 << 1, // Exported entities should have external linkage, not sure we need this. @@ -108,7 +108,7 @@ namespace ifc { // The various calling conventions currently supported by VC. // FIXME: See bug https://github.com/microsoft/ifc-spec/issues/115 - enum class CallingConvention : uint8_t { + enum class CallingConvention : std::uint8_t { Cdecl, // "__cdecl" Fast, // "__fastcall" Std, // "__stdcall" @@ -120,7 +120,7 @@ namespace ifc { }; // Modifiers of (member) function types. - enum class FunctionTypeTraits : uint8_t { + enum class FunctionTypeTraits : std::uint8_t { None = 0x00, // Just a regular function parameter type list Const = 0x01, // 'void (int) const' Volatile = 0x02, // 'void (int) volatile' @@ -130,7 +130,7 @@ namespace ifc { // General description of exception-specification. // FIXME: See https://github.com/microsoft/ifc-spec/issues/116 - enum class ExceptionSpecification : uint8_t { + enum class ExceptionSpecification : std::uint8_t { None, // None specified, not the same as no-exception NonNoexcept, // "noexcept(false)" specification Noexcept, // "noexcept" or "noexcept(true)" specification. @@ -142,7 +142,7 @@ namespace ifc { // Noexcept semantics resolution. // FIXME: See https://github.com/microsoft/ifc-spec/issues/116 - enum class NoexceptSort : uint8_t { + enum class NoexceptSort : std::uint8_t { None, // No specifier False, // "noexcept(false)" specifier. True, // "noexcept(true)" specifier. @@ -156,7 +156,7 @@ namespace ifc { }; // Semantics traits of scope types (classes, namespaces, etc). - enum class ScopeTraits : uint8_t { + enum class ScopeTraits : std::uint8_t { None = 0, Unnamed = 1 << 0, // unnamed namespace, or unnamed class types. Inline = 1 << 1, // inline namespace. @@ -168,7 +168,7 @@ namespace ifc { }; // Variable and object trait specifiers. - enum class ObjectTraits : uint8_t { + enum class ObjectTraits : std::uint8_t { None = 0, Constexpr = 1 << 0, // Constexpr object. Mutable = 1 << 1, // Mutable object. @@ -182,10 +182,10 @@ namespace ifc { }; // Type for #pragma pack values. - enum class PackSize : uint16_t {}; + enum class PackSize : std::uint16_t {}; // Semantic traits of functions. - enum class FunctionTraits : uint16_t { + enum class FunctionTraits : std::uint16_t { None = 0, Inline = 1 << 0, // inline function Constexpr = 1 << 1, // constexpr function @@ -208,14 +208,14 @@ namespace ifc { }; // Semantic traits of deduction guides. - enum class GuideTraits : uint8_t { + enum class GuideTraits : std::uint8_t { None = 0, // nothing Explicit = 1 << 0, // the deduction guide is declared 'explicit'. }; // MSVC-specific declspec attributes. // FIXME: Sequester in an MSVC-specific file, and represent as a form of standard attributes. - enum class VendorTraits : uint32_t { + enum class VendorTraits : std::uint32_t { None = 0, ForceInline = 1 << 0, // __forceinline function Naked = 1 << 1, // __declspec(naked) @@ -256,13 +256,13 @@ namespace ifc { }; // FIXME: Move to an MSVC-specific file. Attributes of segments. - enum class SegmentTraits : uint32_t {}; + enum class SegmentTraits : std::uint32_t {}; // FIXME: Move to an MSVC-specific file. - enum class SegmentType : uint8_t {}; + enum class SegmentType : std::uint8_t {}; // Account for all kinds of valid C++ names. - enum class NameSort : uint8_t { + enum class NameSort : std::uint8_t { Identifier, // Normal alphabetic identifiers. Operator, // Operator names. Conversion, // Conversion function name. @@ -280,7 +280,7 @@ namespace ifc { }; // Sort of template parameter set (also called chart.) - enum class ChartSort : uint8_t { + enum class ChartSort : std::uint8_t { None, // No template parameters; e.g. explicit specialization. Unilevel, // Unidimensional set of template parameters; e.g. templates that are not members of templates. Multilevel, // Multidimensional set of template parameters; e.g. member templates of templates. @@ -293,7 +293,7 @@ namespace ifc { }; // Sorts of declarations that can be exported, or part of exportable entities. - enum class DeclSort : uint8_t { + enum class DeclSort : std::uint8_t { VendorExtension, // A vendor-specific extension. Enumerator, // An enumerator declaration. Variable, // A variable declaration; a static-data member is also considered a variable. @@ -337,7 +337,7 @@ namespace ifc { }; // Sorts of types. - enum class TypeSort : uint8_t { + enum class TypeSort : std::uint8_t { VendorExtension, // Vendor-specific type constructor extensions. Fundamental, // Fundamental type, in standard C++ sense Designated, // A type designated by a declared name. Really a proxy type designator. @@ -372,7 +372,7 @@ namespace ifc { // The set of exported syntactic elements // FIXME: See bug https://github.com/microsoft/ifc-spec/issues/127 - enum class SyntaxSort : uint8_t { + enum class SyntaxSort : std::uint8_t { VendorExtension, // Vendor-specific extension for syntax. What fresh hell is this? SimpleTypeSpecifier, // A simple type-specifier (i.e. no declarator) DecltypeSpecifier, // A decltype-specifier - 'decltype(expression)' @@ -497,7 +497,7 @@ namespace ifc { }; // The various kinds of parameters. - enum class ParameterSort : uint8_t { + enum class ParameterSort : std::uint8_t { Object, // Function parameter Type, // Type template parameter NonType, // Non-type template parameter @@ -506,7 +506,7 @@ namespace ifc { }; // The various sort of literal constants. - enum class LiteralSort : uint8_t { + enum class LiteralSort : std::uint8_t { Immediate, // Immediate integer constants, directly representable by an index value. Integer, // Unsigned 64-bit integer constant that are not immediate values. FloatingPoint, // Floating point constant. @@ -519,7 +519,7 @@ namespace ifc { }; // Sorts of statements. - enum class StmtSort : uint8_t { + enum class StmtSort : std::uint8_t { VendorExtension, // Vendor-specific extensions Try, // A try-block containing a list of handlers If, // If statements @@ -552,7 +552,7 @@ namespace ifc { }; // Sorts of expressions. - enum class ExprSort : uint8_t { + enum class ExprSort : std::uint8_t { VendorExtension, // Vendor-specific extension for expressions. Empty, // An empty expression. Literal, // Literal constants. @@ -635,7 +635,7 @@ namespace ifc { using Over::Over; }; - enum class InheritanceSort : uint8_t { + enum class InheritanceSort : std::uint8_t { None, Single, Multiple, @@ -643,7 +643,7 @@ namespace ifc { }; // Type qualifiers. - enum class Qualifier : uint8_t { + enum class Qualifier : std::uint8_t { None = 0, // No qualifier Const = 1 << 0, // "const" qualifier Volatile = 1 << 1, // "volatile" qualifier @@ -651,9 +651,9 @@ namespace ifc { }; // Type of abstract references to words (generalized tokens). - enum class WordCategory : uint16_t {}; + enum class WordCategory : std::uint16_t {}; - enum class MacroSort : uint8_t { + enum class MacroSort : std::uint8_t { ObjectLike, // #define NAME FunctionLike, // #define F(A, B) Count @@ -664,7 +664,7 @@ namespace ifc { using Over::Over; }; - enum class PragmaSort : uint8_t { + enum class PragmaSort : std::uint8_t { VendorExtension, Expr, // Pragma with a description and expression representing compiler information, e.g. #pragma message "literal" Count, @@ -678,7 +678,7 @@ namespace ifc { static_assert(index_like::tag_precision == 1); static_assert(index_like::index_precision == 31); - enum class AttrSort : uint8_t { + enum class AttrSort : std::uint8_t { Nothing, // no attribute - [[ ]] Basic, // any token - [[ foo ]] Scoped, // scoped attribute - [[foo :: bar]] @@ -696,7 +696,7 @@ namespace ifc { using Over::Over; }; - enum class DirSort : uint8_t { + enum class DirSort : std::uint8_t { VendorExtension, // Vendor-specific extension for directives. Empty, // An empty declaration - ; Attribute, // Attribute declaration - [[nodiscard]]. @@ -739,7 +739,7 @@ namespace ifc { }; // Symbolic name of the various heaps stored in an IFC. - enum class HeapSort : uint8_t { + enum class HeapSort : std::uint8_t { Decl, // DeclIndex heap Type, // TypeIndex heap Stmt, // StmtIndex heap @@ -756,7 +756,7 @@ namespace ifc { }; // Vendor-specific syntax (or future additions to the IFC specification). - enum class VendorSort : uint8_t { + enum class VendorSort : std::uint8_t { SEHTry, // A structured exception handling try block. SEHFinally, // A structured exception handling finally block. SEHExcept, // A structured exception handling except block. @@ -907,7 +907,7 @@ namespace ifc { }; // The set of fundamental type basis. - enum class TypeBasis : uint8_t { + enum class TypeBasis : std::uint8_t { Void, // "void" Bool, // "bool" Char, // "char" @@ -935,7 +935,7 @@ namespace ifc { Count // cardinality of fundamental type basis. }; - enum class TypePrecision : uint8_t { + enum class TypePrecision : std::uint8_t { Default, // Default bit width, whatever that is. Short, // The short version. Long, // The long version. @@ -948,7 +948,7 @@ namespace ifc { }; // Signed-ness of a fundamental type. - enum class TypeSign : uint8_t { + enum class TypeSign : std::uint8_t { Plain, // No sign specified, default to standard interpretation. Signed, // Specified sign, or implied Unsigned, // Specified sign. @@ -962,11 +962,11 @@ namespace ifc { TypeBasis basis{}; TypePrecision precision{}; TypeSign sign{}; - uint8_t unused{}; + std::uint8_t unused{}; }; // Template parameter pack and template-id expansion mode. - enum class ExpansionMode : uint8_t { + enum class ExpansionMode : std::uint8_t { Full, Partial, }; @@ -1092,7 +1092,7 @@ namespace ifc { ExprIndex path{}; }; - enum class BaseClassTraits : uint8_t { + enum class BaseClassTraits : std::uint8_t { None = 0x00, // Nothing Shared = 0x01, // Base class inherited virtually Expanded = 0x02, // Base class pack expanded @@ -1145,7 +1145,7 @@ namespace ifc { }; struct Keyword { - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { None, Class, Struct, @@ -1165,7 +1165,7 @@ namespace ifc { Kind kind = Kind::None; // What kind of keyword do we have? }; - enum class StorageClass : uint32_t { + enum class StorageClass : std::uint32_t { None = 0, Auto = 1 << 0, // 'auto' (use as a storage-class requires '/Zc:auto-') Constexpr = 1 << 1, // 'constexpr' @@ -1275,7 +1275,7 @@ namespace ifc { }; struct PointerDeclarator : Tag { - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { None, Pointer, // T* LvalueReference, // T& @@ -1418,7 +1418,7 @@ namespace ifc { }; struct StructuredBindingDeclaration : Tag { - enum class RefQualifierKind : uint8_t { + enum class RefQualifierKind : std::uint8_t { None, Rvalue, Lvalue, @@ -1444,7 +1444,7 @@ namespace ifc { }; struct ReturnStatement : Tag { - enum class ReturnKind : uint8_t { + enum class ReturnKind : std::uint8_t { Return, Co_return, }; @@ -1535,7 +1535,7 @@ namespace ifc { }; struct LabeledStatement : Tag { - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { None, Case, Default, @@ -1791,7 +1791,7 @@ namespace ifc { }; struct LambdaDeclaratorSpecifier { - enum class SpecifierSort : uint8_t { + enum class SpecifierSort : std::uint8_t { None = 0, Mutable = 1 << 0, Constexpr = 1 << 1, @@ -1888,7 +1888,7 @@ namespace ifc { SourceLocation locus{}; // The source location of the '__super' keyword }; - enum class FoldKind : uint32_t { // FIXME: this should be uint8_t + enum class FoldKind : std::uint32_t { // FIXME: this should be std::uint8_t Unknown, LeftFold, // Some form of left fold expression RightFold, // Some form of right fold expression @@ -2003,7 +2003,7 @@ namespace ifc { static_assert(sizeof(TypeOrExprOperand) == sizeof(Index)); // the types of msvc-specific C++ syntax - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { Unknown, Declspec, // __declspec( expression ) BuiltinAddressOf, // __builtin_addressof( expression ) @@ -2037,12 +2037,12 @@ namespace ifc { ExprIndex argument; // expression }; struct IfExists { - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { Statement, Initializer, MemberDeclaration, }; - enum class Keyword : uint8_t { + enum class Keyword : std::uint8_t { IfExists, IfNotExists, }; @@ -2146,7 +2146,7 @@ namespace ifc { }; // A strongly-typed abstraction of ExprIndex which always points to ExprSort::NamedDecl. - enum class DefaultIndex : uint32_t { + enum class DefaultIndex : std::uint32_t { UnderlyingSort = ifc::to_underlying(ExprSort::NamedDecl), }; @@ -2174,8 +2174,8 @@ namespace ifc { TypeIndex type{}; // Sort and index of this decl's type. Null means no type. ExprIndex type_constraint{}; // Optional type-constraint on the parameter type. DefaultIndex initializer{}; // Default argument. Null means none was provided. - uint32_t level{}; // The nesting depth of this parameter (template or function). - uint32_t position{}; // The 1-based position of this parameter. + std::uint32_t level{}; // The nesting depth of this parameter (template or function). + std::uint32_t position{}; // The 1-based position of this parameter. ParameterSort sort{}; // The kind of parameter. ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; @@ -2307,7 +2307,7 @@ namespace ifc { ReachableProperties properties{}; // The set of semantic properties reaching to outside importers. }; - enum class SpecializationSort : uint8_t { + enum class SpecializationSort : std::uint8_t { Implicit, // An implicit specialization Explicit, // An explicit specialization (user provided) Instantiation, // An explicit instantiation (user provided) @@ -2595,7 +2595,7 @@ namespace ifc { }; // Expression trees for integer constants below this threshold are directly represented by their indices. - inline constexpr auto immediate_upper_bound = uint64_t(1) << index_like::index_precision; + inline constexpr auto immediate_upper_bound = std::uint64_t(1) << index_like::index_precision; struct StringLiteral { TextOffset start{}; // beginning of the first byte in this string literal @@ -2659,7 +2659,7 @@ namespace ifc { // Read from a symbolic address. When the address is an id-expression, the read expression // symbolizes an lvalue-to-rvalue conversion. struct ReadExpr : LocationAndType { - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { Unknown, // Unknown Indirection, // Dereference a pointer, e.g. *p RemoveReference, // Convert a reference into an lvalue @@ -2707,7 +2707,7 @@ namespace ifc { }; struct DestructorCallExpr : LocationAndType { - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { Unknown, Destructor, Finalizer, @@ -2737,7 +2737,7 @@ namespace ifc { }; struct TemporaryExpr : LocationAndType { - uint32_t index{}; // The index that uniquely identifiers this temporary object + std::uint32_t index{}; // The index that uniquely identifiers this temporary object }; struct DynamicDispatchExpr : LocationAndType { @@ -2753,7 +2753,7 @@ namespace ifc { SyntaxIndex body{}; // The requirement body }; - enum class Associativity : uint8_t { + enum class Associativity : std::uint8_t { Unspecified, Left, Right, @@ -2802,7 +2802,7 @@ namespace ifc { }; struct InitializerExpr : LocationAndType { - enum class Kind : uint8_t { + enum class Kind : std::uint8_t { Unknown, DirectInitialization, CopyInitialization, @@ -2850,7 +2850,7 @@ namespace ifc { // FIXME: Remove at earliest convenience. struct ExpressionListExpr : Tag { - enum class Delimiter : uint8_t { + enum class Delimiter : std::uint8_t { None, // No delimiter Brace, // Brace delimiters Parenthesis, // Parenthesis delimiters @@ -2913,7 +2913,7 @@ namespace ifc { ExprIndex base_class_values{}; // The values (zero or more) of base class members }; - enum class ActiveMemberIndex : uint32_t {}; + enum class ActiveMemberIndex : std::uint32_t {}; struct SumTypeValueExpr : LocationAndType { TypeIndex variant{}; // The union type which this value is associated @@ -2937,8 +2937,8 @@ namespace ifc { TextOffset name{}; // macro name FormIndex parameters{}; // The parameters of the macro. FormIndex replacement_list{}; // The replacement list of the macro. - uint32_t arity : 31 {}; // Arity for function-like macros. - uint32_t variadic : 1 {}; // True if this macro is variadic. + std::uint32_t arity : 31 {}; // Arity for function-like macros. + std::uint32_t variadic : 1 {}; // True if this macro is variadic. }; // Note: this class is not meant to be used to create objects -- it is just a traits class. @@ -2950,12 +2950,12 @@ namespace ifc { // FIXME: investigate if disabling C4624 is really necessary here #pragma warning(push) #pragma warning(disable : 4624) - struct IntegerLiteral : constant_traits {}; + struct IntegerLiteral : constant_traits {}; #pragma pack(push, 4) struct LiteralReal { double value{}; - uint16_t size{}; + std::uint16_t size{}; }; #pragma pack(pop) @@ -2969,15 +2969,15 @@ namespace ifc { DeclIndex const_segment; // Symbol for #pragma const_seg DeclIndex data_segment; // Symbol for #pragma data_seg DeclIndex bss_segment; // Symbol for #pragma data_seg - uint32_t pack_size : 8; // value of #pragma pack - uint32_t fp_control : 8; // value of #pragma float_control - uint32_t exec_charset : 8; // value of #pragma execution_character_set - uint32_t vtor_disp : 8; // value of #pragma vtordisp - uint32_t std_for_scope : 1; // value of #pragma conform(forScope) - uint32_t unused : 1; // unused bit - was previously pure_cil, which was meant to be the captured + std::uint32_t pack_size : 8; // value of #pragma pack + std::uint32_t fp_control : 8; // value of #pragma float_control + std::uint32_t exec_charset : 8; // value of #pragma execution_character_set + std::uint32_t vtor_disp : 8; // value of #pragma vtordisp + std::uint32_t std_for_scope : 1; // value of #pragma conform(forScope) + std::uint32_t unused : 1; // unused bit - was previously pure_cil, which was meant to be the captured // state of #pragma managed(off/on). This is not actually required as we // don't support module export for /clr, and it's always the case for native code. - uint32_t strict_gs_check : 1; // value of #pragma strict_gs_check + std::uint32_t strict_gs_check : 1; // value of #pragma strict_gs_check }; struct BasicAttr : Tag { @@ -3016,7 +3016,7 @@ namespace ifc { struct TupleAttr : Tag, Sequence {}; namespace microsoft { - enum class PragmaCommentSort : uint8_t { + enum class PragmaCommentSort : std::uint8_t { Unknown, Compiler, Lib, @@ -3038,7 +3038,7 @@ namespace ifc { ExprIndex operand{}; // The operand of the #pragma expression }; - enum class Phases : uint32_t { + enum class Phases : std::uint32_t { Unknown = 0, Reading = 1 << 0, Lexing = 1 << 1, @@ -3180,7 +3180,7 @@ namespace ifc { }; } // namespace symbolic::preprocessing - enum class TraitSort : uint8_t { + enum class TraitSort : std::uint8_t { MappingExpr, // function definition associated with a declaration AliasTemplate, // extra information required for alias templates Friends, // sequence of friends @@ -3192,7 +3192,7 @@ namespace ifc { Count, }; - enum class MsvcTraitSort : uint8_t { + enum class MsvcTraitSort : std::uint8_t { Uuid, // uuid associated with a declaration Segment, // segment associated with a declaration SpecializationEncoding, // template specialization encoding associated with a specialization @@ -3304,7 +3304,7 @@ namespace ifc { LineNumber last; // The last line in the file (inclusive). }; - enum class MsvcFileHashSort : uint8_t + enum class MsvcFileHashSort : std::uint8_t { None, MD5, @@ -3315,18 +3315,18 @@ namespace ifc { struct alignas(partition_alignment) MsvcFileHashData { static constexpr auto msvc_file_hash_size = 32; - std::array bytes{}; + std::array bytes{}; MsvcFileHashSort sort = MsvcFileHashSort::None; - std::array unused; + std::array unused; }; static_assert(sizeof(MsvcFileHashData) == 36); // The MSVC warning number. - enum class MsvcWarningNumber : uint16_t {}; + enum class MsvcWarningNumber : std::uint16_t {}; // The state of the warning associated with this pragma. - enum class MsvcWarningState : uint8_t {}; + enum class MsvcWarningState : std::uint8_t {}; struct MsvcPragmaWarningRegion { SourceLocation start_locus{}; @@ -3337,7 +3337,7 @@ namespace ifc { static_assert(sizeof(MsvcPragmaWarningRegion) == 20); - enum class MsvcDebugRecordIndex : uint32_t {}; + enum class MsvcDebugRecordIndex : std::uint32_t {}; struct MsvcGMFSpecializedTemplate { DeclIndex template_decl{}; // The template declaration. diff --git a/include/ifc/basic-types.hxx b/include/ifc/basic-types.hxx index 7a5e68b..4053072 100644 --- a/include/ifc/basic-types.hxx +++ b/include/ifc/basic-types.hxx @@ -7,10 +7,10 @@ #include 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, }; diff --git a/include/ifc/dom/node.hxx b/include/ifc/dom/node.hxx index e443e21..8aa52e0 100644 --- a/include/ifc/dom/node.hxx +++ b/include/ifc/dom/node.hxx @@ -31,7 +31,7 @@ #include namespace ifc::util { - enum class SortKind : uint16_t { + enum class SortKind : std::uint16_t { Expr, Decl, Type, @@ -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 diff --git a/include/ifc/file.hxx b/include/ifc/file.hxx index e88d9be..ae7fb16 100644 --- a/include/ifc/file.hxx +++ b/include/ifc/file.hxx @@ -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 @@ -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) { @@ -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) { @@ -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 @@ -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 value; + std::array 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. @@ -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)) @@ -242,7 +242,7 @@ namespace ifc { auto size = static_cast(byte_count); SHA256Hash hash{}; - uint8_t* alias = reinterpret_cast(hash.value.data()); + std::uint8_t* alias = reinterpret_cast(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); diff --git a/include/ifc/index-utils.hxx b/include/ifc/index-utils.hxx index 557878b..e260320 100644 --- a/include/ifc/index-utils.hxx +++ b/include/ifc/index-utils.hxx @@ -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 inline constexpr auto sentinel_for = std::numeric_limits>::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 @@ -30,10 +30,10 @@ namespace index_like { concept U32Enum = ifc::Enum and Uint32>; template - inline constexpr uint32_t wilderness = sentinel_for; + inline constexpr std::uint32_t wilderness = sentinel_for; // 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. @@ -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 { diff --git a/include/ifc/operators.hxx b/include/ifc/operators.hxx index a0be473..36e3411 100644 --- a/include/ifc/operators.hxx +++ b/include/ifc/operators.hxx @@ -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 @@ -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 @@ -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 @@ -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 @@ -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) @@ -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[] @@ -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 @@ -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 constexpr Operator(Category c) : tag(ifc::to_underlying(operator_sort(c))), value(ifc::to_underlying(c)) @@ -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 diff --git a/include/ifc/pp-forms.hxx b/include/ifc/pp-forms.hxx index ac28497..12158a5 100644 --- a/include/ifc/pp-forms.hxx +++ b/include/ifc/pp-forms.hxx @@ -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 diff --git a/include/ifc/reader.hxx b/include/ifc/reader.hxx index bc48603..f2c31a1 100644 --- a/include/ifc/reader.hxx +++ b/include/ifc/reader.hxx @@ -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(offset)}; + return {E::algebra_sort, static_cast(offset)}; } template @@ -369,7 +369,7 @@ namespace ifc { // Outside of class due to GCC bug. template <> - inline const int64_t& Reader::get(LitIndex index) const + inline const std::int64_t& Reader::get(LitIndex index) const { IFCASSERT(LiteralSort::Integer == index.sort()); return view_entry_at(toc.u64s.tell(index.index())); diff --git a/include/ifc/source-word.hxx b/include/ifc/source-word.hxx index 23c747a..8ac6a1a 100644 --- a/include/ifc/source-word.hxx +++ b/include/ifc/source-word.hxx @@ -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 @@ -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, @@ -90,7 +90,7 @@ namespace ifc { MsvcPragmaP0line, }; - enum class Punctuator : uint16_t { + enum class Punctuator : std::uint16_t { Unknown = 0x0000, LeftParenthesis, // "(" RightParenthesis, // ")" @@ -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 @@ -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, // "," @@ -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" @@ -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, @@ -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 PPOperator(Category c) : tag(ifc::to_underlying(pp_operator_sort(c))), value(ifc::to_underlying(c)) @@ -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 From 0e3896eb7951a0f08d2ffecf880bdedf88d93442 Mon Sep 17 00:00:00 2001 From: David Hunter Date: Thu, 25 Sep 2025 16:40:24 -0600 Subject: [PATCH 2/4] One missing addition of std:: --- src/ifc-printer/printer.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ifc-printer/printer.hxx b/src/ifc-printer/printer.hxx index aa4ce2f..4c5806a 100644 --- a/src/ifc-printer/printer.hxx +++ b/src/ifc-printer/printer.hxx @@ -8,7 +8,7 @@ #include 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, From e0483ef1d5c29b99b4c76a6161cd9ee4260b0dbf Mon Sep 17 00:00:00 2001 From: David Hunter Date: Sun, 5 Oct 2025 07:52:07 -0600 Subject: [PATCH 3/4] Fix up the GCC stuff, also test on clang on Ubuntu --- include/ifc/basic-types.hxx | 2 ++ include/ifc/file.hxx | 3 +-- include/ifc/reader.hxx | 4 ++-- src/file.cxx | 8 ++++---- src/ifc-dom/literals.cxx | 2 +- src/input-file.cxx | 1 + src/tools/ifc.cxx | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/ifc/basic-types.hxx b/include/ifc/basic-types.hxx index 4053072..9d3d378 100644 --- a/include/ifc/basic-types.hxx +++ b/include/ifc/basic-types.hxx @@ -6,6 +6,8 @@ #include +#include + namespace ifc { enum class ColumnNumber : std::int32_t { Invalid = -1, diff --git a/include/ifc/file.hxx b/include/ifc/file.hxx index ae7fb16..8bf4747 100644 --- a/include/ifc/file.hxx +++ b/include/ifc/file.hxx @@ -242,7 +242,7 @@ namespace ifc { auto size = static_cast(byte_count); SHA256Hash hash{}; - std::uint8_t* alias = reinterpret_cast(hash.value.data()); + std::uint8_t* alias = reinterpret_cast(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); @@ -557,5 +557,4 @@ namespace ifc { }; } // namespace ifc - #endif // IFC_FILE_INCLUDED diff --git a/include/ifc/reader.hxx b/include/ifc/reader.hxx index f2c31a1..ddfdb42 100644 --- a/include/ifc/reader.hxx +++ b/include/ifc/reader.hxx @@ -369,10 +369,10 @@ namespace ifc { // Outside of class due to GCC bug. template <> - inline const std::int64_t& Reader::get(LitIndex index) const + inline const std::int64_t& Reader::get(LitIndex index) const { IFCASSERT(LiteralSort::Integer == index.sort()); - return view_entry_at(toc.u64s.tell(index.index())); + return view_entry_at(toc.u64s.tell(index.index())); } template <> diff --git a/src/file.cxx b/src/file.cxx index b1d3015..15c1536 100644 --- a/src/file.cxx +++ b/src/file.cxx @@ -8,14 +8,14 @@ namespace ifc { { // Verify integrity of ifc. To do this we know that the header content after the hash // starts after the interface signature and the first 256 bits. - constexpr size_t hash_start = sizeof(InterfaceSignature); - constexpr size_t contents_start = hash_start + sizeof(SHA256Hash); + constexpr std::size_t hash_start = sizeof(InterfaceSignature); + constexpr std::size_t contents_start = hash_start + sizeof(SHA256Hash); static_assert(contents_start == 36); // 4 bytes for Signature + 8*4 bytes for SHA2 const auto& contents = file.contents(); auto result = hash_bytes(contents.data() + contents_start, contents.data() + contents.size()); - auto actual_first = reinterpret_cast(result.value.data()); + auto actual_first = reinterpret_cast(result.value.data()); auto actual_last = actual_first + std::size(result.value) * 4; - auto expected_first = reinterpret_cast(&contents[hash_start]); + auto expected_first = reinterpret_cast(&contents[hash_start]); auto expected_last = expected_first + sizeof(SHA256Hash); if (not std::equal(actual_first, actual_last, expected_first, expected_last)) { diff --git a/src/ifc-dom/literals.cxx b/src/ifc-dom/literals.cxx index a313cd3..ff22bbd 100644 --- a/src/ifc-dom/literals.cxx +++ b/src/ifc-dom/literals.cxx @@ -12,7 +12,7 @@ namespace ifc::util { case LiteralSort::Immediate: return std::to_string(ifc::to_underlying(index.index())); case LiteralSort::Integer: - return std ::to_string(ctx.reader.get(index)); + return std ::to_string(ctx.reader.get(index)); case LiteralSort::FloatingPoint: return std ::to_string(ctx.reader.get(index)); default: diff --git a/src/input-file.cxx b/src/input-file.cxx index 21dd958..6db7632 100644 --- a/src/input-file.cxx +++ b/src/input-file.cxx @@ -8,6 +8,7 @@ # include # include # include +# include #endif #include "ifc/tooling.hxx" diff --git a/src/tools/ifc.cxx b/src/tools/ifc.cxx index aec9996..bed3739 100644 --- a/src/tools/ifc.cxx +++ b/src/tools/ifc.cxx @@ -173,7 +173,7 @@ int IFC_MAIN(int argc, ifc::tool::NativeChar* argv[]) #ifdef WIN32 auto status = _wsystem(command.c_str()); #else - auto status = system(command.c_str()); + auto status = std::system(command.c_str()); #endif if (status != 0) IFC_ERR << STR("ifc: no subcommand named '") << cmd << STR("'") << std::endl; From f4931c4f4b3a89204f9563e638084dac53a7aa33 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Mon, 6 Oct 2025 01:05:11 -0700 Subject: [PATCH 4/4] Update basic-types.hxx Include standard header before project headers. --- include/ifc/basic-types.hxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/ifc/basic-types.hxx b/include/ifc/basic-types.hxx index 9d3d378..9b255ac 100644 --- a/include/ifc/basic-types.hxx +++ b/include/ifc/basic-types.hxx @@ -4,9 +4,8 @@ #ifndef IFC_BASIC_TYPES #define IFC_BASIC_TYPES -#include - #include +#include namespace ifc { enum class ColumnNumber : std::int32_t {