Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-extint.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-extint.cpp +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-extint.cpp @@ -1,21 +1,21 @@ // RUN: %check_clang_tidy -std=c99 %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c // RUN: %check_clang_tidy %s bugprone-implicit-widening-of-multiplication-result %t -- -- -target x86_64-unknown-unknown -x c++ -_ExtInt(64) t0(_ExtInt(32) a, _ExtInt(32) b) { +_BitInt(64) t0(_BitInt(32) a, _BitInt(32) b) { return a * b; - // CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type '_ExtInt(64)' of a multiplication performed in type '_ExtInt(32)' + // CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type '_BitInt(64)' of a multiplication performed in type '_BitInt(32)' // CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning // CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type } -unsigned _ExtInt(64) t1(_ExtInt(32) a, _ExtInt(32) b) { +unsigned _BitInt(64) t1(_BitInt(32) a, _BitInt(32) b) { return a * b; - // CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned _ExtInt(64)' of a multiplication performed in type '_ExtInt(32)' + // CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type 'unsigned _BitInt(64)' of a multiplication performed in type '_BitInt(32)' // CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning // CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type } -_ExtInt(64) t2(unsigned _ExtInt(32) a, unsigned _ExtInt(32) b) { +_BitInt(64) t2(unsigned _BitInt(32) a, unsigned _BitInt(32) b) { return a * b; - // CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type '_ExtInt(64)' of a multiplication performed in type 'unsigned _ExtInt(32)' + // CHECK-NOTES: :[[@LINE-1]]:10: warning: performing an implicit widening conversion to type '_BitInt(64)' of a multiplication performed in type 'unsigned _BitInt(32)' // CHECK-NOTES: :[[@LINE-2]]:10: note: make conversion explicit to silence this warning // CHECK-NOTES: :[[@LINE-3]]:10: note: perform multiplication in a wider type } Index: clang/docs/BitIntABI.rst =================================================================== --- /dev/null +++ clang/docs/BitIntABI.rst @@ -0,0 +1,176 @@ +=============================== +_BitInt Clang ABI Specification +=============================== + +.. contents:: + :local: + +History +======= + +* **version 1** 2021/10/11 + + * Initial document + +This document provides a generic ABI specification for the C23 ``_BitInt`` +feature, expressed in terms of concepts common to low-level platform ABIs. This +document does not directly constrain any platform, as the ABI used for +``_BitInt`` on a platform is determined by that platform's ABI specification. +It is expected that platform ABIs will codify the ABI for the ``_BitInt`` +feature on their platform using this specification, either by reference or by +copying the text of this specification into the platform ABI specification. + +Platform ABIs which include this specification by reference should explicitly +give a version and the parameters listed below. For example: "The ABI for +``_BitInt`` types is specified by version 1 of the `_BitInt Clang ABI +Specification `_, using ``64`` as +the value for ``MaxFundamentalWidth`` and ``long`` as the type for +``chunk_t``." + +High Level +========== + +_BitInt describes a family of related bit-precise integer types standardized in +C23. The original proposal is +`WG14 N2763 `_ +A ``_BitInt`` type is parameterized to specify how wide the type is (how many +bits it occupies), including the sign bit. For example, ``_BitInt(2)`` is a +signed integer with one sign bit and one value bit, while +``unsigned _BitInt(2)`` is an unsigned integer with two value bits. A +``signed _BitInt`` must be at least two bits wide, and an ``unsigned _BitInt`` +must be at least one bit wide, so a `_BitInt` must have at least one value bit. +There is an implementation-defined limit to the widest width supported, +specified by the ``BITINT_MAXWIDTH`` macro in ````. + +Unlike other integer types, bit-precise integer types do not undergo default +integer promotion, including when passed as a variadic argument. This means +that a ``_BitInt(8)`` does not promote to ``int`` when passed as an argument to +a function or returned as a value from a function. + +``_BitInt`` types are ordinary object types and may be used anywhere an object +type can be, such as a ``struct`` field, ``union`` field, or array element. In +addition, they are integer types and may be used as the type of a bit-field. +Like any other type, a ``_BitInt`` object may require more memory than its +stated bit width in order to satisfy the requirements of byte (or higher) +alignment. In other words, the width of a ``_BitInt`` affects the semantics of +operations on the value; it is not a guarantee that the value will be "packed" +into exactly that many bits in memory. + +ABI Description +=============== + +The ABI of ``_BitInt`` is expected to vary between architectures, but the +following is a general ABI outline. + +Definitions +----------- + +This generic ABI is described in terms of the following parameters, which must +be determined by the platform ABI: + +``MaxFundamentalWidth`` is the bit-width of the largest fundamental integer +type for the target that can be used to represent a ``_BitInt``. Typically, +this will be the largest integer type supported by the ABI, but a smaller limit +is also acceptable. Once this limit is chosen for an ABI, it should not be +modified later even if the ABI adds support for a larger fundamental integer +type. + +``chunk_t`` is the type of the fundamental integer type that the target will +use to store the components of a ``_BitInt`` that is wider than +``MaxFundamentalWidth``. This should be a fundamental integer type for which +the target supports overflow operations and will typically be the full width of +a general purpose register. + +These parameters are used to derive other relevant properties as described +below. + +Object Layout (excluding bit-fields) +------------------------------------ + +``ChunkWidth`` is defined as ``sizeof(chunk_t) * CHAR_BITS``. + +``RepWidth(N)`` is the *representation width* of a ``_BitInt`` of width ``N``. +If ``N <= MaxFundamentalWidth``, then ``RepWidth(N)`` is the bit-width of the +lowest-rank fundamental integer type (excluding ``_Bool``) with at least ``N`` +bits. Otherwise, ``RepWidth(N)`` is the least multiple of the bit-width of +``chunk_t`` which is at least ``N``. It is therefore always true that ``N <= +RepWidth(N)``. When ``N < RepWidth(N)``, a ``_BitInt(N)`` is represented +exactly as if it were extended to a ``_BitInt(RepWidth(N))`` of the same +signedness. The value is held in the least significant bits, and the excess +(most significant) bits have unspecified values. + +If ``RepWidth(N) <= MaxFundamentalWidth``, then ``signed _BitInt(N)`` and +``unsigned _BitInt(N)`` have the same representation width as the smallest +fundamental integer type of at least ``RepWidth(N)`` bits with the same sign, +excluding ``_Bool``. + +Otherwise, ``signed _BitInt(N)`` and ``unsigned _BitInt(N)`` have the same +representation width as a ``struct`` containing a single member of type +``chunk_t[RepWidth(N) / sizeof(chunk_t)]``. The element at index ``Idx`` stores +bits ``Idx * ChunkWidth`` through ``(Idx + 1) * ChunkWidth``. That is, the +array is always stored in little-endian order, which should have better memory- +access properties regardless of the target endianness. Individual elements of +this array will still have natural host endianness. + +Bit-Field Layout +---------------- + +When a ``_BitInt(N)`` is used as the type of a bit-field, the width of the +allocation unit is ``RepWidth(N)``. e.g., ``_BitInt(9) i : 8;`` occupies a two- +byte allocation unit, not a one-byte allocation unit. The unused bits from the +``_BitInt`` should be packed together with an adjacent bit-field of a non- +``_BitInt`` type. ``_BitInt(N)`` and ``_BitInt(M)`` types should pack together +when ``N != M``. + +Passing and Returning an Object +------------------------------- + +When a ``_BitInt(N)`` is passed as an argument to a function or returned from a +function, + +* if ``RepWidth(N) <= MaxFundamentalWidth``, the object is passed to the + function or returned from the function in the same manner as an integer + object with width ``RepWidth(N)``, + +* otherwise, the object is passed to the function or returned from the function + in the same manner as a ``struct`` containing a single member of type + ``chunk_t[RepWidth(N) / sizeof(chunk_t)]``. + + +Rationale and Alternative Approaches +==================================== + +Target architectures may have different needs which are not met by the above +generic ABI specification. This section contains information about some of the +decisions in the generic ABI and alternative approaches that can be considered. + +Excess Bits +----------- + +When ``N < RepWidth(N)``, the ABI has three natural alternatives: + +* The value is kept in the least-significant bits and the excess (most + significant) bits are unspecified. + +* The value is kept in the least-significant bits and the excess (most + significant) bits are required to be a proper zero- or sign-extension of the + value (as appropriate for the signedness of the type). + +* The value is left-shifted into the most-significant bits and the excess + (least significant) bits are required to be zero. + +Each of these has tradeoffs. Leaving the most-significant bits unspecified +allows addition, subtraction, multiplication, bitwise complement, left shift, +and narrowing conversions to avoid adjusting these bits in their results. +Forcing the most-significant bits to be properly extended allows comparison, +division, right shift, and widening conversions to avoid adjusting these bits +in their operands. Keeping the value left-shifted is good for both addition and +comparison, but other operations (especially conversions) become more complex, +and the representation is less "natural", which can complicate interacting with +other systems. Furthermore, having unspecified bits means that bitwise equality +can be false even when semantic equality holds, but not having unspecified bits +means that there are trap representations which can lead to undefined behavior. + +This ABI leaves the most-significant bits unspecified out of a belief that +doing so should optimize the most common operations and avoid the most +complexity in practice. Index: clang/docs/LanguageExtensions.rst =================================================================== --- clang/docs/LanguageExtensions.rst +++ clang/docs/LanguageExtensions.rst @@ -3963,55 +3963,13 @@ Extended Integer Types ====================== -Clang supports a set of extended integer types under the syntax ``_ExtInt(N)`` -where ``N`` is an integer that specifies the number of bits that are used to represent -the type, including the sign bit. The keyword ``_ExtInt`` is a type specifier, thus -it can be used in any place a type can, including as a non-type-template-parameter, -as the type of a bitfield, and as the underlying type of an enumeration. - -An extended integer can be declared either signed, or unsigned by using the -``signed``/``unsigned`` keywords. If no sign specifier is used or if the ``signed`` -keyword is used, the extended integer type is a signed integer and can represent -negative values. - -The ``N`` expression is an integer constant expression, which specifies the number -of bits used to represent the type, following normal integer representations for -both signed and unsigned types. Both a signed and unsigned extended integer of the -same ``N`` value will have the same number of bits in its representation. Many -architectures don't have a way of representing non power-of-2 integers, so these -architectures emulate these types using larger integers. In these cases, they are -expected to follow the 'as-if' rule and do math 'as-if' they were done at the -specified number of bits. - -In order to be consistent with the C language specification, and make the extended -integer types useful for their intended purpose, extended integers follow the C -standard integer conversion ranks. An extended integer type has a greater rank than -any integer type with less precision. However, they have lower rank than any -of the built in or other integer types (such as __int128). Usual arithmetic conversions -also work the same, where the smaller ranked integer is converted to the larger. - -The one exception to the C rules for integers for these types is Integer Promotion. -Unary +, -, and ~ operators typically will promote operands to ``int``. Doing these -promotions would inflate the size of required hardware on some platforms, so extended -integer types aren't subject to the integer promotion rules in these cases. - -In languages (such as OpenCL) that define shift by-out-of-range behavior as a mask, -non-power-of-two versions of these types use an unsigned remainder operation to constrain -the value to the proper range, preventing undefined behavior. - -Extended integer types are aligned to the next greatest power-of-2 up to 64 bits. -The size of these types for the purposes of layout and ``sizeof`` are the number of -bits aligned to this calculated alignment. This permits the use of these types in -allocated arrays using common ``sizeof(Array)/sizeof(ElementType)`` pattern. - -Extended integer types work with the C _Atomic type modifier, however only precisions -that are powers-of-2 greater than 8 bit are accepted. - -Extended integer types align with existing calling conventions. They have the same size -and alignment as the smallest basic type that can contain them. Types that are larger -than 64 bits are handled in the same way as _int128 is handled; they are conceptually -treated as struct of register size chunks. They number of chunks are the smallest -number that can contain the types which does not necessarily mean a power-of-2 size. +Clang supports the C23 ``_BitInt(N)`` feature as an extension in older C modes +and in C++. This type was previously implemented in Clang with the same +semantics, but spelled ``_ExtInt(N)``. This spelling has been deprecated in +favor of the standard type. + +Note: the ABI for ``_BitInt(N)`` is still in the process of being stabilized, +so this type should not yet be used in interfaces that require ABI stability. Intrinsics Support within Constant Expressions ============================================== Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -139,6 +139,16 @@ ``__attribute__((warning("")))`` function attributes have been added. - The maximum allowed alignment has been increased from 2^29 to 2^32. +- Clang now supports the ``_BitInt(N)`` family of bit-precise integer types + from C23. This type was previously exposed as ``_ExtInt(N)``, which is now a + deprecated alias for ``_BitInt(N)`` (so diagnostics will mention ``_BitInt`` + even if source uses ``_ExtInt``). ``_BitInt(N)`` and ``_ExtInt(N)`` are the + same types in all respects beyond spelling and the deprecation warning. + ``_BitInt(N)`` is supported as an extension in older C modes and in all C++ + modes. Note: the ABI for ``_BitInt(N)`` is still in the process of being + stabilized, so this type should not yet be used in interfaces that require + ABI stability. + C++ Language Changes in Clang ----------------------------- @@ -171,6 +181,13 @@ ABI Changes in Clang -------------------- +- The ``_ExtInt(N)`` extension has been standardized in C23 as ``_BitInt(N)``. +The mangling of this type in C++ has accordingly changed: under the Microsoft +ABI it is now mangled using the ``_BitInt`` spelling, and under the Itanium ABI +it is now mangled using a dedicated production. Note: the ABI for ``_BitInt(N)`` +is still in the process of being stabilized, so this type should not yet be +used in interfaces that require ABI stability. + OpenMP Support in Clang ----------------------- Index: clang/docs/index.rst =================================================================== --- clang/docs/index.rst +++ clang/docs/index.rst @@ -95,6 +95,7 @@ ItaniumMangleAbiTags HardwareAssistedAddressSanitizerDesign.rst ConstantInterpreter + BitIntABI Indices and tables Index: clang/include/clang/AST/ASTContext.h =================================================================== --- clang/include/clang/AST/ASTContext.h +++ clang/include/clang/AST/ASTContext.h @@ -264,8 +264,8 @@ mutable llvm::FoldingSet AtomicTypes; llvm::FoldingSet AttributedTypes; mutable llvm::FoldingSet PipeTypes; - mutable llvm::FoldingSet ExtIntTypes; - mutable llvm::FoldingSet DependentExtIntTypes; + mutable llvm::FoldingSet BitIntTypes; + mutable llvm::FoldingSet DependentBitIntTypes; mutable llvm::FoldingSet QualifiedTemplateNames; mutable llvm::FoldingSet DependentTemplateNames; @@ -1350,13 +1350,13 @@ /// Return a write_only pipe type for the specified type. QualType getWritePipeType(QualType T) const; - /// Return an extended integer type with the specified signedness and bit + /// Return a bit-precise integer type with the specified signedness and bit /// count. - QualType getExtIntType(bool Unsigned, unsigned NumBits) const; + QualType getBitIntType(bool Unsigned, unsigned NumBits) const; - /// Return a dependent extended integer type with the specified signedness and - /// bit count. - QualType getDependentExtIntType(bool Unsigned, Expr *BitsExpr) const; + /// Return a dependent bit-precise integer type with the specified signedness + /// and bit count. + QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const; /// Gets the struct used to keep track of the extended descriptor for /// pointer to blocks. Index: clang/include/clang/AST/RecursiveASTVisitor.h =================================================================== --- clang/include/clang/AST/RecursiveASTVisitor.h +++ clang/include/clang/AST/RecursiveASTVisitor.h @@ -1072,8 +1072,8 @@ DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); }) -DEF_TRAVERSE_TYPE(ExtIntType, {}) -DEF_TRAVERSE_TYPE(DependentExtIntType, +DEF_TRAVERSE_TYPE(BitIntType, {}) +DEF_TRAVERSE_TYPE(DependentBitIntType, { TRY_TO(TraverseStmt(T->getNumBitsExpr())); }) #undef DEF_TRAVERSE_TYPE @@ -1358,8 +1358,8 @@ DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); }) -DEF_TRAVERSE_TYPELOC(ExtIntType, {}) -DEF_TRAVERSE_TYPELOC(DependentExtIntType, { +DEF_TRAVERSE_TYPELOC(BitIntType, {}) +DEF_TRAVERSE_TYPELOC(DependentBitIntType, { TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr())); }) Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -2128,7 +2128,7 @@ bool isOCLExtOpaqueType() const; // Any OpenCL extension type bool isPipeType() const; // OpenCL pipe type - bool isExtIntType() const; // Extended Int Type + bool isBitIntType() const; // Bit-precise integer type bool isOpenCLSpecificType() const; // Any OpenCL specific type /// Determines if this type, which must satisfy @@ -6304,13 +6304,13 @@ }; /// A fixed int type of a specified bitwidth. -class ExtIntType final : public Type, public llvm::FoldingSetNode { +class BitIntType final : public Type, public llvm::FoldingSetNode { friend class ASTContext; unsigned IsUnsigned : 1; unsigned NumBits : 24; protected: - ExtIntType(bool isUnsigned, unsigned NumBits); + BitIntType(bool isUnsigned, unsigned NumBits); public: bool isUnsigned() const { return IsUnsigned; } @@ -6330,16 +6330,16 @@ ID.AddInteger(NumBits); } - static bool classof(const Type *T) { return T->getTypeClass() == ExtInt; } + static bool classof(const Type *T) { return T->getTypeClass() == BitInt; } }; -class DependentExtIntType final : public Type, public llvm::FoldingSetNode { +class DependentBitIntType final : public Type, public llvm::FoldingSetNode { friend class ASTContext; const ASTContext &Context; llvm::PointerIntPair ExprAndUnsigned; protected: - DependentExtIntType(const ASTContext &Context, bool IsUnsigned, + DependentBitIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBits); public: @@ -6357,7 +6357,7 @@ bool IsUnsigned, Expr *NumBitsExpr); static bool classof(const Type *T) { - return T->getTypeClass() == DependentExtInt; + return T->getTypeClass() == DependentBitInt; } }; @@ -6888,8 +6888,8 @@ return isa(CanonicalType); } -inline bool Type::isExtIntType() const { - return isa(CanonicalType); +inline bool Type::isBitIntType() const { + return isa(CanonicalType); } #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ @@ -6995,7 +6995,7 @@ return IsEnumDeclComplete(ET->getDecl()) && !IsEnumDeclScoped(ET->getDecl()); } - return isExtIntType(); + return isBitIntType(); } inline bool Type::isFixedPointType() const { @@ -7053,7 +7053,7 @@ isa(CanonicalType) || isa(CanonicalType) || isa(CanonicalType) || - isExtIntType(); + isBitIntType(); } inline bool Type::isIntegralOrEnumerationType() const { @@ -7066,7 +7066,7 @@ if (const auto *ET = dyn_cast(CanonicalType)) return IsEnumDeclComplete(ET->getDecl()); - return isExtIntType(); + return isBitIntType(); } inline bool Type::isBooleanType() const { Index: clang/include/clang/AST/TypeLoc.h =================================================================== --- clang/include/clang/AST/TypeLoc.h +++ clang/include/clang/AST/TypeLoc.h @@ -2561,12 +2561,12 @@ } return Cur.getAs(); } -class ExtIntTypeLoc final - : public InheritingConcreteTypeLoc {}; -class DependentExtIntTypeLoc final - : public InheritingConcreteTypeLoc {}; +class BitIntTypeLoc final + : public InheritingConcreteTypeLoc {}; +class DependentBitIntTypeLoc final + : public InheritingConcreteTypeLoc {}; } // namespace clang Index: clang/include/clang/AST/TypeProperties.td =================================================================== --- clang/include/clang/AST/TypeProperties.td +++ clang/include/clang/AST/TypeProperties.td @@ -882,7 +882,7 @@ }]>; } -let Class = ExtIntType in { +let Class = BitIntType in { def : Property<"isUnsigned", Bool> { let Read = [{ node->isUnsigned() }]; } @@ -891,11 +891,11 @@ } def : Creator<[{ - return ctx.getExtIntType(isUnsigned, numBits); + return ctx.getBitIntType(isUnsigned, numBits); }]>; } -let Class = DependentExtIntType in { +let Class = DependentBitIntType in { def : Property<"isUnsigned", Bool> { let Read = [{ node->isUnsigned() }]; } @@ -903,6 +903,6 @@ let Read = [{ node->getNumBitsExpr() }]; } def : Creator<[{ - return ctx.getDependentExtIntType(isUnsigned, numBitsExpr); + return ctx.getDependentBitIntType(isUnsigned, numBitsExpr); }]>; } Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -187,6 +187,7 @@ def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings", [CXX11CompatDeprecatedWritableStr]>; def DeprecatedPragma : DiagGroup<"deprecated-pragma">; +def DeprecatedType : DiagGroup<"deprecated-type">; // FIXME: Why is DeprecatedImplementations not in this group? def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedArrayCompare, @@ -204,6 +205,7 @@ DeprecatedPragma, DeprecatedRegister, DeprecatedThisCapture, + DeprecatedType, DeprecatedVolatile, DeprecatedWritableStr]>, DiagCategory<"Deprecations">; Index: clang/include/clang/Basic/DiagnosticParseKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticParseKinds.td +++ clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1501,6 +1501,15 @@ def err_pragma_cannot_end_force_cuda_host_device : Error< "force_cuda_host_device end pragma without matching " "force_cuda_host_device begin">; + +def warn_ext_int_deprecated : Warning< + "'_ExtInt' is deprecated; use '_BitInt' instead">, InGroup; +def ext_bit_int : Extension< + "'_BitInt' in %select{C17 and earlier|C++}0 is a Clang extension">, + InGroup>; +def warn_c17_compat_bit_int : Warning< + "'_BitInt' is incompatible with C standards before C2x">, + InGroup, DefaultIgnore; } // end of Parse Issue category. let CategoryName = "Modules Issue" in { Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8329,8 +8329,8 @@ " 1,2,4 or 8 byte type (%0 invalid)">; def err_atomic_builtin_ext_int_size : Error< "Atomic memory operand must have a power-of-two size">; -def err_atomic_builtin_ext_int_prohibit : Error< - "argument to atomic builtin of type '_ExtInt' is not supported">; +def err_atomic_builtin_bit_int_prohibit : Error< + "argument to atomic builtin of type '_BitInt' is not supported">; def err_atomic_op_needs_atomic : Error< "address argument to atomic operation must be a pointer to _Atomic " "type (%0 invalid)">; @@ -8366,8 +8366,8 @@ def err_overflow_builtin_must_be_ptr_int : Error< "result argument to overflow builtin must be a pointer " "to a non-const integer (%0 invalid)">; -def err_overflow_builtin_ext_int_max_size : Error< - "__builtin_mul_overflow does not support signed _ExtInt operands of more " +def err_overflow_builtin_bit_int_max_size : Error< + "__builtin_mul_overflow does not support 'signed _BitInt' operands of more " "than %0 bits">; def err_atomic_load_store_uses_lib : Error< @@ -11368,9 +11368,9 @@ "function template with 'sycl_kernel' attribute must have a 'void' return type">, InGroup; -def err_ext_int_bad_size : Error<"%select{signed|unsigned}0 _ExtInt must " +def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " "have a bit size of at least %select{2|1}0">; -def err_ext_int_max_size : Error<"%select{signed|unsigned}0 _ExtInt of bit " +def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; // errors of expect.with.probability Index: clang/include/clang/Basic/Specifiers.h =================================================================== --- clang/include/clang/Basic/Specifiers.h +++ clang/include/clang/Basic/Specifiers.h @@ -59,7 +59,7 @@ TST_char32, // C++11 char32_t TST_int, TST_int128, - TST_extint, // Extended Int types. + TST_bitint, // Bit-precise integer types. TST_half, // OpenCL half, ARM NEON __fp16 TST_Float16, // C11 extension ISO/IEC TS 18661-3 TST_Accum, // ISO/IEC JTC1 SC22 WG14 N1169 Extension Index: clang/include/clang/Basic/TargetInfo.h =================================================================== --- clang/include/clang/Basic/TargetInfo.h +++ clang/include/clang/Basic/TargetInfo.h @@ -580,9 +580,13 @@ return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128; } // FIXME - /// Determine whether the _ExtInt type is supported on this target. This + /// Determine whether the _BitInt type is supported on this target. This /// limitation is put into place for ABI reasons. - virtual bool hasExtIntType() const { + /// FIXME: _BitInt is a required type in C23, so there's not much utility in + /// asking whether the target supported it or not; I think this should be + /// removed once backends have been alerted to the type and have had the + /// chance to do implementation work if needed. + virtual bool hasBitIntType() const { return false; } Index: clang/include/clang/Basic/TokenKinds.def =================================================================== --- clang/include/clang/Basic/TokenKinds.def +++ clang/include/clang/Basic/TokenKinds.def @@ -300,6 +300,7 @@ KEYWORD(inline , KEYC99|KEYCXX|KEYGNU) KEYWORD(int , KEYALL) KEYWORD(_ExtInt , KEYALL) +KEYWORD(_BitInt , KEYALL) KEYWORD(long , KEYALL) KEYWORD(register , KEYALL) KEYWORD(restrict , KEYC99) Index: clang/include/clang/Basic/TypeNodes.td =================================================================== --- clang/include/clang/Basic/TypeNodes.td +++ clang/include/clang/Basic/TypeNodes.td @@ -107,5 +107,5 @@ def ObjCObjectPointerType : TypeNode; def PipeType : TypeNode; def AtomicType : TypeNode; -def ExtIntType : TypeNode; -def DependentExtIntType : TypeNode, AlwaysDependent; +def BitIntType : TypeNode; +def DependentBitIntType : TypeNode, AlwaysDependent; Index: clang/include/clang/Parse/Parser.h =================================================================== --- clang/include/clang/Parse/Parser.h +++ clang/include/clang/Parse/Parser.h @@ -2564,6 +2564,10 @@ /// full validation of the syntactic structure of attributes. bool TrySkipAttributes(); + /// Diagnoses use of _ExtInt as being deprecated, and diagnoses use of + /// _BitInt as an extension when appropriate. + void DiagnoseBitIntUse(const Token &Tok); + public: TypeResult ParseTypeName(SourceRange *Range = nullptr, Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -266,7 +266,7 @@ static const TST TST_char32 = clang::TST_char32; static const TST TST_int = clang::TST_int; static const TST TST_int128 = clang::TST_int128; - static const TST TST_extint = clang::TST_extint; + static const TST TST_bitint = clang::TST_bitint; static const TST TST_half = clang::TST_half; static const TST TST_BFloat16 = clang::TST_BFloat16; static const TST TST_float = clang::TST_float; @@ -404,7 +404,7 @@ T == TST_underlyingType || T == TST_atomic); } static bool isExprRep(TST T) { - return (T == TST_typeofExpr || T == TST_decltype || T == TST_extint); + return (T == TST_typeofExpr || T == TST_decltype || T == TST_bitint); } static bool isTemplateIdRep(TST T) { return (T == TST_auto || T == TST_decltype_auto); @@ -703,7 +703,7 @@ bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy); - bool SetExtIntType(SourceLocation KWLoc, Expr *BitWidth, + bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy); bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -2028,7 +2028,7 @@ SourceLocation Loc); QualType BuildWritePipeType(QualType T, SourceLocation Loc); - QualType BuildExtIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); + QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S); TypeSourceInfo *GetTypeForDeclaratorCast(Declarator &D, QualType FromTy); Index: clang/include/clang/Serialization/TypeBitCodes.def =================================================================== --- clang/include/clang/Serialization/TypeBitCodes.def +++ clang/include/clang/Serialization/TypeBitCodes.def @@ -58,8 +58,8 @@ TYPE_BIT_CODE(DependentAddressSpace, DEPENDENT_ADDRESS_SPACE, 47) TYPE_BIT_CODE(DependentVector, DEPENDENT_SIZED_VECTOR, 48) TYPE_BIT_CODE(MacroQualified, MACRO_QUALIFIED, 49) -TYPE_BIT_CODE(ExtInt, EXT_INT, 50) -TYPE_BIT_CODE(DependentExtInt, DEPENDENT_EXT_INT, 51) +TYPE_BIT_CODE(BitInt, BIT_INT, 50) +TYPE_BIT_CODE(DependentBitInt, DEPENDENT_BIT_INT, 51) TYPE_BIT_CODE(ConstantMatrix, CONSTANT_MATRIX, 52) TYPE_BIT_CODE(DependentSizedMatrix, DEPENDENT_SIZE_MATRIX, 53) Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -2286,8 +2286,8 @@ Align = toBits(Layout.getAlignment()); break; } - case Type::ExtInt: { - const auto *EIT = cast(T); + case Type::BitInt: { + const auto *EIT = cast(T); Align = std::min(static_cast(std::max( getCharWidth(), llvm::PowerOf2Ceil(EIT->getNumBits()))), @@ -3569,8 +3569,8 @@ case Type::Auto: case Type::DeducedTemplateSpecialization: case Type::PackExpansion: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: llvm_unreachable("type should never be variably-modified"); // These types can be variably-modified but should never need to @@ -4482,34 +4482,34 @@ return getPipeType(T, false); } -QualType ASTContext::getExtIntType(bool IsUnsigned, unsigned NumBits) const { +QualType ASTContext::getBitIntType(bool IsUnsigned, unsigned NumBits) const { llvm::FoldingSetNodeID ID; - ExtIntType::Profile(ID, IsUnsigned, NumBits); + BitIntType::Profile(ID, IsUnsigned, NumBits); void *InsertPos = nullptr; - if (ExtIntType *EIT = ExtIntTypes.FindNodeOrInsertPos(ID, InsertPos)) + if (BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(EIT, 0); - auto *New = new (*this, TypeAlignment) ExtIntType(IsUnsigned, NumBits); - ExtIntTypes.InsertNode(New, InsertPos); + auto *New = new (*this, TypeAlignment) BitIntType(IsUnsigned, NumBits); + BitIntTypes.InsertNode(New, InsertPos); Types.push_back(New); return QualType(New, 0); } -QualType ASTContext::getDependentExtIntType(bool IsUnsigned, +QualType ASTContext::getDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr) const { assert(NumBitsExpr->isInstantiationDependent() && "Only good for dependent"); llvm::FoldingSetNodeID ID; - DependentExtIntType::Profile(ID, *this, IsUnsigned, NumBitsExpr); + DependentBitIntType::Profile(ID, *this, IsUnsigned, NumBitsExpr); void *InsertPos = nullptr; - if (DependentExtIntType *Existing = - DependentExtIntTypes.FindNodeOrInsertPos(ID, InsertPos)) + if (DependentBitIntType *Existing = + DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(Existing, 0); auto *New = new (*this, TypeAlignment) - DependentExtIntType(*this, IsUnsigned, NumBitsExpr); - DependentExtIntTypes.InsertNode(New, InsertPos); + DependentBitIntType(*this, IsUnsigned, NumBitsExpr); + DependentBitIntTypes.InsertNode(New, InsertPos); Types.push_back(New); return QualType(New, 0); @@ -6410,7 +6410,7 @@ // Results in this 'losing' to any type of the same size, but winning if // larger. - if (const auto *EIT = dyn_cast(T)) + if (const auto *EIT = dyn_cast(T)) return 0 + (EIT->getNumBits() << 3); switch (cast(T)->getKind()) { @@ -7851,7 +7851,7 @@ return; case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: #define ABSTRACT_TYPE(KIND, BASE) #define TYPE(KIND, BASE) #define DEPENDENT_TYPE(KIND, BASE) \ @@ -10067,12 +10067,12 @@ assert(LHS != RHS && "Equivalent pipe types should have already been handled!"); return {}; - case Type::ExtInt: { - // Merge two ext-int types, while trying to preserve typedef info. - bool LHSUnsigned = LHS->castAs()->isUnsigned(); - bool RHSUnsigned = RHS->castAs()->isUnsigned(); - unsigned LHSBits = LHS->castAs()->getNumBits(); - unsigned RHSBits = RHS->castAs()->getNumBits(); + case Type::BitInt: { + // Merge two bit-precise int types, while trying to preserve typedef info. + bool LHSUnsigned = LHS->castAs()->isUnsigned(); + bool RHSUnsigned = RHS->castAs()->isUnsigned(); + unsigned LHSBits = LHS->castAs()->getNumBits(); + unsigned RHSBits = RHS->castAs()->getNumBits(); // Like unsigned/int, shouldn't have a type if they don't match. if (LHSUnsigned != RHSUnsigned) @@ -10222,7 +10222,7 @@ T = ET->getDecl()->getIntegerType(); if (T->isBooleanType()) return 1; - if(const auto *EIT = T->getAs()) + if (const auto *EIT = T->getAs()) return EIT->getNumBits(); // For builtin types, just use the standard type sizing method return (unsigned)getTypeSize(T); @@ -10237,9 +10237,9 @@ return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()), VTy->getNumElements(), VTy->getVectorKind()); - // For _ExtInt, return an unsigned _ExtInt with same width. - if (const auto *EITy = T->getAs()) - return getExtIntType(/*IsUnsigned=*/true, EITy->getNumBits()); + // For _BitInt, return an unsigned _BitInt with same width. + if (const auto *EITy = T->getAs()) + return getBitIntType(/*IsUnsigned=*/true, EITy->getNumBits()); // For enums, get the underlying integer type of the enum, and let the general // integer type signchanging code handle it. @@ -10305,9 +10305,9 @@ return getVectorType(getCorrespondingSignedType(VTy->getElementType()), VTy->getNumElements(), VTy->getVectorKind()); - // For _ExtInt, return a signed _ExtInt with same width. - if (const auto *EITy = T->getAs()) - return getExtIntType(/*IsUnsigned=*/false, EITy->getNumBits()); + // For _BitInt, return a signed _BitInt with same width. + if (const auto *EITy = T->getAs()) + return getBitIntType(/*IsUnsigned=*/false, EITy->getNumBits()); // For enums, get the underlying integer type of the enum, and let the general // integer type signchanging code handle it. Index: clang/lib/AST/ASTStructuralEquivalence.cpp =================================================================== --- clang/lib/AST/ASTStructuralEquivalence.cpp +++ clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1205,18 +1205,18 @@ cast(T2)->getElementType())) return false; break; - case Type::ExtInt: { - const auto *Int1 = cast(T1); - const auto *Int2 = cast(T2); + case Type::BitInt: { + const auto *Int1 = cast(T1); + const auto *Int2 = cast(T2); if (Int1->isUnsigned() != Int2->isUnsigned() || Int1->getNumBits() != Int2->getNumBits()) return false; break; } - case Type::DependentExtInt: { - const auto *Int1 = cast(T1); - const auto *Int2 = cast(T2); + case Type::DependentBitInt: { + const auto *Int1 = cast(T1); + const auto *Int2 = cast(T2); if (Int1->isUnsigned() != Int2->isUnsigned() || !IsStructurallyEquivalent(Context, Int1->getNumBitsExpr(), Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -11072,7 +11072,7 @@ case Type::ObjCInterface: case Type::ObjCObjectPointer: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: // GCC classifies vectors as None. We follow its lead and classify all // other types that don't fit into the regular classification the same way. return GCCTypeClass::None; Index: clang/lib/AST/ItaniumMangle.cpp =================================================================== --- clang/lib/AST/ItaniumMangle.cpp +++ clang/lib/AST/ItaniumMangle.cpp @@ -2263,8 +2263,8 @@ case Type::Atomic: case Type::Pipe: case Type::MacroQualified: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: llvm_unreachable("type is illegal as a nested name specifier"); case Type::SubstTemplateTypeParmPack: @@ -3967,26 +3967,20 @@ Out << "8ocl_pipe"; } -void CXXNameMangler::mangleType(const ExtIntType *T) { - Out << "U7_ExtInt"; - llvm::APSInt BW(32, true); - BW = T->getNumBits(); - TemplateArgument TA(Context.getASTContext(), BW, getASTContext().IntTy); - mangleTemplateArgs(TemplateName(), &TA, 1); - if (T->isUnsigned()) - Out << "j"; - else - Out << "i"; +void CXXNameMangler::mangleType(const BitIntType *T) { + // 5.1.5.2 Builtin types + // ::= DB _ + // ::= DU _ + Out << "D" << (T->isUnsigned() ? "U" : "B") << T->getNumBits() << "_"; } -void CXXNameMangler::mangleType(const DependentExtIntType *T) { - Out << "U7_ExtInt"; - TemplateArgument TA(T->getNumBitsExpr()); - mangleTemplateArgs(TemplateName(), &TA, 1); - if (T->isUnsigned()) - Out << "j"; - else - Out << "i"; +void CXXNameMangler::mangleType(const DependentBitIntType *T) { + // 5.1.5.2 Builtin types + // ::= DB _ + // ::= DU _ + Out << "D" << (T->isUnsigned() ? "U" : "B"); + mangleExpression(T->getNumBitsExpr()); + Out << "_"; } void CXXNameMangler::mangleIntegerLiteral(QualType T, Index: clang/lib/AST/MicrosoftMangle.cpp =================================================================== --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -3336,26 +3336,26 @@ return Mangler.mangle(D); } -void MicrosoftCXXNameMangler::mangleType(const ExtIntType *T, Qualifiers, +void MicrosoftCXXNameMangler::mangleType(const BitIntType *T, Qualifiers, SourceRange Range) { llvm::SmallString<64> TemplateMangling; llvm::raw_svector_ostream Stream(TemplateMangling); MicrosoftCXXNameMangler Extra(Context, Stream); Stream << "?$"; if (T->isUnsigned()) - Extra.mangleSourceName("_UExtInt"); + Extra.mangleSourceName("_UBitInt"); else - Extra.mangleSourceName("_ExtInt"); + Extra.mangleSourceName("_BitInt"); Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumBits())); mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"}); } -void MicrosoftCXXNameMangler::mangleType(const DependentExtIntType *T, +void MicrosoftCXXNameMangler::mangleType(const DependentBitIntType *T, Qualifiers, SourceRange Range) { DiagnosticsEngine &Diags = Context.getDiags(); unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "cannot mangle this DependentExtInt type yet"); + DiagnosticsEngine::Error, "cannot mangle this DependentBitInt type yet"); Diags.Report(Range.getBegin(), DiagID) << Range; } Index: clang/lib/AST/Type.cpp =================================================================== --- clang/lib/AST/Type.cpp +++ clang/lib/AST/Type.cpp @@ -338,25 +338,25 @@ VectorTypeBits.NumElements = nElements; } -ExtIntType::ExtIntType(bool IsUnsigned, unsigned NumBits) - : Type(ExtInt, QualType{}, TypeDependence::None), IsUnsigned(IsUnsigned), +BitIntType::BitIntType(bool IsUnsigned, unsigned NumBits) + : Type(BitInt, QualType{}, TypeDependence::None), IsUnsigned(IsUnsigned), NumBits(NumBits) {} -DependentExtIntType::DependentExtIntType(const ASTContext &Context, +DependentBitIntType::DependentBitIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBitsExpr) - : Type(DependentExtInt, QualType{}, + : Type(DependentBitInt, QualType{}, toTypeDependence(NumBitsExpr->getDependence())), Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {} -bool DependentExtIntType::isUnsigned() const { +bool DependentBitIntType::isUnsigned() const { return ExprAndUnsigned.getInt(); } -clang::Expr *DependentExtIntType::getNumBitsExpr() const { +clang::Expr *DependentBitIntType::getNumBitsExpr() const { return ExprAndUnsigned.getPointer(); } -void DependentExtIntType::Profile(llvm::FoldingSetNodeID &ID, +void DependentBitIntType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool IsUnsigned, Expr *NumBitsExpr) { ID.AddBoolean(IsUnsigned); @@ -1925,7 +1925,7 @@ if (const auto *ET = dyn_cast(CanonicalType)) return ET->getDecl()->isComplete(); - return isExtIntType(); + return isBitIntType(); } bool Type::isIntegralOrUnscopedEnumerationType() const { @@ -1933,7 +1933,7 @@ return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::Int128; - if (isExtIntType()) + if (isBitIntType()) return true; return isUnscopedEnumerationType(); @@ -2016,7 +2016,9 @@ return ET->getDecl()->getIntegerType()->isSignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isSigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isSigned(); return false; @@ -2033,9 +2035,10 @@ return ET->getDecl()->getIntegerType()->isSignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isSigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isSigned(); - return false; } @@ -2063,7 +2066,9 @@ return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isUnsigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isUnsigned(); return false; @@ -2080,7 +2085,9 @@ return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isUnsigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isUnsigned(); return false; @@ -2122,7 +2129,7 @@ BT->getKind() <= BuiltinType::Ibm128; if (const auto *ET = dyn_cast(CanonicalType)) return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped(); - return isExtIntType(); + return isBitIntType(); } bool Type::isArithmeticType() const { @@ -2138,7 +2145,7 @@ // false for scoped enumerations since that will disable any // unwanted implicit conversions. return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete(); - return isa(CanonicalType) || isExtIntType(); + return isa(CanonicalType) || isBitIntType(); } Type::ScalarTypeKind Type::getScalarTypeKind() const { @@ -2167,7 +2174,7 @@ if (CT->getElementType()->isRealFloatingType()) return STK_FloatingComplex; return STK_IntegralComplex; - } else if (isExtIntType()) { + } else if (isBitIntType()) { return STK_Integral; } @@ -2374,7 +2381,7 @@ case Type::MemberPointer: case Type::Vector: case Type::ExtVector: - case Type::ExtInt: + case Type::BitInt: return true; case Type::Enum: @@ -3842,7 +3849,7 @@ // here in error recovery. return CachedProperties(ExternalLinkage, false); - case Type::ExtInt: + case Type::BitInt: case Type::Builtin: // C++ [basic.link]p8: // A type is said to have linkage if and only if: @@ -3942,7 +3949,7 @@ assert(T->isInstantiationDependentType()); return LinkageInfo::external(); - case Type::ExtInt: + case Type::BitInt: case Type::Builtin: return LinkageInfo::external(); @@ -4162,8 +4169,8 @@ case Type::ObjCInterface: case Type::Atomic: case Type::Pipe: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: return false; } llvm_unreachable("bad type kind!"); Index: clang/lib/AST/TypePrinter.cpp =================================================================== --- clang/lib/AST/TypePrinter.cpp +++ clang/lib/AST/TypePrinter.cpp @@ -232,8 +232,8 @@ case Type::ObjCInterface: case Type::Atomic: case Type::Pipe: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: CanPrefixQualifiers = true; break; @@ -1204,26 +1204,26 @@ void TypePrinter::printPipeAfter(const PipeType *T, raw_ostream &OS) {} -void TypePrinter::printExtIntBefore(const ExtIntType *T, raw_ostream &OS) { +void TypePrinter::printBitIntBefore(const BitIntType *T, raw_ostream &OS) { if (T->isUnsigned()) OS << "unsigned "; - OS << "_ExtInt(" << T->getNumBits() << ")"; + OS << "_BitInt(" << T->getNumBits() << ")"; spaceBeforePlaceHolder(OS); } -void TypePrinter::printExtIntAfter(const ExtIntType *T, raw_ostream &OS) {} +void TypePrinter::printBitIntAfter(const BitIntType *T, raw_ostream &OS) {} -void TypePrinter::printDependentExtIntBefore(const DependentExtIntType *T, +void TypePrinter::printDependentBitIntBefore(const DependentBitIntType *T, raw_ostream &OS) { if (T->isUnsigned()) OS << "unsigned "; - OS << "_ExtInt("; + OS << "_BitInt("; T->getNumBitsExpr()->printPretty(OS, nullptr, Policy); OS << ")"; spaceBeforePlaceHolder(OS); } -void TypePrinter::printDependentExtIntAfter(const DependentExtIntType *T, +void TypePrinter::printDependentBitIntAfter(const DependentBitIntType *T, raw_ostream &OS) {} /// Appends the given scope to the end of a string. Index: clang/lib/Basic/Targets/AArch64.h =================================================================== --- clang/lib/Basic/Targets/AArch64.h +++ clang/lib/Basic/Targets/AArch64.h @@ -149,7 +149,7 @@ const char *getBFloat16Mangling() const override { return "u6__bf16"; }; bool hasInt128Type() const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo { Index: clang/lib/Basic/Targets/AMDGPU.h =================================================================== --- clang/lib/Basic/Targets/AMDGPU.h +++ clang/lib/Basic/Targets/AMDGPU.h @@ -426,7 +426,7 @@ void setAuxTarget(const TargetInfo *Aux) override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } // Record offload arch features since they are needed for defining the // pre-defined macros. Index: clang/lib/Basic/Targets/ARC.h =================================================================== --- clang/lib/Basic/Targets/ARC.h +++ clang/lib/Basic/Targets/ARC.h @@ -66,7 +66,7 @@ return false; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool isCLZForZeroUndef() const override { return false; } }; Index: clang/lib/Basic/Targets/ARM.h =================================================================== --- clang/lib/Basic/Targets/ARM.h +++ clang/lib/Basic/Targets/ARM.h @@ -187,8 +187,8 @@ bool hasSjLjLowering() const override; - bool hasExtIntType() const override { return true; } - + bool hasBitIntType() const override { return true; } + const char *getBFloat16Mangling() const override { return "u6__bf16"; }; }; Index: clang/lib/Basic/Targets/Hexagon.h =================================================================== --- clang/lib/Basic/Targets/Hexagon.h +++ clang/lib/Basic/Targets/Hexagon.h @@ -139,7 +139,7 @@ return CPU.find('t') != std::string::npos; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/Lanai.h =================================================================== --- clang/lib/Basic/Targets/Lanai.h +++ clang/lib/Basic/Targets/Lanai.h @@ -87,7 +87,7 @@ const char *getClobbers() const override { return ""; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/Mips.h =================================================================== --- clang/lib/Basic/Targets/Mips.h +++ clang/lib/Basic/Targets/Mips.h @@ -406,7 +406,7 @@ unsigned getUnwindWordWidth() const override; bool validateTarget(DiagnosticsEngine &Diags) const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/NVPTX.h =================================================================== --- clang/lib/Basic/Targets/NVPTX.h +++ clang/lib/Basic/Targets/NVPTX.h @@ -175,7 +175,7 @@ return CCCR_Warning; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/PNaCl.h =================================================================== --- clang/lib/Basic/Targets/PNaCl.h +++ clang/lib/Basic/Targets/PNaCl.h @@ -69,7 +69,7 @@ const char *getClobbers() const override { return ""; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; // We attempt to use PNaCl (le32) frontend and Mips32EL backend. Index: clang/lib/Basic/Targets/PPC.h =================================================================== --- clang/lib/Basic/Targets/PPC.h +++ clang/lib/Basic/Targets/PPC.h @@ -351,7 +351,7 @@ const char *getFloat128Mangling() const override { return "u9__ieee128"; } const char *getIbm128Mangling() const override { return "g"; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool isSPRegName(StringRef RegName) const override { return RegName.equals("r1") || RegName.equals("x1"); Index: clang/lib/Basic/Targets/RISCV.h =================================================================== --- clang/lib/Basic/Targets/RISCV.h +++ clang/lib/Basic/Targets/RISCV.h @@ -95,7 +95,7 @@ bool handleTargetFeatures(std::vector &Features, DiagnosticsEngine &Diags) override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo { public: Index: clang/lib/Basic/Targets/SPIR.h =================================================================== --- clang/lib/Basic/Targets/SPIR.h +++ clang/lib/Basic/Targets/SPIR.h @@ -153,7 +153,7 @@ supportAllOpenCLOpts(); } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool hasInt128Type() const override { return false; } }; Index: clang/lib/Basic/Targets/Sparc.h =================================================================== --- clang/lib/Basic/Targets/Sparc.h +++ clang/lib/Basic/Targets/Sparc.h @@ -179,7 +179,7 @@ MacroBuilder &Builder) const override; bool hasSjLjLowering() const override { return true; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; // SPARCV8el is the 32-bit little-endian mode selected by Triple::sparcel. @@ -232,7 +232,7 @@ return getCPUGeneration(CPU) == CG_V9; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/SystemZ.h =================================================================== --- clang/lib/Basic/Targets/SystemZ.h +++ clang/lib/Basic/Targets/SystemZ.h @@ -170,7 +170,7 @@ const char *getLongDoubleMangling() const override { return "g"; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } int getEHDataRegisterNumber(unsigned RegNo) const override { return RegNo < 4 ? 6 + RegNo : -1; Index: clang/lib/Basic/Targets/WebAssembly.h =================================================================== --- clang/lib/Basic/Targets/WebAssembly.h +++ clang/lib/Basic/Targets/WebAssembly.h @@ -137,7 +137,7 @@ } } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool hasProtectedVisibility() const override { return false; } Index: clang/lib/Basic/Targets/X86.h =================================================================== --- clang/lib/Basic/Targets/X86.h +++ clang/lib/Basic/Targets/X86.h @@ -461,7 +461,7 @@ ArrayRef getTargetBuiltins() const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo @@ -768,7 +768,7 @@ ArrayRef getTargetBuiltins() const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; // x86-64 Windows target Index: clang/lib/Basic/Targets/XCore.h =================================================================== --- clang/lib/Basic/Targets/XCore.h +++ clang/lib/Basic/Targets/XCore.h @@ -76,7 +76,7 @@ bool allowsLargerPreferedTypeAlignment() const override { return false; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/CodeGen/ABIInfo.h =================================================================== --- clang/lib/CodeGen/ABIInfo.h +++ clang/lib/CodeGen/ABIInfo.h @@ -105,7 +105,7 @@ uint64_t &Members) const; // Implement the Type::IsPromotableIntegerType for ABI specific needs. The - // only difference is that this considers _ExtInt as well. + // only difference is that this considers bit-precise integer types as well. bool isPromotableIntegerTypeForABI(QualType Ty) const; /// A convenience method to return an indirect ABIArgInfo with an Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -666,7 +666,7 @@ const clang::QualType Type) { assert(Type->isIntegerType() && "Given type is not an integer."); unsigned Width = Type->isBooleanType() ? 1 - : Type->isExtIntType() ? context.getIntWidth(Type) + : Type->isBitIntType() ? context.getIntWidth(Type) : context.getTypeInfo(Type).Width; bool Signed = Type->isSignedIntegerType(); return {Width, Signed}; Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -1976,7 +1976,7 @@ // there's no internal padding (typeSizeEqualsStoreSize). return false; } - if (QTy->isExtIntType()) + if (QTy->isBitIntType()) return true; if (QTy->isReferenceType()) return true; Index: clang/lib/CodeGen/CGDebugInfo.h =================================================================== --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -177,7 +177,7 @@ llvm::DIType *CreateType(const BuiltinType *Ty); llvm::DIType *CreateType(const ComplexType *Ty); llvm::DIType *CreateType(const AutoType *Ty); - llvm::DIType *CreateType(const ExtIntType *Ty); + llvm::DIType *CreateType(const BitIntType *Ty); llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg); llvm::DIType *CreateQualifiedType(const FunctionProtoType *Ty, llvm::DIFile *Fg); Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -883,9 +883,9 @@ return DBuilder.createUnspecifiedType("auto"); } -llvm::DIType *CGDebugInfo::CreateType(const ExtIntType *Ty) { +llvm::DIType *CGDebugInfo::CreateType(const BitIntType *Ty) { - StringRef Name = Ty->isUnsigned() ? "unsigned _ExtInt" : "_ExtInt"; + StringRef Name = Ty->isUnsigned() ? "unsigned _BitInt" : "_BitInt"; llvm::dwarf::TypeKind Encoding = Ty->isUnsigned() ? llvm::dwarf::DW_ATE_unsigned : llvm::dwarf::DW_ATE_signed; @@ -3423,8 +3423,8 @@ case Type::Atomic: return CreateType(cast(Ty), Unit); - case Type::ExtInt: - return CreateType(cast(Ty)); + case Type::BitInt: + return CreateType(cast(Ty)); case Type::Pipe: return CreateType(cast(Ty), Unit); Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -243,7 +243,7 @@ case Type::Enum: case Type::ObjCObjectPointer: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: return TEK_Scalar; // Complexes. @@ -2177,7 +2177,7 @@ case Type::ObjCObject: case Type::ObjCInterface: case Type::ObjCObjectPointer: - case Type::ExtInt: + case Type::BitInt: llvm_unreachable("type class is never variably-modified!"); case Type::Adjusted: Index: clang/lib/CodeGen/CodeGenTBAA.cpp =================================================================== --- clang/lib/CodeGen/CodeGenTBAA.cpp +++ clang/lib/CodeGen/CodeGenTBAA.cpp @@ -209,12 +209,12 @@ return createScalarTypeNode(OutName, getChar(), Size); } - if (const auto *EIT = dyn_cast(Ty)) { + if (const auto *EIT = dyn_cast(Ty)) { SmallString<256> OutName; llvm::raw_svector_ostream Out(OutName); // Don't specify signed/unsigned since integer types can alias despite sign // differences. - Out << "_ExtInt(" << EIT->getNumBits() << ')'; + Out << "_BitInt(" << EIT->getNumBits() << ')'; return createScalarTypeNode(OutName, getChar(), Size); } Index: clang/lib/CodeGen/CodeGenTypes.cpp =================================================================== --- clang/lib/CodeGen/CodeGenTypes.cpp +++ clang/lib/CodeGen/CodeGenTypes.cpp @@ -97,10 +97,10 @@ llvm::Type *R = ConvertType(T); - // If this is a bool type, or an ExtIntType in a bitfield representation, - // map this integer to the target-specified size. - if ((ForBitField && T->isExtIntType()) || - (!T->isExtIntType() && R->isIntegerTy(1))) + // If this is a bool type, or a bit-precise integer type in a bitfield + // representation, map this integer to the target-specified size. + if ((ForBitField && T->isBitIntType()) || + (!T->isBitIntType() && R->isIntegerTy(1))) return llvm::IntegerType::get(getLLVMContext(), (unsigned)Context.getTypeSize(T)); @@ -786,8 +786,8 @@ ResultType = CGM.getOpenCLRuntime().getPipeType(cast(Ty)); break; } - case Type::ExtInt: { - const auto &EIT = cast(Ty); + case Type::BitInt: { + const auto &EIT = cast(Ty); ResultType = llvm::Type::getIntNTy(getLLVMContext(), EIT->getNumBits()); break; } Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3529,7 +3529,7 @@ llvm_unreachable("Pipe types shouldn't get here"); case Type::Builtin: - case Type::ExtInt: + case Type::BitInt: // GCC treats vector and complex types as fundamental types. case Type::Vector: case Type::ExtVector: @@ -3802,7 +3802,7 @@ case Type::Pipe: break; - case Type::ExtInt: + case Type::BitInt: break; case Type::ConstantArray: Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -104,7 +104,7 @@ if (Ty->isPromotableIntegerType()) return true; - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < getContext().getTypeSize(getContext().IntTy)) return true; @@ -762,7 +762,7 @@ Ty = EnumTy->getDecl()->getIntegerType(); ASTContext &Context = getContext(); - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > Context.getTypeSize(Context.getTargetInfo().hasInt128Type() ? Context.Int128Ty @@ -784,7 +784,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > getContext().getTypeSize(getContext().getTargetInfo().hasInt128Type() ? getContext().Int128Ty @@ -1008,8 +1008,9 @@ } else if (Ty->isFloatingType()) { // Floating-point types don't go inreg. return ABIArgInfo::getDirect(); - } else if (const auto *EIT = Ty->getAs()) { - // Treat extended integers as integers if <=64, otherwise pass indirectly. + } else if (const auto *EIT = Ty->getAs()) { + // Treat bit-precise integers as integers if <= 64, otherwise pass + // indirectly. if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(Ty); return ABIArgInfo::getDirect(); @@ -1027,8 +1028,8 @@ if (isAggregateTypeForABI(RetTy)) return getNaturalAlignIndirect(RetTy); - // Treat extended integers as integers if <=64, otherwise pass indirectly. - if (const auto *EIT = RetTy->getAs()) { + // Treat bit-precise integers as integers if <= 64, otherwise pass indirectly. + if (const auto *EIT = RetTy->getAs()) { if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(RetTy); return ABIArgInfo::getDirect(); @@ -1590,7 +1591,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 64) return getIndirectReturnResult(RetTy, State); @@ -1926,7 +1927,7 @@ return ABIArgInfo::getExtend(Ty); } - if (const auto * EIT = Ty->getAs()) { + if (const auto *EIT = Ty->getAs()) { if (EIT->getNumBits() <= 64) { if (InReg) return ABIArgInfo::getDirectInReg(); @@ -3009,7 +3010,7 @@ return; } - if (const auto *EITy = Ty->getAs()) { + if (const auto *EITy = Ty->getAs()) { if (EITy->getNumBits() <= 64) Current = Integer; else if (EITy->getNumBits() <= 128) @@ -3200,7 +3201,7 @@ if (const EnumType *EnumTy = Ty->getAs()) Ty = EnumTy->getDecl()->getIntegerType(); - if (Ty->isExtIntType()) + if (Ty->isBitIntType()) return getNaturalAlignIndirect(Ty); return (isPromotableIntegerTypeForABI(Ty) ? ABIArgInfo::getExtend(Ty) @@ -3237,7 +3238,7 @@ // but this code would be much safer if we could mark the argument with // 'onstack'. See PR12193. if (!isAggregateTypeForABI(Ty) && !IsIllegalVectorType(Ty) && - !Ty->isExtIntType()) { + !Ty->isBitIntType()) { // Treat an enum type as its underlying type. if (const EnumType *EnumTy = Ty->getAs()) Ty = EnumTy->getDecl()->getIntegerType(); @@ -4357,12 +4358,12 @@ } } - if (Ty->isExtIntType()) { + if (Ty->isBitIntType()) { // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is // not 1, 2, 4, or 8 bytes, must be passed by reference." - // However, non-power-of-two _ExtInts will be passed as 1,2,4 or 8 bytes - // anyway as long is it fits in them, so we don't have to check the power of - // 2. + // However, non-power-of-two bit-precise integers will be passed as 1, 2, 4, + // or 8 bytes anyway as long is it fits in them, so we don't have to check + // the power of 2. if (Width <= 64) return ABIArgInfo::getDirect(); return ABIArgInfo::getIndirect(Align, /*ByVal=*/false); @@ -5069,7 +5070,7 @@ break; } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < 64) return true; @@ -5289,7 +5290,7 @@ } } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(Ty, /*ByVal=*/true); @@ -5365,7 +5366,7 @@ } } - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(RetTy, /*ByVal=*/false); @@ -5717,7 +5718,7 @@ if (const EnumType *EnumTy = Ty->getAs()) Ty = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(Ty); @@ -5819,7 +5820,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(RetTy); @@ -6543,7 +6544,7 @@ Ty = EnumTy->getDecl()->getIntegerType(); } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(Ty, /*ByVal=*/true); @@ -6745,7 +6746,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(RetTy, /*ByVal=*/false); @@ -7082,7 +7083,7 @@ (T->isFloat128Type() || (T->isRealFloatingType() && Context.getTypeSize(T) == 128))) return true; - if (const auto *EIT = T->getAs()) + if (const auto *EIT = T->getAs()) return EIT->getNumBits() > (Context.getTargetInfo().hasInt128Type() ? 128U : 64U); if (!Context.getTargetInfo().hasInt128Type() && T->isIntegerType() && @@ -7159,7 +7160,7 @@ return getNaturalAlignIndirect(Ty, /* byval */ true); } - if (const auto *EIT = Ty->getAs()) { + if (const auto *EIT = Ty->getAs()) { if ((EIT->getNumBits() > 128) || (!getContext().getTargetInfo().hasInt128Type() && EIT->getNumBits() > 64)) @@ -7373,7 +7374,7 @@ if (ABIInfo::isPromotableIntegerTypeForABI(Ty)) return true; - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < 64) return true; @@ -7976,7 +7977,7 @@ Ty = EnumTy->getDecl()->getIntegerType(); // Make sure we pass indirectly things that are too large. - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 128 || (EIT->getNumBits() > 64 && !getContext().getTargetInfo().hasInt128Type())) @@ -8067,7 +8068,7 @@ RetTy = EnumTy->getDecl()->getIntegerType(); // Make sure we pass indirectly things that are too large. - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 128 || (EIT->getNumBits() > 64 && !getContext().getTargetInfo().hasInt128Type())) @@ -8442,7 +8443,7 @@ if (Size <= 64) HexagonAdjustRegsLeft(Size, RegsLeft); - if (Size > 64 && Ty->isExtIntType()) + if (Size > 64 && Ty->isBitIntType()) return getNaturalAlignIndirect(Ty, /*ByVal=*/true); return isPromotableIntegerTypeForABI(Ty) ? ABIArgInfo::getExtend(Ty) @@ -8498,7 +8499,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (Size > 64 && RetTy->isExtIntType()) + if (Size > 64 && RetTy->isBitIntType()) return getNaturalAlignIndirect(RetTy, /*ByVal=*/false); return isPromotableIntegerTypeForABI(RetTy) ? ABIArgInfo::getExtend(RetTy) @@ -8869,7 +8870,7 @@ bool InReg = shouldUseInReg(Ty, State); // Don't pass >64 bit integers in registers. - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 64) return getIndirectResult(Ty, /*ByVal=*/true, State); @@ -9580,7 +9581,7 @@ if (Size < 64 && Ty->isIntegerType()) return ABIArgInfo::getExtend(Ty); - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < 64) return ABIArgInfo::getExtend(Ty); @@ -9834,7 +9835,7 @@ ABIArgInfo::getDirect(Result, 0, nullptr, false); } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 64) return getIndirectByValue(Ty); @@ -10915,7 +10916,7 @@ return extendType(Ty); } - if (const auto *EIT = Ty->getAs()) { + if (const auto *EIT = Ty->getAs()) { if (EIT->getNumBits() < XLen && !MustUseStack) return extendType(Ty); if (EIT->getNumBits() > 128 || Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -2891,7 +2891,8 @@ } ExprResult Parser::ParseExtIntegerArgument() { - assert(Tok.is(tok::kw__ExtInt) && "Not an extended int type"); + assert(Tok.isOneOf(tok::kw__ExtInt, tok::kw__BitInt) && + "Not an extended int type"); ConsumeToken(); BalancedDelimiterTracker T(*this, tok::l_paren); @@ -3882,11 +3883,13 @@ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID, Policy); break; - case tok::kw__ExtInt: { + case tok::kw__ExtInt: + case tok::kw__BitInt: { + DiagnoseBitIntUse(Tok); ExprResult ER = ParseExtIntegerArgument(); if (ER.isInvalid()) continue; - isInvalid = DS.SetExtIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); + isInvalid = DS.SetBitIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); ConsumedEnd = PrevTokLocation; break; } @@ -5015,6 +5018,7 @@ case tok::kw_char32_t: case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw___bf16: case tok::kw_half: case tok::kw_float: @@ -5097,6 +5101,7 @@ case tok::kw_char32_t: case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_half: case tok::kw___bf16: case tok::kw_float: @@ -5268,6 +5273,7 @@ case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_half: case tok::kw___bf16: case tok::kw_float: @@ -7476,3 +7482,24 @@ } return false; } + +void Parser::DiagnoseBitIntUse(const Token &Tok) { + // If the token is for _ExtInt, diagnose it as being deprecated. Otherwise, + // the token is about _BitInt and gets (potentially) diagnosed as use of an + // extension. + assert(Tok.isOneOf(tok::kw__ExtInt, tok::kw__BitInt) && + "expected either an _ExtInt or _BitInt token!"); + + SourceLocation Loc = Tok.getLocation(); + if (Tok.is(tok::kw__ExtInt)) { + Diag(Loc, diag::warn_ext_int_deprecated) + << FixItHint::CreateReplacement(Loc, "_BitInt"); + } else { + // In C2x mode, diagnose that the use is not compatible with pre-C2x modes. + // Otherwise, diagnose that the use is a Clang extension. + if (getLangOpts().C2x) + Diag(Loc, diag::warn_c17_compat_bit_int); + else + Diag(Loc, diag::ext_bit_int) << getLangOpts().CPlusPlus; + } +} Index: clang/lib/Parse/ParseExpr.cpp =================================================================== --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -1513,6 +1513,7 @@ case tok::kw___int64: case tok::kw___int128: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_signed: case tok::kw_unsigned: case tok::kw_half: Index: clang/lib/Parse/ParseExprCXX.cpp =================================================================== --- clang/lib/Parse/ParseExprCXX.cpp +++ clang/lib/Parse/ParseExprCXX.cpp @@ -2191,12 +2191,14 @@ return; } - case tok::kw__ExtInt: { + case tok::kw__ExtInt: + case tok::kw__BitInt: { + DiagnoseBitIntUse(Tok); ExprResult ER = ParseExtIntegerArgument(); if (ER.isInvalid()) DS.SetTypeSpecError(); else - DS.SetExtIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); + DS.SetBitIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); // Do this here because we have already consumed the close paren. DS.SetRangeEnd(PrevTokLocation); Index: clang/lib/Parse/ParseTentative.cpp =================================================================== --- clang/lib/Parse/ParseTentative.cpp +++ clang/lib/Parse/ParseTentative.cpp @@ -1690,6 +1690,7 @@ case tok::kw__Atomic: return TPResult::True; + case tok::kw__BitInt: case tok::kw__ExtInt: { if (NextToken().isNot(tok::l_paren)) return TPResult::Error; @@ -1741,6 +1742,7 @@ case tok::kw_short: case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_long: case tok::kw___int64: case tok::kw___int128: Index: clang/lib/Sema/DeclSpec.cpp =================================================================== --- clang/lib/Sema/DeclSpec.cpp +++ clang/lib/Sema/DeclSpec.cpp @@ -365,7 +365,7 @@ case TST_half: case TST_int: case TST_int128: - case TST_extint: + case TST_bitint: case TST_struct: case TST_interface: case TST_union: @@ -551,7 +551,7 @@ case DeclSpec::TST_char32: return "char32_t"; case DeclSpec::TST_int: return "int"; case DeclSpec::TST_int128: return "__int128"; - case DeclSpec::TST_extint: return "_ExtInt"; + case DeclSpec::TST_bitint: return "_BitInt"; case DeclSpec::TST_half: return "half"; case DeclSpec::TST_float: return "float"; case DeclSpec::TST_double: return "double"; @@ -932,7 +932,7 @@ return false; } -bool DeclSpec::SetExtIntType(SourceLocation KWLoc, Expr *BitsExpr, +bool DeclSpec::SetBitIntType(SourceLocation KWLoc, Expr *BitsExpr, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy) { assert(BitsExpr && "no expression provided!"); @@ -945,7 +945,7 @@ return true; } - TypeSpecType = TST_extint; + TypeSpecType = TST_bitint; ExprRep = BitsExpr; TSTLoc = KWLoc; TSTNameLoc = KWLoc; @@ -1252,7 +1252,7 @@ TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int. else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 && TypeSpecType != TST_char && TypeSpecType != TST_wchar && - !IsFixedPointType && TypeSpecType != TST_extint) { + !IsFixedPointType && TypeSpecType != TST_bitint) { S.Diag(TSSLoc, diag::err_invalid_sign_spec) << getSpecifierName((TST)TypeSpecType, Policy); // signed double -> double. @@ -1302,7 +1302,7 @@ " double"); TypeSpecType = TST_double; // _Complex -> _Complex double. } else if (TypeSpecType == TST_int || TypeSpecType == TST_char || - TypeSpecType == TST_extint) { + TypeSpecType == TST_bitint) { // Note that this intentionally doesn't include _Complex _Bool. if (!S.getLangOpts().CPlusPlus) S.Diag(TSTLoc, diag::ext_integer_complex); Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -1884,8 +1884,8 @@ if (Ty->isDependentType()) return; - if (Ty->isExtIntType()) { - if (!Context.getTargetInfo().hasExtIntType()) { + if (Ty->isBitIntType()) { + if (!Context.getTargetInfo().hasBitIntType()) { PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type); if (D) PD << D; Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -325,17 +325,17 @@ } } - // Disallow signed ExtIntType args larger than 128 bits to mul function until - // we improve backend support. + // Disallow signed bit-precise integer args larger than 128 bits to mul + // function until we improve backend support. if (BuiltinID == Builtin::BI__builtin_mul_overflow) { for (unsigned I = 0; I < 3; ++I) { const auto Arg = TheCall->getArg(I); // Third argument will be a pointer. auto Ty = I < 2 ? Arg->getType() : Arg->getType()->getPointeeType(); - if (Ty->isExtIntType() && Ty->isSignedIntegerType() && + if (Ty->isBitIntType() && Ty->isSignedIntegerType() && S.getASTContext().getIntWidth(Ty) > 128) return S.Diag(Arg->getBeginLoc(), - diag::err_overflow_builtin_ext_int_max_size) + diag::err_overflow_builtin_bit_int_max_size) << 128; } } @@ -5782,8 +5782,8 @@ ? 0 : 1); - if (ValType->isExtIntType()) { - Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_ext_int_prohibit); + if (ValType->isBitIntType()) { + Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_bit_int_prohibit); return ExprError(); } @@ -6180,11 +6180,11 @@ // gracefully. TheCall->setType(ResultType); - // Prohibit use of _ExtInt with atomic builtins. - // The arguments would have already been converted to the first argument's - // type, so only need to check the first argument. - const auto *ExtIntValType = ValType->getAs(); - if (ExtIntValType && !llvm::isPowerOf2_64(ExtIntValType->getNumBits())) { + // Prohibit problematic uses of bit-precise integer types with atomic + // builtins. The arguments would have already been converted to the first + // argument's type, so only need to check the first argument. + const auto *BitIntValType = ValType->getAs(); + if (BitIntValType && !llvm::isPowerOf2_64(BitIntValType->getNumBits())) { Diag(FirstArg->getExprLoc(), diag::err_atomic_builtin_ext_int_size); return ExprError(); } @@ -11212,7 +11212,7 @@ false/*NonNegative*/); } - if (const auto *EIT = dyn_cast(T)) + if (const auto *EIT = dyn_cast(T)) return IntRange(EIT->getNumBits(), EIT->isUnsigned()); const BuiltinType *BT = cast(T); @@ -11238,7 +11238,7 @@ if (const EnumType *ET = dyn_cast(T)) T = C.getCanonicalType(ET->getDecl()->getIntegerType()).getTypePtr(); - if (const auto *EIT = dyn_cast(T)) + if (const auto *EIT = dyn_cast(T)) return IntRange(EIT->getNumBits(), EIT->isUnsigned()); const BuiltinType *BT = cast(T); Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -15290,7 +15290,7 @@ if (BT->isInteger()) return false; - if (T->isExtIntType()) + if (T->isBitIntType()) return false; return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T; Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -4371,7 +4371,7 @@ return; } bool IntegralOrAnyEnumType = (OldElemTy->isIntegralOrEnumerationType() && - !OldElemTy->isExtIntType()) || + !OldElemTy->isBitIntType()) || OldElemTy->getAs(); if (!OldElemTy->getAs() && !OldElemTy->isComplexType() && Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -4385,7 +4385,7 @@ case Type::ObjCObjectPointer: case Type::ObjCTypeParam: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: llvm_unreachable("type class is never variably-modified!"); case Type::Adjusted: T = cast(Ty)->getOriginalType(); @@ -8389,9 +8389,10 @@ // If both operands have arithmetic type, do the usual arithmetic conversions // to find a common type: C99 6.5.15p3,5. if (LHSTy->isArithmeticType() && RHSTy->isArithmeticType()) { - // Disallow invalid arithmetic conversions, such as those between ExtInts of - // different sizes, or between ExtInts and other types. - if (ResTy.isNull() && (LHSTy->isExtIntType() || RHSTy->isExtIntType())) { + // Disallow invalid arithmetic conversions, such as those between bit- + // precise integers types of different sizes, or between a bit-precise + // integer and another type. + if (ResTy.isNull() && (LHSTy->isBitIntType() || RHSTy->isBitIntType())) { Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); @@ -10975,7 +10976,7 @@ QualType LHSExprType = LHS.get()->getType(); uint64_t LeftSize = S.Context.getTypeSize(LHSExprType); - if (LHSExprType->isExtIntType()) + if (LHSExprType->isBitIntType()) LeftSize = S.Context.getIntWidth(LHSExprType); else if (LHSExprType->isFixedPointType()) { auto FXSema = S.Context.getFixedPointSemantics(LHSExprType); Index: clang/lib/Sema/SemaLookup.cpp =================================================================== --- clang/lib/Sema/SemaLookup.cpp +++ clang/lib/Sema/SemaLookup.cpp @@ -2935,7 +2935,7 @@ case Type::ExtVector: case Type::ConstantMatrix: case Type::Complex: - case Type::ExtInt: + case Type::BitInt: break; // Non-deduced auto types only get here for error cases. Index: clang/lib/Sema/SemaStmtAsm.cpp =================================================================== --- clang/lib/Sema/SemaStmtAsm.cpp +++ clang/lib/Sema/SemaStmtAsm.cpp @@ -296,9 +296,9 @@ checkExprMemoryConstraintCompat(*this, OutputExpr, Info, false)) return StmtError(); - // Disallow _ExtInt, since the backends tend to have difficulties with - // non-normal sizes. - if (OutputExpr->getType()->isExtIntType()) + // Disallow bit-precise integer types, since the backends tend to have + // difficulties with abnormal sizes. + if (OutputExpr->getType()->isBitIntType()) return StmtError( Diag(OutputExpr->getBeginLoc(), diag::err_asm_invalid_type) << OutputExpr->getType() << 0 /*Input*/ @@ -429,7 +429,7 @@ } } - if (InputExpr->getType()->isExtIntType()) + if (InputExpr->getType()->isBitIntType()) return StmtError( Diag(InputExpr->getBeginLoc(), diag::err_asm_invalid_type) << InputExpr->getType() << 1 /*Output*/ @@ -924,7 +924,7 @@ setFunctionHasBranchProtectedScope(); for (uint64_t I = 0; I < NumOutputs + NumInputs; ++I) { - if (Exprs[I]->getType()->isExtIntType()) + if (Exprs[I]->getType()->isBitIntType()) return StmtError( Diag(Exprs[I]->getBeginLoc(), diag::err_asm_invalid_type) << Exprs[I]->getType() << (I < NumOutputs) Index: clang/lib/Sema/SemaTemplate.cpp =================================================================== --- clang/lib/Sema/SemaTemplate.cpp +++ clang/lib/Sema/SemaTemplate.cpp @@ -6143,12 +6143,12 @@ return false; } -bool UnnamedLocalNoLinkageFinder::VisitExtIntType(const ExtIntType *T) { +bool UnnamedLocalNoLinkageFinder::VisitBitIntType(const BitIntType *T) { return false; } -bool UnnamedLocalNoLinkageFinder::VisitDependentExtIntType( - const DependentExtIntType *T) { +bool UnnamedLocalNoLinkageFinder::VisitDependentBitIntType( + const DependentBitIntType *T) { return false; } @@ -7090,7 +7090,7 @@ QualType IntegerType = ParamType; if (const EnumType *Enum = IntegerType->getAs()) IntegerType = Enum->getDecl()->getIntegerType(); - Value = Value.extOrTrunc(IntegerType->isExtIntType() + Value = Value.extOrTrunc(IntegerType->isBitIntType() ? Context.getIntWidth(IntegerType) : Context.getTypeSize(IntegerType)); @@ -7185,7 +7185,7 @@ // Coerce the template argument's value to the value it will have // based on the template parameter's type. - unsigned AllowedBits = IntegerType->isExtIntType() + unsigned AllowedBits = IntegerType->isBitIntType() ? Context.getIntWidth(IntegerType) : Context.getTypeSize(IntegerType); if (Value.getBitWidth() != AllowedBits) Index: clang/lib/Sema/SemaTemplateDeduction.cpp =================================================================== --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1636,7 +1636,7 @@ case Type::ObjCObject: case Type::ObjCInterface: case Type::ObjCObjectPointer: - case Type::ExtInt: + case Type::BitInt: if (TDF & TDF_SkipNonDependent) return Sema::TDK_Success; @@ -2259,10 +2259,10 @@ return Sema::TDK_NonDeducedMismatch; } - case Type::DependentExtInt: { - const auto *IntParam = cast(Param); + case Type::DependentBitInt: { + const auto *IntParam = cast(Param); - if (const auto *IntArg = dyn_cast(Arg)){ + if (const auto *IntArg = dyn_cast(Arg)) { if (IntParam->isUnsigned() != IntArg->isUnsigned()) return Sema::TDK_NonDeducedMismatch; @@ -2279,7 +2279,7 @@ Deduced); } - if (const auto *IntArg = dyn_cast(Arg)) { + if (const auto *IntArg = dyn_cast(Arg)) { if (IntParam->isUnsigned() != IntArg->isUnsigned()) return Sema::TDK_NonDeducedMismatch; return Sema::TDK_Success; @@ -6089,9 +6089,9 @@ cast(T)->getDeducedType(), OnlyDeduced, Depth, Used); break; - case Type::DependentExtInt: + case Type::DependentBitInt: MarkUsedTemplateParameters(Ctx, - cast(T)->getNumBitsExpr(), + cast(T)->getNumBitsExpr(), OnlyDeduced, Depth, Used); break; @@ -6106,7 +6106,7 @@ case Type::ObjCObjectPointer: case Type::UnresolvedUsing: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: #define TYPE(Class, Base) #define ABSTRACT_TYPE(Class, Base) #define DEPENDENT_TYPE(Class, Base) Index: clang/lib/Sema/SemaTemplateVariadic.cpp =================================================================== --- clang/lib/Sema/SemaTemplateVariadic.cpp +++ clang/lib/Sema/SemaTemplateVariadic.cpp @@ -871,7 +871,7 @@ case TST_typeofExpr: case TST_decltype: - case TST_extint: + case TST_bitint: if (DS.getRepAsExpr() && DS.getRepAsExpr()->containsUnexpandedParameterPack()) return true; Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -1435,12 +1435,11 @@ } break; } - case DeclSpec::TST_extint: { - if (!S.Context.getTargetInfo().hasExtIntType()) - S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) - << "_ExtInt"; + case DeclSpec::TST_bitint: { + if (!S.Context.getTargetInfo().hasBitIntType()) + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "_BitInt"; Result = - S.BuildExtIntType(DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned, + S.BuildBitIntType(DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned, DS.getRepAsExpr(), DS.getBeginLoc()); if (Result.isNull()) { Result = Context.IntTy; @@ -2237,7 +2236,7 @@ return Context.getWritePipeType(T); } -/// Build a extended int type. +/// Build a bit-precise integer type. /// /// \param IsUnsigned Boolean representing the signedness of the type. /// @@ -2245,10 +2244,10 @@ /// that. /// /// \param Loc Location of the keyword. -QualType Sema::BuildExtIntType(bool IsUnsigned, Expr *BitWidth, +QualType Sema::BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc) { if (BitWidth->isInstantiationDependent()) - return Context.getDependentExtIntType(IsUnsigned, BitWidth); + return Context.getDependentBitIntType(IsUnsigned, BitWidth); llvm::APSInt Bits(32); ExprResult ICE = @@ -2259,22 +2258,22 @@ int64_t NumBits = Bits.getSExtValue(); if (!IsUnsigned && NumBits < 2) { - Diag(Loc, diag::err_ext_int_bad_size) << 0; + Diag(Loc, diag::err_bit_int_bad_size) << 0; return QualType(); } if (IsUnsigned && NumBits < 1) { - Diag(Loc, diag::err_ext_int_bad_size) << 1; + Diag(Loc, diag::err_bit_int_bad_size) << 1; return QualType(); } if (NumBits > llvm::IntegerType::MAX_INT_BITS) { - Diag(Loc, diag::err_ext_int_max_size) << IsUnsigned - << llvm::IntegerType::MAX_INT_BITS; + Diag(Loc, diag::err_bit_int_max_size) + << IsUnsigned << llvm::IntegerType::MAX_INT_BITS; return QualType(); } - return Context.getExtIntType(IsUnsigned, NumBits); + return Context.getBitIntType(IsUnsigned, NumBits); } /// Check whether the specified array bound can be evaluated using the relevant @@ -6074,11 +6073,11 @@ TL.getValueLoc().initializeFullCopy(TInfo->getTypeLoc()); } - void VisitExtIntTypeLoc(ExtIntTypeLoc TL) { + void VisitExtIntTypeLoc(BitIntTypeLoc TL) { TL.setNameLoc(DS.getTypeSpecTypeLoc()); } - void VisitDependentExtIntTypeLoc(DependentExtIntTypeLoc TL) { + void VisitDependentExtIntTypeLoc(DependentBitIntTypeLoc TL) { TL.setNameLoc(DS.getTypeSpecTypeLoc()); } @@ -6208,7 +6207,7 @@ assert(Chunk.Kind == DeclaratorChunk::Pipe); TL.setKWLoc(Chunk.Loc); } - void VisitExtIntTypeLoc(ExtIntTypeLoc TL) { + void VisitBitIntTypeLoc(BitIntTypeLoc TL) { TL.setNameLoc(Chunk.Loc); } void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) { @@ -9047,9 +9046,8 @@ else if (!T.isTriviallyCopyableType(Context)) // Some other non-trivially-copyable type (probably a C++ class) DisallowedKind = 7; - else if (T->isExtIntType()) { - DisallowedKind = 8; - } + else if (T->isBitIntType()) + DisallowedKind = 8; if (DisallowedKind != -1) { Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T; Index: clang/lib/Sema/TreeTransform.h =================================================================== --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -1195,12 +1195,12 @@ QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, bool isReadPipe); - /// Build an extended int given its value type. - QualType RebuildExtIntType(bool IsUnsigned, unsigned NumBits, + /// Build a bit-precise int given its value type. + QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc); - /// Build a dependent extended int given its value type. - QualType RebuildDependentExtIntType(bool IsUnsigned, Expr *NumBitsExpr, + /// Build a dependent bit-precise int given its value type. + QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc); /// Build a new template name given a nested name specifier, a flag @@ -6405,27 +6405,27 @@ } template -QualType TreeTransform::TransformExtIntType(TypeLocBuilder &TLB, - ExtIntTypeLoc TL) { - const ExtIntType *EIT = TL.getTypePtr(); +QualType TreeTransform::TransformBitIntType(TypeLocBuilder &TLB, + BitIntTypeLoc TL) { + const BitIntType *EIT = TL.getTypePtr(); QualType Result = TL.getType(); if (getDerived().AlwaysRebuild()) { - Result = getDerived().RebuildExtIntType(EIT->isUnsigned(), + Result = getDerived().RebuildBitIntType(EIT->isUnsigned(), EIT->getNumBits(), TL.getNameLoc()); if (Result.isNull()) return QualType(); } - ExtIntTypeLoc NewTL = TLB.push(Result); + BitIntTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); return Result; } template -QualType TreeTransform::TransformDependentExtIntType( - TypeLocBuilder &TLB, DependentExtIntTypeLoc TL) { - const DependentExtIntType *EIT = TL.getTypePtr(); +QualType TreeTransform::TransformDependentBitIntType( + TypeLocBuilder &TLB, DependentBitIntTypeLoc TL) { + const DependentBitIntType *EIT = TL.getTypePtr(); EnterExpressionEvaluationContext Unevaluated( SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); @@ -6438,18 +6438,18 @@ QualType Result = TL.getType(); if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) { - Result = getDerived().RebuildDependentExtIntType( + Result = getDerived().RebuildDependentBitIntType( EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc()); if (Result.isNull()) return QualType(); } - if (isa(Result)) { - DependentExtIntTypeLoc NewTL = TLB.push(Result); + if (isa(Result)) { + DependentBitIntTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); } else { - ExtIntTypeLoc NewTL = TLB.push(Result); + BitIntTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); } return Result; @@ -14496,20 +14496,20 @@ } template -QualType TreeTransform::RebuildExtIntType(bool IsUnsigned, +QualType TreeTransform::RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc) { llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy), NumBits, true); IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP, SemaRef.Context.IntTy, Loc); - return SemaRef.BuildExtIntType(IsUnsigned, Bits, Loc); + return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc); } template -QualType TreeTransform::RebuildDependentExtIntType( +QualType TreeTransform::RebuildDependentBitIntType( bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) { - return SemaRef.BuildExtIntType(IsUnsigned, NumBitsExpr, Loc); + return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc); } template Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -6772,11 +6772,11 @@ TL.setKWLoc(readSourceLocation()); } -void TypeLocReader::VisitExtIntTypeLoc(clang::ExtIntTypeLoc TL) { +void TypeLocReader::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) { TL.setNameLoc(readSourceLocation()); } -void TypeLocReader::VisitDependentExtIntTypeLoc( - clang::DependentExtIntTypeLoc TL) { +void TypeLocReader::VisitDependentBitIntTypeLoc( + clang::DependentBitIntTypeLoc TL) { TL.setNameLoc(readSourceLocation()); } Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -509,11 +509,11 @@ Record.AddSourceLocation(TL.getKWLoc()); } -void TypeLocWriter::VisitExtIntTypeLoc(clang::ExtIntTypeLoc TL) { +void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } -void TypeLocWriter::VisitDependentExtIntTypeLoc( - clang::DependentExtIntTypeLoc TL) { +void TypeLocWriter::VisitDependentBitIntTypeLoc( + clang::DependentBitIntTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } Index: clang/test/CXX/temp/temp.param/p7.cpp =================================================================== --- clang/test/CXX/temp/temp.param/p7.cpp +++ clang/test/CXX/temp/temp.param/p7.cpp @@ -30,7 +30,7 @@ // arbitrary scalar types; we generally include complex types in that list template<_Complex float ci> struct ComplexFloat; // cxx17-error {{cannot have type '_Complex float' before C++20}} template<_Complex int ci> struct ComplexInt; // cxx17-error {{cannot have type '_Complex int' before C++20}} -template<_ExtInt(42) ei> struct ExtInt; +template<_BitInt(42) ei> struct ExtInt; // atomic types aren't scalar types template<_Atomic float ci> struct AtomicFloat; // expected-error {{cannot have type '_Atomic(float)'}} @@ -63,7 +63,7 @@ RRef &ref_to_bad = *ptr_to_bad; _Complex int ci; _Complex float cf; - _ExtInt(42) ei; + _BitInt(42) ei; VI4 vi4; VF4 vf4; }; Index: clang/test/CodeGen/attr-noundef.cpp =================================================================== --- clang/test/CodeGen/attr-noundef.cpp +++ clang/test/CodeGen/attr-noundef.cpp @@ -131,12 +131,12 @@ } void pass_npt(nullptr_t t) { } -_ExtInt(3) ret_extint() { +_BitInt(3) ret_BitInt() { return 0; } -void pass_extint(_ExtInt(3) e) { +void pass_BitInt(_BitInt(3) e) { } -void pass_large_extint(_ExtInt(127) e) { +void pass_large_BitInt(_BitInt(127) e) { } // Pointers to arrays/functions are always noundef @@ -153,10 +153,10 @@ // CHECK: [[DEFINE]] void @{{.*}}pass_npt{{.*}}(i8* % // TODO: for now, ExtInt is only noundef if it is sign/zero-extended -// CHECK-INTEL: [[DEFINE]] noundef signext i3 @{{.*}}ret_extint{{.*}}() -// CHECK-AARCH: [[DEFINE]] i3 @{{.*}}ret_extint{{.*}}() -// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_extint{{.*}}(i3 noundef signext % -// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_extint{{.*}}(i3 % -// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_large_extint{{.*}}(i64 %{{.*}}, i64 % -// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_large_extint{{.*}}(i127 % +// CHECK-INTEL: [[DEFINE]] noundef signext i3 @{{.*}}ret_BitInt{{.*}}() +// CHECK-AARCH: [[DEFINE]] i3 @{{.*}}ret_BitInt{{.*}}() +// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_BitInt{{.*}}(i3 noundef signext % +// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_BitInt{{.*}}(i3 % +// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_large_BitInt{{.*}}(i64 %{{.*}}, i64 % +// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_large_BitInt{{.*}}(i127 % } // namespace check_exotic Index: clang/test/CodeGen/builtins-overflow.c =================================================================== --- clang/test/CodeGen/builtins-overflow.c +++ clang/test/CodeGen/builtins-overflow.c @@ -41,7 +41,7 @@ return r; } -int test_add_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) { +int test_add_overflow_xint31_xint31_xint31(_BitInt(31) x, _BitInt(31) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_add_overflow_xint31_xint31_xint31({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.sadd.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}}) @@ -49,7 +49,7 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0 // CHECK: store i31 [[Q]], i31* // CHECK: br i1 [[C]] - _ExtInt(31) r; + _BitInt(31) r; if (__builtin_add_overflow(x, y, &r)) overflowed(); return r; @@ -83,7 +83,7 @@ return r; } -int test_sub_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) { +int test_sub_overflow_xint31_xint31_xint31(_BitInt(31) x, _BitInt(31) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_sub_overflow_xint31_xint31_xint31({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.ssub.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}}) @@ -91,7 +91,7 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0 // CHECK: store i31 [[Q]], i31* // CHECK: br i1 [[C]] - _ExtInt(31) r; + _BitInt(31) r; if (__builtin_sub_overflow(x, y, &r)) overflowed(); return r; @@ -170,7 +170,7 @@ return r; } -int test_mul_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) { +int test_mul_overflow_xint31_xint31_xint31(_BitInt(31) x, _BitInt(31) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint31_xint31_xint31({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.smul.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}}) @@ -178,13 +178,13 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0 // CHECK: store i31 [[Q]], i31* // CHECK: br i1 [[C]] - _ExtInt(31) r; + _BitInt(31) r; if (__builtin_mul_overflow(x, y, &r)) overflowed(); return r; } -int test_mul_overflow_xint127_xint127_xint127(_ExtInt(127) x, _ExtInt(127) y) { +int test_mul_overflow_xint127_xint127_xint127(_BitInt(127) x, _BitInt(127) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint127_xint127_xint127({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i127, i1 } @llvm.smul.with.overflow.i127(i127 %{{.+}}, i127 %{{.+}}) @@ -192,13 +192,13 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i127, i1 } [[S]], 0 // CHECK: store i127 [[Q]], i127* // CHECK: br i1 [[C]] - _ExtInt(127) r; + _BitInt(127) r; if (__builtin_mul_overflow(x, y, &r)) overflowed(); return r; } -int test_mul_overflow_xint128_xint128_xint128(_ExtInt(128) x, _ExtInt(128) y) { +int test_mul_overflow_xint128_xint128_xint128(_BitInt(128) x, _BitInt(128) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint128_xint128_xint128({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %{{.+}}, i128 %{{.+}}) @@ -206,7 +206,7 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i128, i1 } [[S]], 0 // CHECK: store i128 [[Q]], i128* // CHECK: br i1 [[C]] - _ExtInt(128) r; + _BitInt(128) r; if (__builtin_mul_overflow(x, y, &r)) overflowed(); return r; Index: clang/test/CodeGen/ext-int-cc.c =================================================================== --- clang/test/CodeGen/ext-int-cc.c +++ clang/test/CodeGen/ext-int-cc.c @@ -30,7 +30,7 @@ // Make sure 128 and 64 bit versions are passed like integers, and that >128 // is passed indirectly. -void ParamPassing(_ExtInt(129) a, _ExtInt(128) b, _ExtInt(64) c) {} +void ParamPassing(_BitInt(129) a, _BitInt(128) b, _BitInt(64) c) {} // LIN64: define{{.*}} void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}) // WIN64: define dso_local void @ParamPassing(i129* %{{.+}}, i128* %{{.+}}, i64 %{{.+}}) // LIN32: define{{.*}} void @ParamPassing(i129* %{{.+}}, i128* %{{.+}}, i64 %{{.+}}) @@ -59,7 +59,7 @@ // AARCH64DARWIN: define{{.*}} void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) // ARM: define{{.*}} arm_aapcscc void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128* byval(i128) align 8 %{{.+}}, i64 %{{.+}}) -void ParamPassing2(_ExtInt(129) a, _ExtInt(127) b, _ExtInt(63) c) {} +void ParamPassing2(_BitInt(129) a, _BitInt(127) b, _BitInt(63) c) {} // LIN64: define{{.*}} void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}) // WIN64: define dso_local void @ParamPassing2(i129* %{{.+}}, i127* %{{.+}}, i63 %{{.+}}) // LIN32: define{{.*}} void @ParamPassing2(i129* %{{.+}}, i127* %{{.+}}, i63 %{{.+}}) @@ -89,7 +89,7 @@ // ARM: define{{.*}} arm_aapcscc void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127* byval(i127) align 8 %{{.+}}, i63 %{{.+}}) // Make sure we follow the signext rules for promotable integer types. -void ParamPassing3(_ExtInt(15) a, _ExtInt(31) b) {} +void ParamPassing3(_BitInt(15) a, _BitInt(31) b) {} // LIN64: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) // WIN64: define dso_local void @ParamPassing3(i15 %{{.+}}, i31 %{{.+}}) // LIN32: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) @@ -118,7 +118,7 @@ // AARCH64DARWIN: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) // ARM: define{{.*}} arm_aapcscc void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) -_ExtInt(63) ReturnPassing(){} +_BitInt(63) ReturnPassing(){} // LIN64: define{{.*}} i64 @ReturnPassing( // WIN64: define dso_local i63 @ReturnPassing( // LIN32: define{{.*}} i63 @ReturnPassing( @@ -147,7 +147,7 @@ // AARCH64DARWIN: define{{.*}} i63 @ReturnPassing( // ARM: define{{.*}} arm_aapcscc i63 @ReturnPassing( -_ExtInt(64) ReturnPassing2(){} +_BitInt(64) ReturnPassing2(){} // LIN64: define{{.*}} i64 @ReturnPassing2( // WIN64: define dso_local i64 @ReturnPassing2( // LIN32: define{{.*}} i64 @ReturnPassing2( @@ -176,7 +176,7 @@ // AARCH64DARWIN: define{{.*}} i64 @ReturnPassing2( // ARM: define{{.*}} arm_aapcscc i64 @ReturnPassing2( -_ExtInt(127) ReturnPassing3(){} +_BitInt(127) ReturnPassing3(){} // LIN64: define{{.*}} { i64, i64 } @ReturnPassing3( // WIN64: define dso_local void @ReturnPassing3(i127* noalias sret // LIN32: define{{.*}} void @ReturnPassing3(i127* noalias sret @@ -207,7 +207,7 @@ // AARCH64DARWIN: define{{.*}} i127 @ReturnPassing3( // ARM: define{{.*}} arm_aapcscc void @ReturnPassing3(i127* noalias sret -_ExtInt(128) ReturnPassing4(){} +_BitInt(128) ReturnPassing4(){} // LIN64: define{{.*}} { i64, i64 } @ReturnPassing4( // WIN64: define dso_local void @ReturnPassing4(i128* noalias sret // LIN32: define{{.*}} void @ReturnPassing4(i128* noalias sret @@ -236,7 +236,7 @@ // AARCH64DARWIN: define{{.*}} i128 @ReturnPassing4( // ARM: define{{.*}} arm_aapcscc void @ReturnPassing4(i128* noalias sret -_ExtInt(129) ReturnPassing5(){} +_BitInt(129) ReturnPassing5(){} // LIN64: define{{.*}} void @ReturnPassing5(i129* noalias sret // WIN64: define dso_local void @ReturnPassing5(i129* noalias sret // LIN32: define{{.*}} void @ReturnPassing5(i129* noalias sret @@ -267,7 +267,7 @@ // SparcV9 is odd in that it has a return-size limit of 256, not 128 or 64 // like other platforms, so test to make sure this behavior will still work. -_ExtInt(256) ReturnPassing6() {} +_BitInt(256) ReturnPassing6() {} // SPARCV9: define{{.*}} i256 @ReturnPassing6( -_ExtInt(257) ReturnPassing7() {} +_BitInt(257) ReturnPassing7() {} // SPARCV9: define{{.*}} void @ReturnPassing7(i257* noalias sret Index: clang/test/CodeGen/ext-int-sanitizer.cpp =================================================================== --- clang/test/CodeGen/ext-int-sanitizer.cpp +++ clang/test/CodeGen/ext-int-sanitizer.cpp @@ -1,8 +1,8 @@ // RUN: %clang_cc1 -triple x86_64-gnu-linux -fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -// CHECK: define{{.*}} void @_Z6BoundsRA10_KiU7_ExtIntILi15EEi -void Bounds(const int (&Array)[10], _ExtInt(15) Index) { +// CHECK: define{{.*}} void @_Z6BoundsRA10_KiDB15_ +void Bounds(const int (&Array)[10], _BitInt(15) Index) { int I1 = Array[Index]; // CHECK: %[[SEXT:.+]] = sext i15 %{{.+}} to i64 // CHECK: %[[CMP:.+]] = icmp ult i64 %[[SEXT]], 10 @@ -19,17 +19,17 @@ enum E3 { e3a = (1u << 31) - 1 } e3; - _ExtInt(34) a = e1; + _BitInt(34) a = e1; // CHECK: %[[E1:.+]] = icmp ule i32 %{{.*}}, 127 // CHECK: br i1 %[[E1]] // CHECK: call void @__ubsan_handle_load_invalid_value_abort - _ExtInt(34) b = e2; + _BitInt(34) b = e2; // CHECK: %[[E2HI:.*]] = icmp sle i32 {{.*}}, 127 // CHECK: %[[E2LO:.*]] = icmp sge i32 {{.*}}, -128 // CHECK: %[[E2:.*]] = and i1 %[[E2HI]], %[[E2LO]] // CHECK: br i1 %[[E2]] // CHECK: call void @__ubsan_handle_load_invalid_value_abort - _ExtInt(34) c = e3; + _BitInt(34) c = e3; // CHECK: %[[E3:.*]] = icmp ule i32 {{.*}}, 2147483647 // CHECK: br i1 %[[E3]] // CHECK: call void @__ubsan_handle_load_invalid_value_abort @@ -37,22 +37,22 @@ // CHECK: define{{.*}} void @_Z13FloatOverflowfd void FloatOverflow(float f, double d) { - _ExtInt(10) E = f; + _BitInt(10) E = f; // CHECK: fcmp ogt float %{{.+}}, -5.130000e+02 // CHECK: fcmp olt float %{{.+}}, 5.120000e+02 - _ExtInt(10) E2 = d; + _BitInt(10) E2 = d; // CHECK: fcmp ogt double %{{.+}}, -5.130000e+02 // CHECK: fcmp olt double %{{.+}}, 5.120000e+02 - _ExtInt(7) E3 = f; + _BitInt(7) E3 = f; // CHECK: fcmp ogt float %{{.+}}, -6.500000e+01 // CHECK: fcmp olt float %{{.+}}, 6.400000e+01 - _ExtInt(7) E4 = d; + _BitInt(7) E4 = d; // CHECK: fcmp ogt double %{{.+}}, -6.500000e+01 // CHECK: fcmp olt double %{{.+}}, 6.400000e+01 } -// CHECK: define{{.*}} void @_Z14UIntTruncationU7_ExtIntILi35EEjjy -void UIntTruncation(unsigned _ExtInt(35) E, unsigned int i, unsigned long long ll) { +// CHECK: define{{.*}} void @_Z14UIntTruncationDU35_jy +void UIntTruncation(unsigned _BitInt(35) E, unsigned int i, unsigned long long ll) { i = E; // CHECK: %[[LOADE:.+]] = load i35 @@ -73,8 +73,8 @@ // CHECK: call void @__ubsan_handle_implicit_conversion_abort } -// CHECK: define{{.*}} void @_Z13IntTruncationU7_ExtIntILi35EEiU7_ExtIntILi42EEjij -void IntTruncation(_ExtInt(35) E, unsigned _ExtInt(42) UE, int i, unsigned j) { +// CHECK: define{{.*}} void @_Z13IntTruncationDB35_DU42_ij +void IntTruncation(_BitInt(35) E, unsigned _BitInt(42) UE, int i, unsigned j) { j = E; // CHECK: %[[LOADE:.+]] = load i35 @@ -119,8 +119,8 @@ // CHECK: call void @__ubsan_handle_implicit_conversion_abort } -// CHECK: define{{.*}} void @_Z15SignChangeCheckU7_ExtIntILi39EEjU7_ExtIntILi39EEi -void SignChangeCheck(unsigned _ExtInt(39) UE, _ExtInt(39) E) { +// CHECK: define{{.*}} void @_Z15SignChangeCheckDU39_DB39_ +void SignChangeCheck(unsigned _BitInt(39) UE, _BitInt(39) E) { UE = E; // CHECK: %[[LOADEU:.+]] = load i39 // CHECK: %[[LOADE:.+]] = load i39 @@ -140,8 +140,8 @@ // CHECK: call void @__ubsan_handle_implicit_conversion_abort } -// CHECK: define{{.*}} void @_Z9DivByZeroU7_ExtIntILi11EEii -void DivByZero(_ExtInt(11) E, int i) { +// CHECK: define{{.*}} void @_Z9DivByZeroDB11_i +void DivByZero(_BitInt(11) E, int i) { // Also triggers signed integer overflow. E / E; @@ -159,8 +159,8 @@ // TODO: //-fsanitize=shift: (shift-base, shift-exponent) Shift operators where the amount shifted is greater or equal to the promoted bit-width of the left hand side or less than zero, or where the left hand side is negative. For a signed left shift, also checks for signed overflow in C, and for unsigned overflow in C++. You can use -fsanitize=shift-base or -fsanitize=shift-exponent to check only left-hand side or right-hand side of shift operation, respectively. -// CHECK: define{{.*}} void @_Z6ShiftsU7_ExtIntILi9EEi -void Shifts(_ExtInt(9) E) { +// CHECK: define{{.*}} void @_Z6ShiftsDB9_ +void Shifts(_BitInt(9) E) { E >> E; // CHECK: %[[EADDR:.+]] = alloca i9 // CHECK: %[[LHSE:.+]] = load i9, i9* %[[EADDR]] @@ -183,10 +183,10 @@ // CHECK: call void @__ubsan_handle_shift_out_of_bounds_abort } -// CHECK: define{{.*}} void @_Z21SignedIntegerOverflowU7_ExtIntILi93EEiU7_ExtIntILi4EEiU7_ExtIntILi31EEi -void SignedIntegerOverflow(_ExtInt(93) BiggestE, - _ExtInt(4) SmallestE, - _ExtInt(31) JustRightE) { +// CHECK: define{{.*}} void @_Z21SignedIntegerOverflowDB93_DB4_DB31_ +void SignedIntegerOverflow(_BitInt(93) BiggestE, + _BitInt(4) SmallestE, + _BitInt(31) JustRightE) { BiggestE + BiggestE; // CHECK: %[[LOADBIGGESTE2:.+]] = load i93 // CHECK: store i93 %[[LOADBIGGESTE2]], i93* %[[BIGGESTEADDR:.+]] @@ -220,10 +220,10 @@ // CHECK: call void @__ubsan_handle_mul_overflow_abort } -// CHECK: define{{.*}} void @_Z23UnsignedIntegerOverflowjU7_ExtIntILi23EEjU7_ExtIntILi35EEj +// CHECK: define{{.*}} void @_Z23UnsignedIntegerOverflowjDU23_DU35_ void UnsignedIntegerOverflow(unsigned u, - unsigned _ExtInt(23) SmallE, - unsigned _ExtInt(35) BigE) { + unsigned _BitInt(23) SmallE, + unsigned _BitInt(35) BigE) { u = SmallE + SmallE; // CHECK: %[[BIGGESTEADDR:.+]] = alloca i23 // CHECK: %[[LOADE1:.+]] = load i23, i23* %[[BIGGESTEADDR]] Index: clang/test/CodeGen/ext-int.c =================================================================== --- clang/test/CodeGen/ext-int.c +++ clang/test/CodeGen/ext-int.c @@ -3,17 +3,17 @@ // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN32 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN32 -void GenericTest(_ExtInt(3) a, unsigned _ExtInt(3) b, _ExtInt(4) c) { +void GenericTest(_BitInt(3) a, unsigned _BitInt(3) b, _BitInt(4) c) { // CHECK: define {{.*}}void @GenericTest - int which = _Generic(a, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3); + int which = _Generic(a, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); // CHECK: store i32 1 - int which2 = _Generic(b, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3); + int which2 = _Generic(b, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); // CHECK: store i32 2 - int which3 = _Generic(c, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3); + int which3 = _Generic(c, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); // CHECK: store i32 3 } -void VLATest(_ExtInt(3) A, _ExtInt(99) B, _ExtInt(123456) C) { +void VLATest(_BitInt(3) A, _BitInt(99) B, _BitInt(123456) C) { // CHECK: define {{.*}}void @VLATest int AR1[A]; // CHECK: %[[A:.+]] = zext i3 %{{.+}} to i[[INDXSIZE:[0-9]+]] @@ -27,9 +27,9 @@ } struct S { - _ExtInt(17) A; - _ExtInt(8388600) B; - _ExtInt(17) C; + _BitInt(17) A; + _BitInt(8388600) B; + _BitInt(17) C; }; void OffsetOfTest() { @@ -46,12 +46,12 @@ // WIN32: store i32 1048584, i32* %{{.+}} } -void Size1ExtIntParam(unsigned _ExtInt(1) A) { +void Size1ExtIntParam(unsigned _BitInt(1) A) { // CHECK: define {{.*}}void @Size1ExtIntParam(i1{{.*}} %[[PARAM:.+]]) // CHECK: %[[PARAM_ADDR:.+]] = alloca i1 // CHECK: %[[B:.+]] = alloca [5 x i1] // CHECK: store i1 %[[PARAM]], i1* %[[PARAM_ADDR]] - unsigned _ExtInt(1) B[5]; + unsigned _BitInt(1) B[5]; // CHECK: %[[PARAM_LOAD:.+]] = load i1, i1* %[[PARAM_ADDR]] // CHECK: %[[IDX:.+]] = getelementptr inbounds [5 x i1], [5 x i1]* %[[B]] Index: clang/test/CodeGen/extend-arg-64.c =================================================================== --- clang/test/CodeGen/extend-arg-64.c +++ clang/test/CodeGen/extend-arg-64.c @@ -32,7 +32,7 @@ unsigned char u8; signed char s8; long long ll; -_ExtInt(23) ei23; +_BitInt(23) ei23; float ff; double dd; #ifdef D128 Index: clang/test/CodeGenCXX/ext-int.cpp =================================================================== --- clang/test/CodeGenCXX/ext-int.cpp +++ clang/test/CodeGenCXX/ext-int.cpp @@ -9,54 +9,54 @@ // Ensure that the layout for these structs is the same as the normal bitfield // layouts. struct BitFieldsByte { - _ExtInt(7) A : 3; - _ExtInt(7) B : 3; - _ExtInt(7) C : 2; + _BitInt(7) A : 3; + _BitInt(7) B : 3; + _BitInt(7) C : 2; }; // CHECK: %struct.BitFieldsByte = type { i8 } struct BitFieldsShort { - _ExtInt(15) A : 3; - _ExtInt(15) B : 3; - _ExtInt(15) C : 2; + _BitInt(15) A : 3; + _BitInt(15) B : 3; + _BitInt(15) C : 2; }; // LIN: %struct.BitFieldsShort = type { i8, i8 } // WIN: %struct.BitFieldsShort = type { i16 } struct BitFieldsInt { - _ExtInt(31) A : 3; - _ExtInt(31) B : 3; - _ExtInt(31) C : 2; + _BitInt(31) A : 3; + _BitInt(31) B : 3; + _BitInt(31) C : 2; }; // LIN: %struct.BitFieldsInt = type { i8, [3 x i8] } // WIN: %struct.BitFieldsInt = type { i32 } struct BitFieldsLong { - _ExtInt(63) A : 3; - _ExtInt(63) B : 3; - _ExtInt(63) C : 2; + _BitInt(63) A : 3; + _BitInt(63) B : 3; + _BitInt(63) C : 2; }; // LIN: %struct.BitFieldsLong = type { i8, [7 x i8] } // WIN: %struct.BitFieldsLong = type { i64 } -struct HasExtIntFirst { - _ExtInt(35) A; +struct HasBitIntFirst { + _BitInt(35) A; int B; }; -// CHECK: %struct.HasExtIntFirst = type { i35, i32 } +// CHECK: %struct.HasBitIntFirst = type { i35, i32 } -struct HasExtIntLast { +struct HasBitIntLast { int A; - _ExtInt(35) B; + _BitInt(35) B; }; -// CHECK: %struct.HasExtIntLast = type { i32, i35 } +// CHECK: %struct.HasBitIntLast = type { i32, i35 } -struct HasExtIntMiddle { +struct HasBitIntMiddle { int A; - _ExtInt(35) B; + _BitInt(35) B; int C; }; -// CHECK: %struct.HasExtIntMiddle = type { i32, i35, i32 } +// CHECK: %struct.HasBitIntMiddle = type { i32, i35, i32 } // Force emitting of the above structs. void StructEmit() { @@ -65,9 +65,9 @@ BitFieldsInt C; BitFieldsLong D; - HasExtIntFirst E; - HasExtIntLast F; - HasExtIntMiddle G; + HasBitIntFirst E; + HasBitIntLast F; + HasBitIntMiddle G; } void BitfieldAssignment() { @@ -93,7 +93,7 @@ // CHECK: %[[SETC:.+]] = or i8 %[[CLEARC]], 64 } -enum AsEnumUnderlyingType : _ExtInt(9) { +enum AsEnumUnderlyingType : _BitInt(9) { A,B,C }; @@ -105,37 +105,43 @@ // CHECK: store i9 %{{.*}}, align 2 } -unsigned _ExtInt(33) ManglingTestRetParam(unsigned _ExtInt(33) Param) { -// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i64 % -// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UExtInt@$0CB@@__clang@@U12@@Z"(i33 +unsigned _BitInt(33) ManglingTestRetParam(unsigned _BitInt(33) Param) { +// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamDU33_(i64 % +// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UBitInt@$0CB@@__clang@@U12@@Z"(i33 return 0; } -_ExtInt(33) ManglingTestRetParam(_ExtInt(33) Param) { -// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i64 % -// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_ExtInt@$0CB@@__clang@@U12@@Z"(i33 +_BitInt(33) ManglingTestRetParam(_BitInt(33) Param) { +// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamDB33_(i64 % +// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_BitInt@$0CB@@__clang@@U12@@Z"(i33 return 0; } template void ManglingTestTemplateParam(T&); -template<_ExtInt(99) T> +template<_BitInt(99) T> void ManglingTestNTTP(); +template +auto ManglingDependent() -> decltype(_BitInt(N){}); + void ManglingInstantiator() { // LIN: define{{.*}} void @_Z20ManglingInstantiatorv() // WIN: define dso_local void @"?ManglingInstantiator@@YAXXZ"() - _ExtInt(93) A; + _BitInt(93) A; ManglingTestTemplateParam(A); -// LIN: call void @_Z25ManglingTestTemplateParamIU7_ExtIntILi93EEiEvRT_(i93* -// WIN: call void @"??$ManglingTestTemplateParam@U?$_ExtInt@$0FN@@__clang@@@@YAXAEAU?$_ExtInt@$0FN@@__clang@@@Z"(i93* - constexpr _ExtInt(93) B = 993; + // LIN: call void @_Z25ManglingTestTemplateParamIDB93_EvRT_(i93* + // WIN: call void @"??$ManglingTestTemplateParam@U?$_BitInt@$0FN@@__clang@@@@YAXAEAU?$_BitInt@$0FN@@__clang@@@Z"(i93* + constexpr _BitInt(93) B = 993; ManglingTestNTTP<38>(); -// LIN: call void @_Z16ManglingTestNTTPILU7_ExtIntILi99EEi38EEvv() -// WIN: call void @"??$ManglingTestNTTP@$0CG@@@YAXXZ"() + // LIN: call void @_Z16ManglingTestNTTPILDB99_38EEvv() + // WIN: call void @"??$ManglingTestNTTP@$0CG@@@YAXXZ"() ManglingTestNTTP(); -// LIN: call void @_Z16ManglingTestNTTPILU7_ExtIntILi99EEi993EEvv() -// WIN: call void @"??$ManglingTestNTTP@$0DOB@@@YAXXZ"() + // LIN: call void @_Z16ManglingTestNTTPILDB99_993EEvv() + // WIN: call void @"??$ManglingTestNTTP@$0DOB@@@YAXXZ"() + ManglingDependent<4>(); + // LIN: call signext i4 @_Z17ManglingDependentILi4EEDTtlDBT__EEv() + // WIN: call i4 @"??$ManglingDependent@$03@@YAU?$_BitInt@$03@__clang@@XZ"() } void TakesVarargs(int i, ...) { @@ -153,7 +159,7 @@ // WIN: %[[ARGSSTART:.+]] = bitcast i8** %[[ARGS]] to i8* // WIN: call void @llvm.va_start(i8* %[[ARGSSTART]]) - _ExtInt(92) A = __builtin_va_arg(args, _ExtInt(92)); + _BitInt(92) A = __builtin_va_arg(args, _BitInt(92)); // LIN: %[[AD1:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P1:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD1]], i32 0, i32 0 // LIN: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P1]] @@ -171,7 +177,7 @@ // WIN: %[[LOADV1:.+]] = load i92, i92* %[[LOADP1]] // WIN: store i92 %[[LOADV1]], i92* - _ExtInt(31) B = __builtin_va_arg(args, _ExtInt(31)); + _BitInt(31) B = __builtin_va_arg(args, _BitInt(31)); // LIN: %[[AD2:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P2:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD2]], i32 0, i32 0 // LIN: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P2]] @@ -188,7 +194,7 @@ // WIN: %[[LOADV2:.+]] = load i31, i31* %[[BC2]] // WIN: store i31 %[[LOADV2]], i31* - _ExtInt(16) C = __builtin_va_arg(args, _ExtInt(16)); + _BitInt(16) C = __builtin_va_arg(args, _BitInt(16)); // LIN: %[[AD3:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P3:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD3]], i32 0, i32 0 // LIN: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P3]] @@ -205,7 +211,7 @@ // WIN: %[[LOADV3:.+]] = load i16, i16* %[[BC3]] // WIN: store i16 %[[LOADV3]], i16* - _ExtInt(129) D = __builtin_va_arg(args, _ExtInt(129)); + _BitInt(129) D = __builtin_va_arg(args, _BitInt(129)); // LIN: %[[AD4:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P4:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD4]], i32 0, i32 2 // LIN: %[[OFA4:.+]] = load i8*, i8** %[[OFA_P4]] @@ -223,7 +229,7 @@ // WIN: %[[LOADV4:.+]] = load i129, i129* %[[LOADP4]] // WIN: store i129 %[[LOADV4]], i129* - _ExtInt(8388600) E = __builtin_va_arg(args, _ExtInt(8388600)); + _BitInt(8388600) E = __builtin_va_arg(args, _BitInt(8388600)); // LIN: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P5:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD5]], i32 0, i32 2 // LIN: %[[OFA5:.+]] = load i8*, i8** %[[OFA_P5]] @@ -251,36 +257,36 @@ void typeid_tests() { // LIN: define{{.*}} void @_Z12typeid_testsv() // WIN: define dso_local void @"?typeid_tests@@YAXXZ"() - unsigned _ExtInt(33) U33_1, U33_2; - _ExtInt(33) S33_1, S33_2; - _ExtInt(32) S32_1, S32_2; + unsigned _BitInt(33) U33_1, U33_2; + _BitInt(33) S33_1, S33_2; + _BitInt(32) S32_1, S32_2; auto A = typeid(U33_1); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDU33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UBitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto B = typeid(U33_2); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDU33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UBitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto C = typeid(S33_1); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto D = typeid(S33_2); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto E = typeid(S32_1); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB32_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) auto F = typeid(S32_2); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB32_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) } void ExplicitCasts() { // LIN: define{{.*}} void @_Z13ExplicitCastsv() // WIN: define dso_local void @"?ExplicitCasts@@YAXXZ"() - _ExtInt(33) a; - _ExtInt(31) b; + _BitInt(33) a; + _BitInt(31) b; int i; a = i; @@ -294,9 +300,9 @@ } struct S { - _ExtInt(17) A; - _ExtInt(8388600) B; - _ExtInt(17) C; + _BitInt(17) A; + _BitInt(8388600) B; + _BitInt(17) C; }; void OffsetOfTest() { @@ -312,9 +318,9 @@ } -void ShiftExtIntByConstant(_ExtInt(28) Ext) { -// LIN: define{{.*}} void @_Z21ShiftExtIntByConstantU7_ExtIntILi28EEi -// WIN: define dso_local void @"?ShiftExtIntByConstant@@YAXU?$_ExtInt@$0BM@@__clang@@@Z" +void ShiftBitIntByConstant(_BitInt(28) Ext) { +// LIN: define{{.*}} void @_Z21ShiftBitIntByConstantDB28_ +// WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXU?$_BitInt@$0BM@@__clang@@@Z" Ext << 7; // CHECK: shl i28 %{{.+}}, 7 Ext >> 7; @@ -331,9 +337,9 @@ // CHECK: ashr i28 %{{.+}}, 29 } -void ConstantShiftByExtInt(_ExtInt(28) Ext, _ExtInt(65) LargeExt) { - // LIN: define{{.*}} void @_Z21ConstantShiftByExtIntU7_ExtIntILi28EEiU7_ExtIntILi65EEi - // WIN: define dso_local void @"?ConstantShiftByExtInt@@YAXU?$_ExtInt@$0BM@@__clang@@U?$_ExtInt@$0EB@@2@@Z" +void ConstantShiftByBitInt(_BitInt(28) Ext, _BitInt(65) LargeExt) { + // LIN: define{{.*}} void @_Z21ConstantShiftByBitIntDB28_DB65_ + // WIN: define dso_local void @"?ConstantShiftByBitInt@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@@Z" 10 << Ext; // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 // CHECK: shl i32 10, %[[PROMO]] @@ -348,9 +354,9 @@ // CHECK: ashr i32 10, %[[PROMO]] } -void Shift(_ExtInt(28) Ext, _ExtInt(65) LargeExt, int i) { - // LIN: define{{.*}} void @_Z5ShiftU7_ExtIntILi28EEiU7_ExtIntILi65EEii - // WIN: define dso_local void @"?Shift@@YAXU?$_ExtInt@$0BM@@__clang@@U?$_ExtInt@$0EB@@2@H@Z" +void Shift(_BitInt(28) Ext, _BitInt(65) LargeExt, int i) { + // LIN: define{{.*}} void @_Z5ShiftDB28_DB65_ + // WIN: define dso_local void @"?Shift@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@H@Z" i << Ext; // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 // CHECK: shl i32 {{.+}}, %[[PROMO]] @@ -394,10 +400,9 @@ // CHECK: ashr i65 {{.+}}, %[[PROMO]] } -void ComplexTest(_Complex _ExtInt(12) first, - _Complex _ExtInt(33) second) { - // LIN: define{{.*}} void @_Z11ComplexTestCU7_ExtIntILi12EEiCU7_ExtIntILi33EEi - // WIN: define dso_local void @"?ComplexTest@@YAXU?$_Complex@U?$_ExtInt@$0M@@__clang@@@__clang@@U?$_Complex@U?$_ExtInt@$0CB@@__clang@@@2@@Z" +void ComplexTest(_Complex _BitInt(12) first, _Complex _BitInt(33) second) { + // LIN: define{{.*}} void @_Z11ComplexTestCDB12_CDB33_ + // WIN: define dso_local void @"?ComplexTest@@YAXU?$_Complex@U?$_BitInt@$0M@@__clang@@@__clang@@U?$_Complex@U?$_BitInt@$0CB@@__clang@@@2@@Z" first + second; // CHECK: %[[FIRST_REALP:.+]] = getelementptr inbounds { i12, i12 }, { i12, i12 }* %{{.+}}, i32 0, i32 0 // CHECK: %[[FIRST_REAL:.+]] = load i12, i12* %[[FIRST_REALP]] @@ -414,9 +419,9 @@ } // Ensure that these types don't alias the normal int types. -void TBAATest(_ExtInt(sizeof(int) * 8) ExtInt, - unsigned _ExtInt(sizeof(int) * 8) ExtUInt, - _ExtInt(6) Other) { +void TBAATest(_BitInt(sizeof(int) * 8) ExtInt, + unsigned _BitInt(sizeof(int) * 8) ExtUInt, + _BitInt(6) Other) { // CHECK-DAG: store i32 %{{.+}}, i32* %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA:.+]] // CHECK-DAG: store i32 %{{.+}}, i32* %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA]] // CHECK-DAG: store i6 %{{.+}}, i6* %{{.+}}, align 1, !tbaa ![[EXTINT6_TBAA:.+]] @@ -428,13 +433,13 @@ // NoNewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{!"omnipotent char", ![[TBAA_ROOT:.+]], i64 0} // NoNewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"} // NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0} -// NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{!"_ExtInt(32)", ![[CHAR_TBAA_ROOT]], i64 0} +// NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{!"_BitInt(32)", ![[CHAR_TBAA_ROOT]], i64 0} // NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0} -// NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{!"_ExtInt(6)", ![[CHAR_TBAA_ROOT]], i64 0} +// NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{!"_BitInt(6)", ![[CHAR_TBAA_ROOT]], i64 0} // NewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{![[TBAA_ROOT:.+]], i64 1, !"omnipotent char"} // NewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"} // NewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0, i64 4} -// NewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 4, !"_ExtInt(32)"} +// NewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 4, !"_BitInt(32)"} // NewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0, i64 1} -// NewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 1, !"_ExtInt(6)"} +// NewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 1, !"_BitInt(6)"} Index: clang/test/CodeGenOpenCL/ext-int-shift.cl =================================================================== --- clang/test/CodeGenOpenCL/ext-int-shift.cl +++ clang/test/CodeGenOpenCL/ext-int-shift.cl @@ -1,6 +1,6 @@ // RUN: %clang -cc1 -triple x86_64-linux-pc -O3 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -void Shifts(_ExtInt(12) E, int i) { +void Shifts(_BitInt(12) E, int i) { E << 99; // CHECK: shl i12 %{{.+}}, 3 Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp =================================================================== --- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp +++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp @@ -265,6 +265,6 @@ typedef typename A_type::type type; }; -void bar(_ExtInt(66) a) { +void bar(_BitInt(66) a) { auto b = a; } Index: clang/test/Parser/ext-int.cpp =================================================================== --- clang/test/Parser/ext-int.cpp +++ clang/test/Parser/ext-int.cpp @@ -5,11 +5,11 @@ // expected-error@+3{{expected unqualified-id}} // expected-error@+2{{extraneous closing brace}} // expected-error@+1{{C++ requires a type specifier for all declarations}} -_ExtInt(32} a; +_BitInt(32} a; // expected-error@+2{{expected expression}} // expected-error@+1{{C++ requires a type specifier for all declarations}} -_ExtInt(32* ) b; +_BitInt(32* ) b; // expected-error@+3{{expected '('}} // expected-error@+2{{expected unqualified-id}} // expected-error@+1{{C++ requires a type specifier for all declarations}} -_ExtInt{32} c; +_BitInt{32} c; Index: clang/test/Sema/builtins-overflow.c =================================================================== --- clang/test/Sema/builtins-overflow.c +++ clang/test/Sema/builtins-overflow.c @@ -21,21 +21,21 @@ __builtin_add_overflow(1, 1, &q); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('const unsigned int *' invalid)}} { - _ExtInt(128) x = 1; - _ExtInt(128) y = 1; - _ExtInt(128) result; + _BitInt(128) x = 1; + _BitInt(128) y = 1; + _BitInt(128) result; _Bool status = __builtin_mul_overflow(x, y, &result); // expect ok } { - unsigned _ExtInt(129) x = 1; - unsigned _ExtInt(129) y = 1; - unsigned _ExtInt(129) result; + unsigned _BitInt(129) x = 1; + unsigned _BitInt(129) y = 1; + unsigned _BitInt(129) result; _Bool status = __builtin_mul_overflow(x, y, &result); // expect ok } { - _ExtInt(129) x = 1; - _ExtInt(129) y = 1; - _ExtInt(129) result; - _Bool status = __builtin_mul_overflow(x, y, &result); // expected-error {{__builtin_mul_overflow does not support signed _ExtInt operands of more than 128 bits}} + _BitInt(129) x = 1; + _BitInt(129) y = 1; + _BitInt(129) result; + _Bool status = __builtin_mul_overflow(x, y, &result); // expected-error {{__builtin_mul_overflow does not support 'signed _BitInt' operands of more than 128 bits}} } } Index: clang/test/Sema/builtins.c =================================================================== --- clang/test/Sema/builtins.c +++ clang/test/Sema/builtins.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wstrlcpy-strlcat-size -Wno-string-plus-int -triple=i686-apple-darwin9 +// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wstrlcpy-strlcat-size -Wno-string-plus-int -Wno-bit-int-extension -triple=i686-apple-darwin9 // This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si int test1(float a, int b) { @@ -281,41 +281,41 @@ __atomic_fetch_add(ptr, 1, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}} } -void test_ei_i42i(_ExtInt(42) *ptr, int value) { +void test_ei_i42i(_BitInt(42) *ptr, int value) { __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} - __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}} + __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_BitInt' is not supported}} } -void test_ei_i64i(_ExtInt(64) *ptr, int value) { +void test_ei_i64i(_BitInt(64) *ptr, int value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success - __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}} + __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_BitInt' is not supported}} } -void test_ei_ii42(int *ptr, _ExtInt(42) value) { +void test_ei_ii42(int *ptr, _BitInt(42) value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success } -void test_ei_ii64(int *ptr, _ExtInt(64) value) { +void test_ei_ii64(int *ptr, _BitInt(64) value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success } -void test_ei_i42i42(_ExtInt(42) *ptr, _ExtInt(42) value) { +void test_ei_i42i42(_BitInt(42) *ptr, _BitInt(42) value) { __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} } -void test_ei_i64i64(_ExtInt(64) *ptr, _ExtInt(64) value) { +void test_ei_i64i64(_BitInt(64) *ptr, _BitInt(64) value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success Index: clang/test/Sema/ext-int.c =================================================================== --- clang/test/Sema/ext-int.c +++ clang/test/Sema/ext-int.c @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -Wimplicit-int-conversion -Wno-unused -triple x86_64-gnu-linux -typedef _ExtInt(31) EI31; +typedef _BitInt(31) EI31; -void Ternary(_ExtInt(30) s30, EI31 s31a, _ExtInt(31) s31b, - _ExtInt(32) s32, int b) { +void Ternary(_BitInt(30) s30, EI31 s31a, _BitInt(31) s31b, + _BitInt(32) s32, int b) { b ? s30 : s31a; b ? s31a : s30; b ? s32 : 0; @@ -12,42 +12,42 @@ } struct CursedBitField { - _ExtInt(4) A : 8; // expected-error {{width of bit-field 'A' (8 bits) exceeds the width of its type (4 bits)}} + _BitInt(4) A : 8; // expected-error {{width of bit-field 'A' (8 bits) exceeds the width of its type (4 bits)}} }; #define EXPR_HAS_TYPE(EXPR, TYPE) _Generic((EXPR), default : 0, TYPE : 1) void Ops(void) { - _ExtInt(4) x4_s = 1; - _ExtInt(32) x32_s = 1; - _ExtInt(43) x43_s = 1; - unsigned _ExtInt(4) x4_u = 1; - unsigned _ExtInt(43) x43_u = 1; - unsigned _ExtInt(32) x32_u = 1; + _BitInt(4) x4_s = 1; + _BitInt(32) x32_s = 1; + _BitInt(43) x43_s = 1; + unsigned _BitInt(4) x4_u = 1; + unsigned _BitInt(43) x43_u = 1; + unsigned _BitInt(32) x32_u = 1; int x_int = 1; unsigned x_uint = 1; // Same size/sign ops don't change type. - _Static_assert(EXPR_HAS_TYPE(x43_s + x43_s, _ExtInt(43)), ""); - _Static_assert(EXPR_HAS_TYPE(x4_s - x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(x43_u * x43_u, unsigned _ExtInt(43)), ""); - _Static_assert(EXPR_HAS_TYPE(x4_u / x4_u, unsigned _ExtInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_s + x43_s, _BitInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_s - x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_u * x43_u, unsigned _BitInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_u / x4_u, unsigned _BitInt(4)), ""); // Unary ops shouldn't go through integer promotions. - _Static_assert(EXPR_HAS_TYPE(x4_s++, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(++x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(x4_u++, unsigned _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(++x4_u, unsigned _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(+x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(-x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(~x4_u, unsigned _ExtInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_s++, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(++x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_u++, unsigned _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(++x4_u, unsigned _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(+x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(-x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(~x4_u, unsigned _BitInt(4)), ""); // This one really does convert to a different result type though. _Static_assert(EXPR_HAS_TYPE(!x4_u, int), ""); // Test binary ops pick the correct common type. - _Static_assert(EXPR_HAS_TYPE(x43_s + x_int, _ExtInt(43)), ""); - _Static_assert(EXPR_HAS_TYPE(x43_u + x_int, unsigned _ExtInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_s + x_int, _BitInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_u + x_int, unsigned _BitInt(43)), ""); _Static_assert(EXPR_HAS_TYPE(x32_s + x_int, int), ""); _Static_assert(EXPR_HAS_TYPE(x32_u + x_int, unsigned int), ""); _Static_assert(EXPR_HAS_TYPE(x32_s + x_uint, unsigned int), ""); @@ -60,16 +60,16 @@ void FromPaper1(void) { // Test the examples of conversion and promotion rules from C2x 6.3.1.8. - _ExtInt(2) a2 = 1; - _ExtInt(3) a3 = 2; - _ExtInt(33) a33 = 1; + _BitInt(2) a2 = 1; + _BitInt(3) a3 = 2; + _BitInt(33) a33 = 1; char c = 3; - _Static_assert(EXPR_HAS_TYPE(a2 * a3, _ExtInt(3)), ""); + _Static_assert(EXPR_HAS_TYPE(a2 * a3, _BitInt(3)), ""); _Static_assert(EXPR_HAS_TYPE(a2 * c, int), ""); - _Static_assert(EXPR_HAS_TYPE(a33 * c, _ExtInt(33)), ""); + _Static_assert(EXPR_HAS_TYPE(a33 * c, _BitInt(33)), ""); } -void FromPaper2(_ExtInt(8) a1, _ExtInt(24) a2) { - _Static_assert(EXPR_HAS_TYPE(a1 * (_ExtInt(32))a2, _ExtInt(32)), ""); +void FromPaper2(_BitInt(8) a1, _BitInt(24) a2) { + _Static_assert(EXPR_HAS_TYPE(a1 * (_BitInt(32))a2, _BitInt(32)), ""); } Index: clang/test/Sema/invalid-bitwidth-expr.mm =================================================================== --- clang/test/Sema/invalid-bitwidth-expr.mm +++ clang/test/Sema/invalid-bitwidth-expr.mm @@ -34,6 +34,6 @@ constexpr int ssss = sizeof(Z); struct Z2 { - int X : sizeof(_ExtInt(invalid())); // expected-error {{use of undeclared identifier}} + int X : sizeof(_BitInt(invalid())); // expected-error {{use of undeclared identifier}} }; constexpr int sssss = sizeof(Z2); Index: clang/test/SemaCXX/ext-int-asm.cpp =================================================================== --- clang/test/SemaCXX/ext-int-asm.cpp +++ clang/test/SemaCXX/ext-int-asm.cpp @@ -1,11 +1,11 @@ // REQUIRES: x86-registered-target // RUN: %clang_cc1 -fsyntax-only -verify %s -Wimplicit-int-conversion -triple x86_64-gnu-linux -fasm-blocks -void NotAllowedInInlineAsm(_ExtInt(9) in, _ExtInt(9) out) { - __asm { mov eax, in} // expected-error{{invalid type '_ExtInt(9)' in asm input}} - __asm { mov out, eax} // expected-error{{invalid type '_ExtInt(9)' in asm output}} +void NotAllowedInInlineAsm(_BitInt(9) in, _BitInt(9) out) { + __asm { mov eax, in} // expected-error{{invalid type '_BitInt(9)' in asm input}} + __asm { mov out, eax} // expected-error{{invalid type '_BitInt(9)' in asm output}} - asm("" : "=g" (in));// expected-error{{invalid type '_ExtInt(9)' in asm input}} - asm("" :: "r" (out));// expected-error{{invalid type '_ExtInt(9)' in asm output}} + asm("" : "=g" (in));// expected-error{{invalid type '_BitInt(9)' in asm input}} + asm("" :: "r" (out));// expected-error{{invalid type '_BitInt(9)' in asm output}} } Index: clang/test/SemaCXX/ext-int-compat.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/ext-int-compat.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=precompat -x c %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -Wbit-int-extension -verify=cext -x c %s +// RUN: %clang_cc1 -fsyntax-only -Wbit-int-extension -verify=cppext %s + +_BitInt(5) Val; // precompat-warning {{'_BitInt' is incompatible with C standards before C2x}} \ + cext-warning {{'_BitInt' in C17 and earlier is a Clang extension}} \ + cppext-warning {{'_BitInt' in C++ is a Clang extension}} + Index: clang/test/SemaCXX/ext-int-fixit.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/ext-int-fixit.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:19}:"_BitInt" +void Fixit(_ExtInt(8) foo) { // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:19}:"_BitInt" + unsigned _ExtInt(33) bar; // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} +} + +// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:11-[[@LINE+1]]:18}:"_BitInt" +template <_ExtInt(32) Val> // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} +void Func(); + +template +void OtherFunc(Ty); + +void Instantiate() { + // CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:23-[[@LINE+1]]:30}:"_BitInt" + OtherFunc((unsigned _ExtInt(24) const){0}); // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} +} Index: clang/test/SemaCXX/ext-int.cpp =================================================================== --- clang/test/SemaCXX/ext-int.cpp +++ clang/test/SemaCXX/ext-int.cpp @@ -2,72 +2,72 @@ template struct HasExtInt { - _ExtInt(Bounds) b; - unsigned _ExtInt(Bounds) b2; + _BitInt(Bounds) b; + unsigned _BitInt(Bounds) b2; }; // Delcaring variables: -_ExtInt(33) Declarations(_ExtInt(48) &Param) { // Useable in params and returns. - short _ExtInt(43) a; // expected-error {{'short _ExtInt' is invalid}} - _ExtInt(43) long b; // expected-error {{'long _ExtInt' is invalid}} +_BitInt(33) Declarations(_BitInt(48) &Param) { // Useable in params and returns. + short _BitInt(43) a; // expected-error {{'short _BitInt' is invalid}} + _BitInt(43) long b; // expected-error {{'long _BitInt' is invalid}} // These should all be fine: - const _ExtInt(5) c = 3; - const unsigned _ExtInt(5) d; // expected-error {{default initialization of an object of const type 'const unsigned _ExtInt(5)'}} - unsigned _ExtInt(5) e = 5; - _ExtInt(5) unsigned f; - - _ExtInt(-3) g; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - _ExtInt(0) h; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - _ExtInt(1) i; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - _ExtInt(2) j;; - unsigned _ExtInt(0) k;// expected-error{{unsigned _ExtInt must have a bit size of at least 1}} - unsigned _ExtInt(1) l; - signed _ExtInt(1) m; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - - constexpr _ExtInt(6) n = 33; // expected-warning{{implicit conversion from 'int' to 'const _ExtInt(6)' changes value from 33 to -31}} - constexpr _ExtInt(7) o = 33; + const _BitInt(5) c = 3; + const unsigned _BitInt(5) d; // expected-error {{default initialization of an object of const type 'const unsigned _BitInt(5)'}} + unsigned _BitInt(5) e = 5; + _BitInt(5) unsigned f; + + _BitInt(-3) g; // expected-error{{signed _BitInt must have a bit size of at least 2}} + _BitInt(0) h; // expected-error{{signed _BitInt must have a bit size of at least 2}} + _BitInt(1) i; // expected-error{{signed _BitInt must have a bit size of at least 2}} + _BitInt(2) j;; + unsigned _BitInt(0) k;// expected-error{{unsigned _BitInt must have a bit size of at least 1}} + unsigned _BitInt(1) l; + signed _BitInt(1) m; // expected-error{{signed _BitInt must have a bit size of at least 2}} + + constexpr _BitInt(6) n = 33; // expected-warning{{implicit conversion from 'int' to 'const _BitInt(6)' changes value from 33 to -31}} + constexpr _BitInt(7) o = 33; // Check LLVM imposed max size. - _ExtInt(8388609) p; // expected-error {{signed _ExtInt of bit sizes greater than 8388608 not supported}} - unsigned _ExtInt(0xFFFFFFFFFF) q; // expected-error {{unsigned _ExtInt of bit sizes greater than 8388608 not supported}} + _BitInt(8388609) p; // expected-error {{signed _BitInt of bit sizes greater than 8388608 not supported}} + unsigned _BitInt(0xFFFFFFFFFF) q; // expected-error {{unsigned _BitInt of bit sizes greater than 8388608 not supported}} // Ensure template params are instantiated correctly. - // expected-error@5{{signed _ExtInt must have a bit size of at least 2}} - // expected-error@6{{unsigned _ExtInt must have a bit size of at least 1}} + // expected-error@5{{signed _BitInt must have a bit size of at least 2}} + // expected-error@6{{unsigned _BitInt must have a bit size of at least 1}} // expected-note@+1{{in instantiation of template class }} HasExtInt<-1> r; - // expected-error@5{{signed _ExtInt must have a bit size of at least 2}} - // expected-error@6{{unsigned _ExtInt must have a bit size of at least 1}} + // expected-error@5{{signed _BitInt must have a bit size of at least 2}} + // expected-error@6{{unsigned _BitInt must have a bit size of at least 1}} // expected-note@+1{{in instantiation of template class }} HasExtInt<0> s; - // expected-error@5{{signed _ExtInt must have a bit size of at least 2}} + // expected-error@5{{signed _BitInt must have a bit size of at least 2}} // expected-note@+1{{in instantiation of template class }} HasExtInt<1> t; HasExtInt<2> u; - _ExtInt(-3.0) v; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} - _ExtInt(3.0) x; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} + _BitInt(-3.0) v; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} + _BitInt(3.0) x; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} return 0; } -template <_ExtInt(5) I> +template <_BitInt(5) I> struct ExtIntTemplParam { - static constexpr _ExtInt(5) Var = I; + static constexpr _BitInt(5) Var = I; }; template void deduced_whole_type(T){} template -void deduced_bound(_ExtInt(I)){} +void deduced_bound(_BitInt(I)){} // Ensure ext-int can be used in template places. void Templates() { ExtIntTemplParam<13> a; - constexpr _ExtInt(3) b = 1; + constexpr _BitInt(3) b = 1; ExtIntTemplParam c; - constexpr _ExtInt(9) d = 1; + constexpr _BitInt(9) d = 1; ExtIntTemplParam e; deduced_whole_type(b); @@ -84,28 +84,28 @@ }; // Reject vector types: -// expected-error@+1{{invalid vector element type '_ExtInt(32)'}} -typedef _ExtInt(32) __attribute__((vector_size(16))) VecTy; +// expected-error@+1{{invalid vector element type '_BitInt(32)'}} +typedef _BitInt(32) __attribute__((vector_size(16))) VecTy; // Allow _Complex: -_Complex _ExtInt(3) Cmplx; +_Complex _BitInt(3) Cmplx; // Reject cases of _Atomic: -// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(4)'}} -_Atomic _ExtInt(4) TooSmallAtomic; -// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(9)'}} -_Atomic _ExtInt(9) NotPow2Atomic; -// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(128)'}} -_Atomic _ExtInt(128) JustRightAtomic; +// expected-error@+1{{_Atomic cannot be applied to integer type '_BitInt(4)'}} +_Atomic _BitInt(4) TooSmallAtomic; +// expected-error@+1{{_Atomic cannot be applied to integer type '_BitInt(9)'}} +_Atomic _BitInt(9) NotPow2Atomic; +// expected-error@+1{{_Atomic cannot be applied to integer type '_BitInt(128)'}} +_Atomic _BitInt(128) JustRightAtomic; // Test result types of Unary/Bitwise/Binary Operations: void Ops() { - _ExtInt(43) x43_s = 1, y43_s = 1; - _ExtInt(sizeof(int) * 8) x32_s = 1, y32_s = 1; - unsigned _ExtInt(sizeof(unsigned) * 8) x32_u = 1, y32_u = 1; - _ExtInt(4) x4_s = 1, y4_s = 1; - unsigned _ExtInt(43) x43_u = 1, y43_u = 1; - unsigned _ExtInt(4) x4_u = 1, y4_u = 1; + _BitInt(43) x43_s = 1, y43_s = 1; + _BitInt(sizeof(int) * 8) x32_s = 1, y32_s = 1; + unsigned _BitInt(sizeof(unsigned) * 8) x32_u = 1, y32_u = 1; + _BitInt(4) x4_s = 1, y4_s = 1; + unsigned _BitInt(43) x43_u = 1, y43_u = 1; + unsigned _BitInt(4) x4_u = 1, y4_u = 1; int x_int = 1, y_int = 1; unsigned x_uint = 1, y_uint = 1; bool b; @@ -135,8 +135,8 @@ x4_u - b; x43_s + b; x43_u - b; - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); static_assert(is_same::value, ""); static_assert(is_same::value, ""); static_assert(is_same::value, ""); @@ -157,71 +157,71 @@ // Comparisons. x43_s > 33; - x4_s > 33; // expected-warning {{result of comparison of constant 33 with expression of type '_ExtInt(4)' is always false}} + x4_s > 33; // expected-warning {{result of comparison of constant 33 with expression of type '_BitInt(4)' is always false}} // Same size/sign ops don't change type. - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); // Unary ops shouldn't go through integer promotions. - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); - static_assert(is_same> 1), _ExtInt(4)>::value,""); - static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same> 1), _BitInt(4)>::value,""); + static_assert(is_same::value,""); static_assert(sizeof(x43_s) == 8, ""); static_assert(sizeof(x4_s) == 1, ""); - static_assert(sizeof(_ExtInt(3340)) == 424, ""); // 424 * 8 == 3392. - static_assert(sizeof(_ExtInt(1049)) == 136, ""); // 136 * 8 == 1088. + static_assert(sizeof(_BitInt(3340)) == 424, ""); // 424 * 8 == 3392. + static_assert(sizeof(_BitInt(1049)) == 136, ""); // 136 * 8 == 1088. static_assert(alignof(decltype(x43_s)) == 8, ""); static_assert(alignof(decltype(x4_s)) == 1, ""); - static_assert(alignof(_ExtInt(3340)) == 8, ""); - static_assert(alignof(_ExtInt(1049)) == 8, ""); + static_assert(alignof(_BitInt(3340)) == 8, ""); + static_assert(alignof(_BitInt(1049)) == 8, ""); } constexpr int func() { return 42;} void ConstexprBitsize() { - _ExtInt(func()) F; - static_assert(is_same::value, ""); + _BitInt(func()) F; + static_assert(is_same::value, ""); } // Useable as an underlying type. -enum AsEnumUnderlyingType : _ExtInt(33) { +enum AsEnumUnderlyingType : _BitInt(33) { }; void overloaded(int); -void overloaded(_ExtInt(32)); -void overloaded(_ExtInt(33)); +void overloaded(_BitInt(32)); +void overloaded(_BitInt(33)); void overloaded(short); //expected-note@+1{{candidate function}} -void overloaded2(_ExtInt(32)); +void overloaded2(_BitInt(32)); //expected-note@+1{{candidate function}} -void overloaded2(_ExtInt(33)); +void overloaded2(_BitInt(33)); //expected-note@+1{{candidate function}} void overloaded2(short); void overload_use() { int i; - _ExtInt(32) i32; - _ExtInt(33) i33; + _BitInt(32) i32; + _BitInt(33) i33; short s; // All of these get their corresponding exact matches. @@ -239,19 +239,19 @@ // no errors expected, this should 'just work'. struct UsedAsBitField { - _ExtInt(3) F : 3; - _ExtInt(3) G : 3; - _ExtInt(3) H : 3; + _BitInt(3) F : 3; + _BitInt(3) G : 3; + _BitInt(3) H : 3; }; struct CursedBitField { - _ExtInt(4) A : 8; // expected-warning {{width of bit-field 'A' (8 bits) exceeds the width of its type; value will be truncated to 4 bits}} + _BitInt(4) A : 8; // expected-warning {{width of bit-field 'A' (8 bits) exceeds the width of its type; value will be truncated to 4 bits}} }; // expected-error@+1{{mode attribute only supported for integer and floating-point types}} -typedef _ExtInt(33) IllegalMode __attribute__((mode(DI))); +typedef _BitInt(33) IllegalMode __attribute__((mode(DI))); -void ImplicitCasts(_ExtInt(31) s31, _ExtInt(33) s33, int i) { +void ImplicitCasts(_BitInt(31) s31, _BitInt(33) s33, int i) { // expected-warning@+1{{implicit conversion loses integer precision}} s31 = i; // expected-warning@+1{{implicit conversion loses integer precision}} @@ -263,31 +263,31 @@ i = s33; } -void Ternary(_ExtInt(30) s30, _ExtInt(31) s31a, _ExtInt(31) s31b, - _ExtInt(32) s32, bool b) { +void Ternary(_BitInt(30) s30, _BitInt(31) s31a, _BitInt(31) s31b, + _BitInt(32) s32, bool b) { b ? s30 : s31a; b ? s31a : s30; b ? s32 : (int)0; (void)(b ? s31a : s31b); (void)(s30 ? s31a : s31b); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); static_assert(is_same::value, ""); } void FromPaper1() { // Test the examples of conversion and promotion rules from C2x 6.3.1.8. - _ExtInt(2) a2 = 1; - _ExtInt(3) a3 = 2; - _ExtInt(33) a33 = 1; + _BitInt(2) a2 = 1; + _BitInt(3) a3 = 2; + _BitInt(33) a33 = 1; char c = 3; - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); } -void FromPaper2(_ExtInt(8) a1, _ExtInt(24) a2) { - static_assert(is_same::value, ""); +void FromPaper2(_BitInt(8) a1, _BitInt(24) a2) { + static_assert(is_same::value, ""); } Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -1815,8 +1815,8 @@ DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParm, Type) DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParmPack, Type) DEFAULT_TYPELOC_IMPL(Auto, Type) -DEFAULT_TYPELOC_IMPL(ExtInt, Type) -DEFAULT_TYPELOC_IMPL(DependentExtInt, Type) +DEFAULT_TYPELOC_IMPL(BitInt, Type) +DEFAULT_TYPELOC_IMPL(DependentBitInt, Type) bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) { // Visit the nested-name-specifier, if present.