Introduce _BitInt, deprecate _ExtInt
authorAaron Ballman <aaron@aaronballman.com>
Mon, 6 Dec 2021 17:46:54 +0000 (12:46 -0500)
committerAaron Ballman <aaron@aaronballman.com>
Mon, 6 Dec 2021 17:52:01 +0000 (12:52 -0500)
WG14 adopted the _ExtInt feature from Clang for C23, but renamed the
type to be _BitInt. This patch does the vast majority of the work to
rename _ExtInt to _BitInt, which accounts for most of its size. The new
type is exposed in older C modes and all C++ modes as a conforming
extension. However, there are functional changes worth calling out:

* Deprecates _ExtInt with a fix-it to help users migrate to _BitInt.
* Updates the mangling for the type.
* Updates the documentation and adds a release note to warn users what
is going on.
* Adds new diagnostics for use of _BitInt to call out when it's used as
a Clang extension or as a pre-C23 compatibility concern.
* Adds new tests for the new diagnostic behaviors.

I want to call out the ABI break specifically. We do not believe that
this break will cause a significant imposition for early adopters of
the feature, and so this is being done as a full break. If it turns out
there are critical uses where recompilation is not an option for some
reason, we can consider using ABI tags to ease the transition.

90 files changed:
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-extint.cpp
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeLoc.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Basic/TypeNodes.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/TypeBitCodes.def
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/ARC.h
clang/lib/Basic/Targets/ARM.h
clang/lib/Basic/Targets/Hexagon.h
clang/lib/Basic/Targets/Lanai.h
clang/lib/Basic/Targets/Mips.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/PNaCl.h
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/RISCV.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/Sparc.h
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.h
clang/lib/Basic/Targets/XCore.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenTBAA.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaStmtAsm.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CXX/temp/temp.param/p7.cpp
clang/test/CodeGen/attr-noundef.cpp
clang/test/CodeGen/builtins-overflow.c
clang/test/CodeGen/ext-int-cc.c
clang/test/CodeGen/ext-int-sanitizer.cpp
clang/test/CodeGen/ext-int.c
clang/test/CodeGen/extend-arg-64.c
clang/test/CodeGenCXX/ext-int.cpp
clang/test/CodeGenOpenCL/ext-int-shift.cl
clang/test/OpenMP/nvptx_unsupported_type_messages.cpp
clang/test/Parser/ext-int.cpp
clang/test/Sema/builtins-overflow.c
clang/test/Sema/builtins.c
clang/test/Sema/ext-int.c
clang/test/Sema/invalid-bitwidth-expr.mm
clang/test/SemaCXX/ext-int-asm.cpp
clang/test/SemaCXX/ext-int.cpp
clang/tools/libclang/CIndex.cpp

index 1da232e..b600cc5 100644 (file)
@@ -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 60b1ed3..e2c724e 100644 (file)
@@ -4089,55 +4089,13 @@ Examples are:
 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 149d0e1..5e6be24 100644 (file)
@@ -141,6 +141,16 @@ C Language Changes in Clang
   ``__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
 -----------------------------
 
@@ -173,6 +183,13 @@ OpenCL C Language Changes in Clang
 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 d336342..e861cd6 100644 (file)
@@ -264,8 +264,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
   mutable llvm::FoldingSet<AtomicType> AtomicTypes;
   llvm::FoldingSet<AttributedType> AttributedTypes;
   mutable llvm::FoldingSet<PipeType> PipeTypes;
-  mutable llvm::FoldingSet<ExtIntType> ExtIntTypes;
-  mutable llvm::FoldingSet<DependentExtIntType> DependentExtIntTypes;
+  mutable llvm::FoldingSet<BitIntType> BitIntTypes;
+  mutable llvm::FoldingSet<DependentBitIntType> DependentBitIntTypes;
 
   mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
   mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
@@ -1350,13 +1350,13 @@ public:
   /// 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 9797eac..3801c18 100644 (file)
@@ -1072,8 +1072,8 @@ DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); })
 
 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(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); })
 
 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 4c89c29..8abaae5 100644 (file)
@@ -2128,7 +2128,7 @@ public:
   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
@@ -6307,13 +6307,13 @@ public:
 };
 
 /// 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; }
@@ -6333,16 +6333,16 @@ public:
     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<Expr*, 1, bool> ExprAndUnsigned;
 
 protected:
-  DependentExtIntType(const ASTContext &Context, bool IsUnsigned,
+  DependentBitIntType(const ASTContext &Context, bool IsUnsigned,
                       Expr *NumBits);
 
 public:
@@ -6360,7 +6360,7 @@ public:
                       bool IsUnsigned, Expr *NumBitsExpr);
 
   static bool classof(const Type *T) {
-    return T->getTypeClass() == DependentExtInt;
+    return T->getTypeClass() == DependentBitInt;
   }
 };
 
@@ -6891,8 +6891,8 @@ inline bool Type::isPipeType() const {
   return isa<PipeType>(CanonicalType);
 }
 
-inline bool Type::isExtIntType() const {
-  return isa<ExtIntType>(CanonicalType);
+inline bool Type::isBitIntType() const {
+  return isa<BitIntType>(CanonicalType);
 }
 
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
@@ -6998,7 +6998,7 @@ inline bool Type::isIntegerType() const {
     return IsEnumDeclComplete(ET->getDecl()) &&
       !IsEnumDeclScoped(ET->getDecl());
   }
-  return isExtIntType();
+  return isBitIntType();
 }
 
 inline bool Type::isFixedPointType() const {
@@ -7056,7 +7056,7 @@ inline bool Type::isScalarType() const {
          isa<MemberPointerType>(CanonicalType) ||
          isa<ComplexType>(CanonicalType) ||
          isa<ObjCObjectPointerType>(CanonicalType) ||
-         isExtIntType();
+         isBitIntType();
 }
 
 inline bool Type::isIntegralOrEnumerationType() const {
@@ -7069,7 +7069,7 @@ inline bool Type::isIntegralOrEnumerationType() const {
   if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
     return IsEnumDeclComplete(ET->getDecl());
 
-  return isExtIntType();
+  return isBitIntType();
 }
 
 inline bool Type::isBooleanType() const {
index bb668c1..223c1b6 100644 (file)
@@ -2561,12 +2561,12 @@ inline T TypeLoc::getAsAdjusted() const {
   }
   return Cur.getAs<T>();
 }
-class ExtIntTypeLoc final
-    : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, ExtIntTypeLoc,
-                                        ExtIntType> {};
-class DependentExtIntTypeLoc final
-    : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentExtIntTypeLoc,
-                                        DependentExtIntType> {};
+class BitIntTypeLoc final
+    : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, BitIntTypeLoc,
+                                       BitIntType> {};
+class DependentBitIntTypeLoc final
+    : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentBitIntTypeLoc,
+                                       DependentBitIntType> {};
 
 } // namespace clang
 
index 438d5af..b7730a0 100644 (file)
@@ -882,7 +882,7 @@ let Class = PipeType in {
   }]>;
 }
 
-let Class = ExtIntType in {
+let Class = BitIntType in {
   def : Property<"isUnsigned", Bool> {
     let Read = [{ node->isUnsigned() }];
   }
@@ -891,11 +891,11 @@ let Class = ExtIntType in {
   }
 
   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 Class = DependentExtIntType in {
     let Read = [{ node->getNumBitsExpr() }];
   }
   def : Creator<[{
-    return ctx.getDependentExtIntType(isUnsigned, numBitsExpr);
+    return ctx.getDependentBitIntType(isUnsigned, numBitsExpr);
   }]>;
 }
index 90df3a4..22cd934 100644 (file)
@@ -191,6 +191,7 @@ def DeprecatedVolatile : DiagGroup<"deprecated-volatile">;
 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,
@@ -208,6 +209,7 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion,
                                           DeprecatedPragma,
                                           DeprecatedRegister,
                                           DeprecatedThisCapture,
+                                          DeprecatedType,
                                           DeprecatedVolatile,
                                           DeprecatedWritableStr]>,
                  DiagCategory<"Deprecations">;
index 92e8770..9dc036c 100644 (file)
@@ -1503,6 +1503,15 @@ def warn_pragma_force_cuda_host_device_bad_arg : Warning<
 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<DeprecatedType>;
+def ext_bit_int : Extension<
+  "'_BitInt' in %select{C17 and earlier|C++}0 is a Clang extension">,
+  InGroup<DiagGroup<"bit-int-extension">>;
+def warn_c17_compat_bit_int : Warning<
+  "'_BitInt' is incompatible with C standards before C2x">,
+  InGroup<CPre2xCompat>, DefaultIgnore;
 } // end of Parse Issue category.
 
 let CategoryName = "Modules Issue" in {
index fb5bd53..640286d 100644 (file)
@@ -8337,8 +8337,8 @@ def err_atomic_exclusive_builtin_pointer_size : Error<
   " 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)">;
@@ -8374,8 +8374,8 @@ def err_overflow_builtin_must_be_int : Error<
 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<
@@ -11423,9 +11423,9 @@ def warn_sycl_kernel_return_type : Warning<
   "function template with 'sycl_kernel' attribute must have a 'void' return type">,
   InGroup<IgnoredAttributes>;
 
-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 66cdba3..82b3c1f 100644 (file)
@@ -59,7 +59,7 @@ namespace clang {
     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 3e1e094..437feba 100644 (file)
@@ -582,9 +582,13 @@ public:
     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 0dd5936..e55244e 100644 (file)
@@ -300,6 +300,7 @@ KEYWORD(if                          , KEYALL)
 KEYWORD(inline                      , KEYC99|KEYCXX|KEYGNU)
 KEYWORD(int                         , KEYALL)
 KEYWORD(_ExtInt                     , KEYALL)
+KEYWORD(_BitInt                     , KEYALL)
 KEYWORD(long                        , KEYALL)
 KEYWORD(register                    , KEYALL)
 KEYWORD(restrict                    , KEYC99)
index 011394c..3152b2a 100644 (file)
@@ -107,5 +107,5 @@ def ObjCInterfaceType : TypeNode<ObjCObjectType>, LeafType;
 def ObjCObjectPointerType : TypeNode<Type>;
 def PipeType : TypeNode<Type>;
 def AtomicType : TypeNode<Type>;
-def ExtIntType : TypeNode<Type>;
-def DependentExtIntType : TypeNode<Type>, AlwaysDependent;
+def BitIntType : TypeNode<Type>;
+def DependentBitIntType : TypeNode<Type>, AlwaysDependent;
index 92a703b..741a484 100644 (file)
@@ -2564,6 +2564,10 @@ private:
   /// 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 ed5be2d..2704a9c 100644 (file)
@@ -266,7 +266,7 @@ public:
   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 @@ private:
             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 @@ public:
   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 1a82a94..40c0b54 100644 (file)
@@ -2043,7 +2043,7 @@ public:
                          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 e92e058..745d0ba 100644 (file)
@@ -58,8 +58,8 @@ TYPE_BIT_CODE(DependentSizedExtVector, DEPENDENT_SIZED_EXT_VECTOR, 46)
 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 2d85d72..b6e1966 100644 (file)
@@ -2286,8 +2286,8 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
     Align = toBits(Layout.getAlignment());
     break;
   }
-  case Type::ExtInt: {
-    const auto *EIT = cast<ExtIntType>(T);
+  case Type::BitInt: {
+    const auto *EIT = cast<BitIntType>(T);
     Align =
         std::min(static_cast<unsigned>(std::max(
                      getCharWidth(), llvm::PowerOf2Ceil(EIT->getNumBits()))),
@@ -3569,8 +3569,8 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const {
   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 @@ QualType ASTContext::getWritePipeType(QualType T) const {
   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);
@@ -6444,7 +6444,7 @@ unsigned ASTContext::getIntegerRank(const Type *T) const {
 
   // Results in this 'losing' to any type of the same size, but winning if
   // larger.
-  if (const auto *EIT = dyn_cast<ExtIntType>(T))
+  if (const auto *EIT = dyn_cast<BitIntType>(T))
     return 0 + (EIT->getNumBits() << 3);
 
   switch (cast<BuiltinType>(T)->getKind()) {
@@ -7885,7 +7885,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S,
     return;
 
   case Type::Pipe:
-  case Type::ExtInt:
+  case Type::BitInt:
 #define ABSTRACT_TYPE(KIND, BASE)
 #define TYPE(KIND, BASE)
 #define DEPENDENT_TYPE(KIND, BASE) \
@@ -10101,12 +10101,12 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
     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<ExtIntType>()->isUnsigned();
-    bool RHSUnsigned = RHS->castAs<ExtIntType>()->isUnsigned();
-    unsigned LHSBits = LHS->castAs<ExtIntType>()->getNumBits();
-    unsigned RHSBits = RHS->castAs<ExtIntType>()->getNumBits();
+  case Type::BitInt: {
+    // Merge two bit-precise int types, while trying to preserve typedef info.
+    bool LHSUnsigned = LHS->castAs<BitIntType>()->isUnsigned();
+    bool RHSUnsigned = RHS->castAs<BitIntType>()->isUnsigned();
+    unsigned LHSBits = LHS->castAs<BitIntType>()->getNumBits();
+    unsigned RHSBits = RHS->castAs<BitIntType>()->getNumBits();
 
     // Like unsigned/int, shouldn't have a type if they don't match.
     if (LHSUnsigned != RHSUnsigned)
@@ -10256,7 +10256,7 @@ unsigned ASTContext::getIntWidth(QualType T) const {
     T = ET->getDecl()->getIntegerType();
   if (T->isBooleanType())
     return 1;
-  if(const auto *EIT = T->getAs<ExtIntType>())
+  if (const auto *EIT = T->getAs<BitIntType>())
     return EIT->getNumBits();
   // For builtin types, just use the standard type sizing method
   return (unsigned)getTypeSize(T);
@@ -10271,9 +10271,9 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) const {
     return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
                          VTy->getNumElements(), VTy->getVectorKind());
 
-  // For _ExtInt, return an unsigned _ExtInt with same width.
-  if (const auto *EITy = T->getAs<ExtIntType>())
-    return getExtIntType(/*IsUnsigned=*/true, EITy->getNumBits());
+  // For _BitInt, return an unsigned _BitInt with same width.
+  if (const auto *EITy = T->getAs<BitIntType>())
+    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.
@@ -10339,9 +10339,9 @@ QualType ASTContext::getCorrespondingSignedType(QualType T) const {
     return getVectorType(getCorrespondingSignedType(VTy->getElementType()),
                          VTy->getNumElements(), VTy->getVectorKind());
 
-  // For _ExtInt, return a signed _ExtInt with same width.
-  if (const auto *EITy = T->getAs<ExtIntType>())
-    return getExtIntType(/*IsUnsigned=*/false, EITy->getNumBits());
+  // For _BitInt, return a signed _BitInt with same width.
+  if (const auto *EITy = T->getAs<BitIntType>())
+    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 7fd24e2..9883f6f 100644 (file)
@@ -1205,18 +1205,18 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
                                   cast<PipeType>(T2)->getElementType()))
       return false;
     break;
-  case Type::ExtInt: {
-    const auto *Int1 = cast<ExtIntType>(T1);
-    const auto *Int2 = cast<ExtIntType>(T2);
+  case Type::BitInt: {
+    const auto *Int1 = cast<BitIntType>(T1);
+    const auto *Int2 = cast<BitIntType>(T2);
 
     if (Int1->isUnsigned() != Int2->isUnsigned() ||
         Int1->getNumBits() != Int2->getNumBits())
       return false;
     break;
   }
-  case Type::DependentExtInt: {
-    const auto *Int1 = cast<DependentExtIntType>(T1);
-    const auto *Int2 = cast<DependentExtIntType>(T2);
+  case Type::DependentBitInt: {
+    const auto *Int1 = cast<DependentBitIntType>(T1);
+    const auto *Int2 = cast<DependentBitIntType>(T2);
 
     if (Int1->isUnsigned() != Int2->isUnsigned() ||
         !IsStructurallyEquivalent(Context, Int1->getNumBitsExpr(),
index 99babd5..bb59e72 100644 (file)
@@ -11077,7 +11077,7 @@ EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts) {
   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 07579d0..c39daa3 100644 (file)
@@ -2263,8 +2263,8 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty,
   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 @@ void CXXNameMangler::mangleType(const PipeType *T) {
   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
+  // <type> ::= DB <number | instantiation-dependent expression> _
+  //        ::= DU <number | instantiation-dependent expression> _
+  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
+  // <type> ::= DB <number | instantiation-dependent expression> _
+  //        ::= DU <number | instantiation-dependent expression> _
+  Out << "D" << (T->isUnsigned() ? "U" : "B");
+  mangleExpression(T->getNumBitsExpr());
+  Out << "_";
 }
 
 void CXXNameMangler::mangleIntegerLiteral(QualType T,
index 79a448a..8802b6e 100644 (file)
@@ -3365,26 +3365,26 @@ void MicrosoftMangleContextImpl::mangleCXXName(GlobalDecl GD,
   return Mangler.mangle(GD);
 }
 
-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 e0ac3f5..e5a39f8 100644 (file)
@@ -338,25 +338,25 @@ VectorType::VectorType(TypeClass tc, QualType vecType, unsigned nElements,
   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);
@@ -1932,7 +1932,7 @@ bool Type::isIntegralType(const ASTContext &Ctx) const {
     if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
       return ET->getDecl()->isComplete();
 
-  return isExtIntType();
+  return isBitIntType();
 }
 
 bool Type::isIntegralOrUnscopedEnumerationType() const {
@@ -1940,7 +1940,7 @@ bool Type::isIntegralOrUnscopedEnumerationType() const {
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::Int128;
 
-  if (isExtIntType())
+  if (isBitIntType())
     return true;
 
   return isUnscopedEnumerationType();
@@ -2023,7 +2023,9 @@ bool Type::isSignedIntegerType() const {
       return ET->getDecl()->getIntegerType()->isSignedIntegerType();
   }
 
-  if (const ExtIntType *IT = dyn_cast<ExtIntType>(CanonicalType))
+  if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
+    return IT->isSigned();
+  if (const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
     return IT->isSigned();
 
   return false;
@@ -2040,9 +2042,10 @@ bool Type::isSignedIntegerOrEnumerationType() const {
       return ET->getDecl()->getIntegerType()->isSignedIntegerType();
   }
 
-  if (const ExtIntType *IT = dyn_cast<ExtIntType>(CanonicalType))
+  if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
+    return IT->isSigned();
+  if (const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
     return IT->isSigned();
-
 
   return false;
 }
@@ -2070,7 +2073,9 @@ bool Type::isUnsignedIntegerType() const {
       return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
   }
 
-  if (const ExtIntType *IT = dyn_cast<ExtIntType>(CanonicalType))
+  if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
+    return IT->isUnsigned();
+  if (const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
     return IT->isUnsigned();
 
   return false;
@@ -2087,7 +2092,9 @@ bool Type::isUnsignedIntegerOrEnumerationType() const {
       return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
   }
 
-  if (const ExtIntType *IT = dyn_cast<ExtIntType>(CanonicalType))
+  if (const auto *IT = dyn_cast<BitIntType>(CanonicalType))
+    return IT->isUnsigned();
+  if (const auto *IT = dyn_cast<DependentBitIntType>(CanonicalType))
     return IT->isUnsigned();
 
   return false;
@@ -2129,7 +2136,7 @@ bool Type::isRealType() const {
            BT->getKind() <= BuiltinType::Ibm128;
   if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
       return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
-  return isExtIntType();
+  return isBitIntType();
 }
 
 bool Type::isArithmeticType() const {
@@ -2145,7 +2152,7 @@ bool Type::isArithmeticType() const {
     // false for scoped enumerations since that will disable any
     // unwanted implicit conversions.
     return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
-  return isa<ComplexType>(CanonicalType) || isExtIntType();
+  return isa<ComplexType>(CanonicalType) || isBitIntType();
 }
 
 Type::ScalarTypeKind Type::getScalarTypeKind() const {
@@ -2174,7 +2181,7 @@ Type::ScalarTypeKind Type::getScalarTypeKind() const {
     if (CT->getElementType()->isRealFloatingType())
       return STK_FloatingComplex;
     return STK_IntegralComplex;
-  } else if (isExtIntType()) {
+  } else if (isBitIntType()) {
     return STK_Integral;
   }
 
@@ -2381,7 +2388,7 @@ bool QualType::isCXX98PODType(const ASTContext &Context) const {
   case Type::MemberPointer:
   case Type::Vector:
   case Type::ExtVector:
-  case Type::ExtInt:
+  case Type::BitInt:
     return true;
 
   case Type::Enum:
@@ -3849,7 +3856,7 @@ static CachedProperties computeCachedProperties(const Type *T) {
     // 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:
@@ -3949,7 +3956,7 @@ LinkageInfo LinkageComputer::computeTypeLinkageInfo(const Type *T) {
     assert(T->isInstantiationDependentType());
     return LinkageInfo::external();
 
-  case Type::ExtInt:
+  case Type::BitInt:
   case Type::Builtin:
     return LinkageInfo::external();
 
@@ -4169,8 +4176,8 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
   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 eca9af3..4044518 100644 (file)
@@ -232,8 +232,8 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
     case Type::ObjCInterface:
     case Type::Atomic:
     case Type::Pipe:
-    case Type::ExtInt:
-    case Type::DependentExtInt:
+    case Type::BitInt:
+    case Type::DependentBitInt:
       CanPrefixQualifiers = true;
       break;
 
@@ -1200,26 +1200,26 @@ void TypePrinter::printPipeBefore(const PipeType *T, raw_ostream &OS) {
 
 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 dea59a9..74745df 100644 (file)
@@ -150,7 +150,7 @@ public:
   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 8b9d7ce..9749221 100644 (file)
@@ -426,7 +426,7 @@ public:
 
   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 3c0c5f6..5411cd2 100644 (file)
@@ -66,7 +66,7 @@ public:
     return false;
   }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 
   bool isCLZForZeroUndef() const override { return false; }
 };
index 7d0011d..f939904 100644 (file)
@@ -191,8 +191,8 @@ public:
 
   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 d6c7da5..9444199 100644 (file)
@@ -139,7 +139,7 @@ public:
     return CPU.find('t') != std::string::npos;
   }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 } // namespace targets
 } // namespace clang
index 9af5427..56c6cce 100644 (file)
@@ -87,7 +87,7 @@ public:
 
   const char *getClobbers() const override { return ""; }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 } // namespace targets
 } // namespace clang
index b475c03..b54d36e 100644 (file)
@@ -406,7 +406,7 @@ public:
   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 ef751b8..76217e2 100644 (file)
@@ -175,7 +175,7 @@ public:
     return CCCR_Warning;
   }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 } // namespace targets
 } // namespace clang
index d5bfc36..b5cf73d 100644 (file)
@@ -69,7 +69,7 @@ public:
 
   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 f19d3eb..6070107 100644 (file)
@@ -351,7 +351,7 @@ public:
   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 f7ffe9f..5331ed4 100644 (file)
@@ -95,7 +95,7 @@ public:
   bool handleTargetFeatures(std::vector<std::string> &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 8cf18b6..a40d4b3 100644 (file)
@@ -162,7 +162,7 @@ public:
     supportAllOpenCLOpts();
   }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 
   bool hasInt128Type() const override { return false; }
 };
index badb568..177a117 100644 (file)
@@ -176,7 +176,7 @@ public:
   void getTargetDefines(const LangOptions &Opts,
                         MacroBuilder &Builder) const override;
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 
 // SPARCV8el is the 32-bit little-endian mode selected by Triple::sparcel.
@@ -229,7 +229,7 @@ public:
     return getCPUGeneration(CPU) == CG_V9;
   }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 } // namespace targets
 } // namespace clang
index d3e3ed5..92cefee 100644 (file)
@@ -170,7 +170,7 @@ public:
 
   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 16534d3..0754869 100644 (file)
@@ -137,7 +137,7 @@ private:
     }
   }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 
   bool hasProtectedVisibility() const override { return false; }
 
index b9b2ac7..0b420a7 100644 (file)
@@ -462,7 +462,7 @@ public:
 
   ArrayRef<Builtin::Info> getTargetBuiltins() const override;
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 
 class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo
@@ -769,7 +769,7 @@ public:
 
   ArrayRef<Builtin::Info> getTargetBuiltins() const override;
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 
 // x86-64 Windows target
index c337667..25f2058 100644 (file)
@@ -76,7 +76,7 @@ public:
 
   bool allowsLargerPreferedTypeAlignment() const override { return false; }
 
-  bool hasExtIntType() const override { return true; }
+  bool hasBitIntType() const override { return true; }
 };
 } // namespace targets
 } // namespace clang
index 56f0dd4..0d12183 100644 (file)
@@ -105,7 +105,7 @@ namespace swiftcall {
                                 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 44a24d2..5caa81f 100644 (file)
@@ -687,7 +687,7 @@ getIntegerWidthAndSignedness(const clang::ASTContext &context,
                              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 d830a7e..b0b6432 100644 (file)
@@ -1971,7 +1971,7 @@ static bool DetermineNoUndef(QualType QTy, CodeGenTypes &Types,
       // there's no internal padding (typeSizeEqualsStoreSize).
       return false;
   }
-  if (QTy->isExtIntType())
+  if (QTy->isBitIntType())
     return true;
   if (QTy->isReferenceType())
     return true;
index af651e6..7f48b27 100644 (file)
@@ -884,9 +884,9 @@ llvm::DIType *CGDebugInfo::CreateType(const AutoType *Ty) {
   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;
@@ -3531,8 +3531,8 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit,
   case Type::Atomic:
     return CreateType(cast<AtomicType>(Ty), Unit);
 
-  case Type::ExtInt:
-    return CreateType(cast<ExtIntType>(Ty));
+  case Type::BitInt:
+    return CreateType(cast<BitIntType>(Ty));
   case Type::Pipe:
     return CreateType(cast<PipeType>(Ty), Unit);
 
index a7b72fa..14ff0ee 100644 (file)
@@ -177,7 +177,7 @@ class CGDebugInfo {
   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,
                                     TypeLoc TL = TypeLoc());
   llvm::DIType *CreateQualifiedType(const FunctionProtoType *Ty,
index d87cf2d..ed43adf 100644 (file)
@@ -243,7 +243,7 @@ TypeEvaluationKind CodeGenFunction::getEvaluationKind(QualType type) {
     case Type::Enum:
     case Type::ObjCObjectPointer:
     case Type::Pipe:
-    case Type::ExtInt:
+    case Type::BitInt:
       return TEK_Scalar;
 
     // Complexes.
@@ -2207,7 +2207,7 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
     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 f4ebe68..95763d8 100644 (file)
@@ -209,12 +209,12 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
     return createScalarTypeNode(OutName, getChar(), Size);
   }
 
-  if (const auto *EIT = dyn_cast<ExtIntType>(Ty)) {
+  if (const auto *EIT = dyn_cast<BitIntType>(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 fb05475..7772151 100644 (file)
@@ -97,10 +97,10 @@ llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T, bool ForBitField) {
 
   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 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
     ResultType = CGM.getOpenCLRuntime().getPipeType(cast<PipeType>(Ty));
     break;
   }
-  case Type::ExtInt: {
-    const auto &EIT = cast<ExtIntType>(Ty);
+  case Type::BitInt: {
+    const auto &EIT = cast<BitIntType>(Ty);
     ResultType = llvm::Type::getIntNTy(getLLVMContext(), EIT->getNumBits());
     break;
   }
index 04163ae..2730b5b 100644 (file)
@@ -3529,7 +3529,7 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
     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 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
   case Type::Pipe:
     break;
 
-  case Type::ExtInt:
+  case Type::BitInt:
     break;
 
   case Type::ConstantArray:
index 3cb1f83..ade937d 100644 (file)
@@ -104,7 +104,7 @@ bool ABIInfo::isPromotableIntegerTypeForABI(QualType Ty) const {
   if (Ty->isPromotableIntegerType())
     return true;
 
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() < getContext().getTypeSize(getContext().IntTy))
       return true;
 
@@ -762,7 +762,7 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
     Ty = EnumTy->getDecl()->getIntegerType();
 
   ASTContext &Context = getContext();
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() >
         Context.getTypeSize(Context.getTargetInfo().hasInt128Type()
                                 ? Context.Int128Ty
@@ -784,7 +784,7 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy) const {
   if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
     RetTy = EnumTy->getDecl()->getIntegerType();
 
-  if (const auto *EIT = RetTy->getAs<ExtIntType>())
+  if (const auto *EIT = RetTy->getAs<BitIntType>())
     if (EIT->getNumBits() >
         getContext().getTypeSize(getContext().getTargetInfo().hasInt128Type()
                                      ? getContext().Int128Ty
@@ -1008,8 +1008,9 @@ ABIArgInfo PNaClABIInfo::classifyArgumentType(QualType Ty) const {
   } else if (Ty->isFloatingType()) {
     // Floating-point types don't go inreg.
     return ABIArgInfo::getDirect();
-  } else if (const auto *EIT = Ty->getAs<ExtIntType>()) {
-    // Treat extended integers as integers if <=64, otherwise pass indirectly.
+  } else if (const auto *EIT = Ty->getAs<BitIntType>()) {
+    // 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 @@ ABIArgInfo PNaClABIInfo::classifyReturnType(QualType RetTy) const {
   if (isAggregateTypeForABI(RetTy))
     return getNaturalAlignIndirect(RetTy);
 
-  // Treat extended integers as integers if <=64, otherwise pass indirectly.
-  if (const auto *EIT = RetTy->getAs<ExtIntType>()) {
+  // Treat bit-precise integers as integers if <= 64, otherwise pass indirectly.
+  if (const auto *EIT = RetTy->getAs<BitIntType>()) {
     if (EIT->getNumBits() > 64)
       return getNaturalAlignIndirect(RetTy);
     return ABIArgInfo::getDirect();
@@ -1590,7 +1591,7 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
   if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
     RetTy = EnumTy->getDecl()->getIntegerType();
 
-  if (const auto *EIT = RetTy->getAs<ExtIntType>())
+  if (const auto *EIT = RetTy->getAs<BitIntType>())
     if (EIT->getNumBits() > 64)
       return getIndirectReturnResult(RetTy, State);
 
@@ -1926,7 +1927,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
     return ABIArgInfo::getExtend(Ty);
   }
 
-  if (const auto * EIT = Ty->getAs<ExtIntType>()) {
+  if (const auto *EIT = Ty->getAs<BitIntType>()) {
     if (EIT->getNumBits() <= 64) {
       if (InReg)
         return ABIArgInfo::getDirectInReg();
@@ -3009,7 +3010,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase,
     return;
   }
 
-  if (const auto *EITy = Ty->getAs<ExtIntType>()) {
+  if (const auto *EITy = Ty->getAs<BitIntType>()) {
     if (EITy->getNumBits() <= 64)
       Current = Integer;
     else if (EITy->getNumBits() <= 128)
@@ -3200,7 +3201,7 @@ ABIArgInfo X86_64ABIInfo::getIndirectReturnResult(QualType Ty) const {
     if (const EnumType *EnumTy = Ty->getAs<EnumType>())
       Ty = EnumTy->getDecl()->getIntegerType();
 
-    if (Ty->isExtIntType())
+    if (Ty->isBitIntType())
       return getNaturalAlignIndirect(Ty);
 
     return (isPromotableIntegerTypeForABI(Ty) ? ABIArgInfo::getExtend(Ty)
@@ -3237,7 +3238,7 @@ ABIArgInfo X86_64ABIInfo::getIndirectResult(QualType Ty,
   // 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<EnumType>())
       Ty = EnumTy->getDecl()->getIntegerType();
@@ -4357,12 +4358,12 @@ ABIArgInfo WinX86_64ABIInfo::classify(QualType Ty, unsigned &FreeSSERegs,
     }
   }
 
-  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 @@ PPC64_SVR4_ABIInfo::isPromotableTypeForABI(QualType Ty) const {
       break;
     }
 
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() < 64)
       return true;
 
@@ -5294,7 +5295,7 @@ PPC64_SVR4_ABIInfo::classifyArgumentType(QualType Ty) const {
     }
   }
 
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() > 128)
       return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
 
@@ -5370,7 +5371,7 @@ PPC64_SVR4_ABIInfo::classifyReturnType(QualType RetTy) const {
     }
   }
 
-  if (const auto *EIT = RetTy->getAs<ExtIntType>())
+  if (const auto *EIT = RetTy->getAs<BitIntType>())
     if (EIT->getNumBits() > 128)
       return getNaturalAlignIndirect(RetTy, /*ByVal=*/false);
 
@@ -5722,7 +5723,7 @@ AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadic,
     if (const EnumType *EnumTy = Ty->getAs<EnumType>())
       Ty = EnumTy->getDecl()->getIntegerType();
 
-    if (const auto *EIT = Ty->getAs<ExtIntType>())
+    if (const auto *EIT = Ty->getAs<BitIntType>())
       if (EIT->getNumBits() > 128)
         return getNaturalAlignIndirect(Ty);
 
@@ -5824,7 +5825,7 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
     if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
       RetTy = EnumTy->getDecl()->getIntegerType();
 
-    if (const auto *EIT = RetTy->getAs<ExtIntType>())
+    if (const auto *EIT = RetTy->getAs<BitIntType>())
       if (EIT->getNumBits() > 128)
         return getNaturalAlignIndirect(RetTy);
 
@@ -6566,7 +6567,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
       Ty = EnumTy->getDecl()->getIntegerType();
     }
 
-    if (const auto *EIT = Ty->getAs<ExtIntType>())
+    if (const auto *EIT = Ty->getAs<BitIntType>())
       if (EIT->getNumBits() > 64)
         return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
 
@@ -6768,7 +6769,7 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy, bool isVariadic,
     if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
       RetTy = EnumTy->getDecl()->getIntegerType();
 
-    if (const auto *EIT = RetTy->getAs<ExtIntType>())
+    if (const auto *EIT = RetTy->getAs<BitIntType>())
       if (EIT->getNumBits() > 64)
         return getNaturalAlignIndirect(RetTy, /*ByVal=*/false);
 
@@ -7105,7 +7106,7 @@ bool NVPTXABIInfo::isUnsupportedType(QualType T) const {
       (T->isFloat128Type() ||
        (T->isRealFloatingType() && Context.getTypeSize(T) == 128)))
     return true;
-  if (const auto *EIT = T->getAs<ExtIntType>())
+  if (const auto *EIT = T->getAs<BitIntType>())
     return EIT->getNumBits() >
            (Context.getTargetInfo().hasInt128Type() ? 128U : 64U);
   if (!Context.getTargetInfo().hasInt128Type() && T->isIntegerType() &&
@@ -7182,7 +7183,7 @@ ABIArgInfo NVPTXABIInfo::classifyArgumentType(QualType Ty) const {
     return getNaturalAlignIndirect(Ty, /* byval */ true);
   }
 
-  if (const auto *EIT = Ty->getAs<ExtIntType>()) {
+  if (const auto *EIT = Ty->getAs<BitIntType>()) {
     if ((EIT->getNumBits() > 128) ||
         (!getContext().getTargetInfo().hasInt128Type() &&
          EIT->getNumBits() > 64))
@@ -7396,7 +7397,7 @@ bool SystemZABIInfo::isPromotableIntegerTypeForABI(QualType Ty) const {
   if (ABIInfo::isPromotableIntegerTypeForABI(Ty))
     return true;
 
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() < 64)
       return true;
 
@@ -7999,7 +8000,7 @@ MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t &Offset) const {
     Ty = EnumTy->getDecl()->getIntegerType();
 
   // Make sure we pass indirectly things that are too large.
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() > 128 ||
         (EIT->getNumBits() > 64 &&
          !getContext().getTargetInfo().hasInt128Type()))
@@ -8090,7 +8091,7 @@ ABIArgInfo MipsABIInfo::classifyReturnType(QualType RetTy) const {
     RetTy = EnumTy->getDecl()->getIntegerType();
 
   // Make sure we pass indirectly things that are too large.
-  if (const auto *EIT = RetTy->getAs<ExtIntType>())
+  if (const auto *EIT = RetTy->getAs<BitIntType>())
     if (EIT->getNumBits() > 128 ||
         (EIT->getNumBits() > 64 &&
          !getContext().getTargetInfo().hasInt128Type()))
@@ -8465,7 +8466,7 @@ ABIArgInfo HexagonABIInfo::classifyArgumentType(QualType Ty,
     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)
@@ -8521,7 +8522,7 @@ ABIArgInfo HexagonABIInfo::classifyReturnType(QualType RetTy) const {
     if (const EnumType *EnumTy = RetTy->getAs<EnumType>())
       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)
@@ -8892,7 +8893,7 @@ ABIArgInfo LanaiABIInfo::classifyArgumentType(QualType Ty,
   bool InReg = shouldUseInReg(Ty, State);
 
   // Don't pass >64 bit integers in registers.
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() > 64)
       return getIndirectResult(Ty, /*ByVal=*/true, State);
 
@@ -9624,7 +9625,7 @@ SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit) const {
   if (Size < 64 && Ty->isIntegerType())
     return ABIArgInfo::getExtend(Ty);
 
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() < 64)
       return ABIArgInfo::getExtend(Ty);
 
@@ -9878,7 +9879,7 @@ ABIArgInfo ARCABIInfo::classifyArgumentType(QualType Ty,
         ABIArgInfo::getDirect(Result, 0, nullptr, false);
   }
 
-  if (const auto *EIT = Ty->getAs<ExtIntType>())
+  if (const auto *EIT = Ty->getAs<BitIntType>())
     if (EIT->getNumBits() > 64)
       return getIndirectByValue(Ty);
 
@@ -10961,7 +10962,7 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
       return extendType(Ty);
     }
 
-    if (const auto *EIT = Ty->getAs<ExtIntType>()) {
+    if (const auto *EIT = Ty->getAs<BitIntType>()) {
       if (EIT->getNumBits() < XLen && !MustUseStack)
         return extendType(Ty);
       if (EIT->getNumBits() > 128 ||
index 1bdeccc..0c1f88b 100644 (file)
@@ -2891,7 +2891,8 @@ void Parser::ParseAlignmentSpecifier(ParsedAttributes &Attrs,
 }
 
 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 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
       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 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
   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 @@ bool Parser::isTypeSpecifierQualifier() {
   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 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) {
 
   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 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc,
   }
   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 2c8b4f9..09a3842 100644 (file)
@@ -1513,6 +1513,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
   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 4e5c0ac..76c510d 100644 (file)
@@ -2191,12 +2191,14 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
     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 be3823e..35c9036 100644 (file)
@@ -1690,6 +1690,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
   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 @@ bool Parser::isCXXDeclarationSpecifierAType() {
   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 4405f29..d4dc790 100644 (file)
@@ -365,7 +365,7 @@ bool Declarator::isDeclarationOfFunction() const {
     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 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
   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 @@ bool DeclSpec::SetTypeSpecError() {
   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 @@ bool DeclSpec::SetExtIntType(SourceLocation KWLoc, Expr *BitsExpr,
     return true;
   }
 
-  TypeSpecType = TST_extint;
+  TypeSpecType = TST_bitint;
   ExprRep = BitsExpr;
   TSTLoc = KWLoc;
   TSTNameLoc = KWLoc;
@@ -1252,7 +1252,7 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
       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 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy &Policy) {
                                                  " 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 a2b8f47..734ed0f 100644 (file)
@@ -1881,8 +1881,8 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
     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 33e2b3b..fc3886e 100644 (file)
@@ -325,17 +325,17 @@ static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall,
     }
   }
 
-  // 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;
     }
   }
@@ -5819,8 +5819,8 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
                 ? 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();
   }
 
@@ -6217,11 +6217,11 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
   // 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<ExtIntType>();
-  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<BitIntType>();
+  if (BitIntValType && !llvm::isPowerOf2_64(BitIntValType->getNumBits())) {
     Diag(FirstArg->getExprLoc(), diag::err_atomic_builtin_ext_int_size);
     return ExprError();
   }
@@ -11249,7 +11249,7 @@ struct IntRange {
                         false/*NonNegative*/);
     }
 
-    if (const auto *EIT = dyn_cast<ExtIntType>(T))
+    if (const auto *EIT = dyn_cast<BitIntType>(T))
       return IntRange(EIT->getNumBits(), EIT->isUnsigned());
 
     const BuiltinType *BT = cast<BuiltinType>(T);
@@ -11275,7 +11275,7 @@ struct IntRange {
     if (const EnumType *ET = dyn_cast<EnumType>(T))
       T = C.getCanonicalType(ET->getDecl()->getIntegerType()).getTypePtr();
 
-    if (const auto *EIT = dyn_cast<ExtIntType>(T))
+    if (const auto *EIT = dyn_cast<BitIntType>(T))
       return IntRange(EIT->getNumBits(), EIT->isUnsigned());
 
     const BuiltinType *BT = cast<BuiltinType>(T);
index 7be71ca..421ca95 100644 (file)
@@ -15359,7 +15359,7 @@ bool Sema::CheckEnumUnderlyingType(TypeSourceInfo *TI) {
     if (BT->isInteger())
       return false;
 
-  if (T->isExtIntType())
+  if (T->isBitIntType())
     return false;
 
   return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
index 4df8687..ba22c16 100644 (file)
@@ -4502,7 +4502,7 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
     return;
   }
   bool IntegralOrAnyEnumType = (OldElemTy->isIntegralOrEnumerationType() &&
-                                !OldElemTy->isExtIntType()) ||
+                                !OldElemTy->isBitIntType()) ||
                                OldElemTy->getAs<EnumType>();
 
   if (!OldElemTy->getAs<BuiltinType>() && !OldElemTy->isComplexType() &&
index b305d4e..2b69c37 100644 (file)
@@ -4384,7 +4384,7 @@ static void captureVariablyModifiedType(ASTContext &Context, QualType T,
     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<AdjustedType>(Ty)->getOriginalType();
@@ -8388,9 +8388,10 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   // 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();
@@ -10974,7 +10975,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
 
   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 0711e6d..635e93b 100644 (file)
@@ -2935,7 +2935,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) {
     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 603611b..49f7a8d 100644 (file)
@@ -296,9 +296,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
         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 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
       }
     }
 
-    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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
   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 f4fd2ea..2482f6d 100644 (file)
@@ -6142,12 +6142,12 @@ bool UnnamedLocalNoLinkageFinder::VisitPipeType(const PipeType* T) {
   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;
 }
 
@@ -7089,7 +7089,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       QualType IntegerType = ParamType;
       if (const EnumType *Enum = IntegerType->getAs<EnumType>())
         IntegerType = Enum->getDecl()->getIntegerType();
-      Value = Value.extOrTrunc(IntegerType->isExtIntType()
+      Value = Value.extOrTrunc(IntegerType->isBitIntType()
                                    ? Context.getIntWidth(IntegerType)
                                    : Context.getTypeSize(IntegerType));
 
@@ -7184,7 +7184,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
 
       // 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 81edae1..d527a37 100644 (file)
@@ -1597,7 +1597,7 @@ static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(
     case Type::ObjCObject:
     case Type::ObjCInterface:
     case Type::ObjCObjectPointer:
-    case Type::ExtInt:
+    case Type::BitInt:
       return (TDF & TDF_SkipNonDependent) ||
                      ((TDF & TDF_IgnoreQualifiers)
                           ? S.Context.hasSameUnqualifiedType(P, A)
@@ -2145,9 +2145,9 @@ static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(
       return Sema::TDK_NonDeducedMismatch;
     }
     case Type::DependentExtInt: {
-      const auto *IP = P->castAs<DependentExtIntType>();
+      const auto *IP = P->castAs<DependentBitIntType>();
 
-      if (const auto *IA = A->getAs<ExtIntType>()) {
+      if (const auto *IA = A->getAs<BitIntType>()) {
         if (IP->isUnsigned() != IA->isUnsigned())
           return Sema::TDK_NonDeducedMismatch;
 
@@ -2164,7 +2164,7 @@ static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(
                                              Deduced);
       }
 
-      if (const auto *IA = A->getAs<DependentExtIntType>()) {
+      if (const auto *IA = A->getAs<DependentBitIntType>()) {
         if (IP->isUnsigned() != IA->isUnsigned())
           return Sema::TDK_NonDeducedMismatch;
         return Sema::TDK_Success;
@@ -5949,9 +5949,9 @@ MarkUsedTemplateParameters(ASTContext &Ctx, QualType T,
                                cast<DeducedType>(T)->getDeducedType(),
                                OnlyDeduced, Depth, Used);
     break;
-  case Type::DependentExtInt:
+  case Type::DependentBitInt:
     MarkUsedTemplateParameters(Ctx,
-                               cast<DependentExtIntType>(T)->getNumBitsExpr(),
+                               cast<DependentBitIntType>(T)->getNumBitsExpr(),
                                OnlyDeduced, Depth, Used);
     break;
 
@@ -5966,7 +5966,7 @@ MarkUsedTemplateParameters(ASTContext &Ctx, QualType T,
   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 c0bb310..51c79e9 100644 (file)
@@ -870,7 +870,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
 
   case TST_typeofExpr:
   case TST_decltype:
-  case TST_extint:
+  case TST_bitint:
     if (DS.getRepAsExpr() &&
         DS.getRepAsExpr()->containsUnexpandedParameterPack())
       return true;
index d2ee669..b786c9f 100644 (file)
@@ -1435,12 +1435,11 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     }
     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 @@ QualType Sema::BuildWritePipeType(QualType T, SourceLocation Loc) {
   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 @@ QualType Sema::BuildWritePipeType(QualType T, SourceLocation Loc) {
 /// 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 @@ QualType Sema::BuildExtIntType(bool IsUnsigned, Expr *BitWidth,
 
   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
@@ -6077,11 +6076,11 @@ namespace {
       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());
     }
 
@@ -6211,7 +6210,7 @@ namespace {
       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) {
@@ -9079,9 +9078,8 @@ QualType Sema::BuildAtomicType(QualType T, SourceLocation Loc) {
     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 7f3326c..31f4c47 100644 (file)
@@ -1195,12 +1195,12 @@ public:
   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
@@ -6430,27 +6430,27 @@ QualType TreeTransform<Derived>::TransformPipeType(TypeLocBuilder &TLB,
 }
 
 template <typename Derived>
-QualType TreeTransform<Derived>::TransformExtIntType(TypeLocBuilder &TLB,
-                                                     ExtIntTypeLoc TL) {
-  const ExtIntType *EIT = TL.getTypePtr();
+QualType TreeTransform<Derived>::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<ExtIntTypeLoc>(Result);
+  BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
   NewTL.setNameLoc(TL.getNameLoc());
   return Result;
 }
 
 template <typename Derived>
-QualType TreeTransform<Derived>::TransformDependentExtIntType(
-    TypeLocBuilder &TLB, DependentExtIntTypeLoc TL) {
-  const DependentExtIntType *EIT = TL.getTypePtr();
+QualType TreeTransform<Derived>::TransformDependentBitIntType(
+    TypeLocBuilder &TLB, DependentBitIntTypeLoc TL) {
+  const DependentBitIntType *EIT = TL.getTypePtr();
 
   EnterExpressionEvaluationContext Unevaluated(
       SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
@@ -6463,18 +6463,18 @@ QualType TreeTransform<Derived>::TransformDependentExtIntType(
   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<DependentExtIntType>(Result)) {
-    DependentExtIntTypeLoc NewTL = TLB.push<DependentExtIntTypeLoc>(Result);
+  if (isa<DependentBitIntType>(Result)) {
+    DependentBitIntTypeLoc NewTL = TLB.push<DependentBitIntTypeLoc>(Result);
     NewTL.setNameLoc(TL.getNameLoc());
   } else {
-    ExtIntTypeLoc NewTL = TLB.push<ExtIntTypeLoc>(Result);
+    BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
     NewTL.setNameLoc(TL.getNameLoc());
   }
   return Result;
@@ -14557,20 +14557,20 @@ QualType TreeTransform<Derived>::RebuildPipeType(QualType ValueType,
 }
 
 template <typename Derived>
-QualType TreeTransform<Derived>::RebuildExtIntType(bool IsUnsigned,
+QualType TreeTransform<Derived>::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 <typename Derived>
-QualType TreeTransform<Derived>::RebuildDependentExtIntType(
+QualType TreeTransform<Derived>::RebuildDependentBitIntType(
     bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
-  return SemaRef.BuildExtIntType(IsUnsigned, NumBitsExpr, Loc);
+  return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
 }
 
 template<typename Derived>
index a033bcc..08f9346 100644 (file)
@@ -6772,11 +6772,11 @@ void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) {
   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 a1972f5..f3bccf9 100644 (file)
@@ -562,11 +562,11 @@ void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
   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 ae78af7..f804306 100644 (file)
@@ -30,7 +30,7 @@ template<int &&R> struct rval_ref; // expected-warning 0-1{{extension}} expected
 // 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 @@ public:
   RRef &ref_to_bad = *ptr_to_bad;
   _Complex int ci;
   _Complex float cf;
-  _ExtInt(42) ei;
+  _BitInt(42) ei;
   VI4 vi4;
   VF4 vf4;
 };
index 949e051..57c1ca0 100644 (file)
@@ -131,12 +131,12 @@ nullptr_t ret_npt() {
 }
 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 @@ void pass_large_extint(_ExtInt(127) e) {
 // 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 636a571..614a939 100644 (file)
@@ -41,7 +41,7 @@ int test_add_overflow_int_int_int(int x, int y) {
   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 @@ int test_add_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
   // 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 @@ int test_sub_overflow_int_int_int(int x, int y) {
   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 @@ int test_sub_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
   // 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 @@ int test_mul_overflow_int_int_int(int x, int y) {
   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 @@ int test_mul_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) {
   // 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 @@ int test_mul_overflow_xint127_xint127_xint127(_ExtInt(127) x, _ExtInt(127) y) {
   // 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 @@ int test_mul_overflow_xint128_xint128_xint128(_ExtInt(128) x, _ExtInt(128) y) {
   // 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 1073c63..a1179db 100644 (file)
@@ -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 @@ void ParamPassing(_ExtInt(129) a, _ExtInt(128) b, _ExtInt(64) c) {}
 // 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 @@ void ParamPassing2(_ExtInt(129) a, _ExtInt(127) b, _ExtInt(63) c) {}
 // 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 @@ void ParamPassing3(_ExtInt(15) a, _ExtInt(31) b) {}
 // 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 @@ _ExtInt(63) ReturnPassing(){}
 // 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 @@ _ExtInt(64) ReturnPassing2(){}
 // 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 @@ _ExtInt(127) ReturnPassing3(){}
 // 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 @@ _ExtInt(128) ReturnPassing4(){}
 // 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 @@ _ExtInt(129) ReturnPassing5(){}
 
 // 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 7b7a7f9..2659cba 100644 (file)
@@ -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 @@ void Enum() {
   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 @@ void Enum() {
 
 // 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 @@ void UIntTruncation(unsigned _ExtInt(35) E, unsigned int i, unsigned long long l
   // 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 @@ void IntTruncation(_ExtInt(35) E, unsigned _ExtInt(42) UE, int i, unsigned j) {
   // 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 @@ void SignChangeCheck(unsigned _ExtInt(39) UE, _ExtInt(39) E) {
   // 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 @@ void DivByZero(_ExtInt(11) E, int i) {
 
 // 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 @@ void Shifts(_ExtInt(9) E) {
   // 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 @@ void SignedIntegerOverflow(_ExtInt(93) BiggestE,
   // 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 44ac45b..fbc627d 100644 (file)
@@ -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 @@ void VLATest(_ExtInt(3) A, _ExtInt(99) B, _ExtInt(123456) C) {
 }
 
 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 @@ void OffsetOfTest() {
   // 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 8cdbda8..b72d526 100644 (file)
@@ -32,7 +32,7 @@ short s16;
 unsigned char u8;
 signed char s8;
 long long ll;
-_ExtInt(23) ei23;
+_BitInt(23) ei23;
 float ff;
 double dd;
 #ifdef D128
index 3d6457f..24c7b39 100644 (file)
@@ -17,55 +17,55 @@ namespace std {
 // 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;
 };
 // LIN64: %struct.BitFieldsLong = type { i8, [7 x i8] }
 // LIN32: %struct.BitFieldsLong = type { i8, [3 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() {
@@ -74,9 +74,9 @@ void StructEmit() {
   BitFieldsInt C;
   BitFieldsLong D;
 
-  HasExtIntFirst E;
-  HasExtIntLast F;
-  HasExtIntMiddle G;
+  HasBitIntFirst E;
+  HasBitIntLast F;
+  HasBitIntMiddle G;
 }
 
 void BitfieldAssignment() {
@@ -102,7 +102,7 @@ void BitfieldAssignment() {
   // CHECK: %[[SETC:.+]] = or i8 %[[CLEARC]], 64
 }
 
-enum AsEnumUnderlyingType : _ExtInt(9) {
+enum AsEnumUnderlyingType : _BitInt(9) {
   A,B,C
 };
 
@@ -115,40 +115,47 @@ void UnderlyingTypeUsage(AsEnumUnderlyingType Param) {
   // CHECK: store i9 %{{.*}}, align 2
 }
 
-unsigned _ExtInt(33) ManglingTestRetParam(unsigned _ExtInt(33) Param) {
-// LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i64 %
-// LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i33 %
-// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UExtInt@$0CB@@__clang@@U12@@Z"(i33
+unsigned _BitInt(33) ManglingTestRetParam(unsigned _BitInt(33) Param) {
+// LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamDU33_(i64 %
+// LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamDU33_(i33 %
+// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UBitInt@$0CB@@__clang@@U12@@Z"(i33
   return 0;
 }
 
-_ExtInt(33) ManglingTestRetParam(_ExtInt(33) Param) {
-// LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i64 %
-// LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i33 %
-// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_ExtInt@$0CB@@__clang@@U12@@Z"(i33
+_BitInt(33) ManglingTestRetParam(_BitInt(33) Param) {
+// LIN64: define{{.*}} i64 @_Z20ManglingTestRetParamDB33_(i64 %
+// LIN32: define{{.*}} i33 @_Z20ManglingTestRetParamDB33_(i33 %
+// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_BitInt@$0CB@@__clang@@U12@@Z"(i33
   return 0;
 }
 
 template<typename T>
 void ManglingTestTemplateParam(T&);
-template<_ExtInt(99) T>
+template<_BitInt(99) T>
 void ManglingTestNTTP();
+template <int N>
+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*
-// WIN64: call void @"??$ManglingTestTemplateParam@U?$_ExtInt@$0FN@@__clang@@@@YAXAEAU?$_ExtInt@$0FN@@__clang@@@Z"(i93*
-// WIN32: call void @"??$ManglingTestTemplateParam@U?$_ExtInt@$0FN@@__clang@@@@YAXAAU?$_ExtInt@$0FN@@__clang@@@Z"(i93*
-  constexpr _ExtInt(93) B = 993;
+// LIN: call void @_Z25ManglingTestTemplateParamIDB93_EvRT_(i93*
+// WIN64: call void @"??$ManglingTestTemplateParam@U?$_BitInt@$0FN@@__clang@@@@YAXAEAU?$_BitInt@$0FN@@__clang@@@Z"(i93*
+// WIN32: call void @"??$ManglingTestTemplateParam@U?$_BitInt@$0FN@@__clang@@@@YAXAAU?$_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<B>();
-// 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()
+  // WIN64: call i4 @"??$ManglingDependent@$03@@YAU?$_BitInt@$03@__clang@@XZ"()
+  // WIN32: call signext i4 @"??$ManglingDependent@$03@@YAU?$_BitInt@$03@__clang@@XZ"()
 }
 
 void TakesVarargs(int i, ...) {
@@ -170,7 +177,7 @@ void TakesVarargs(int i, ...) {
   // 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));
   // LIN64: %[[AD1:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]]
   // LIN64: %[[OFA_P1:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD1]], i32 0, i32 0
   // LIN64: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P1]]
@@ -203,7 +210,7 @@ void TakesVarargs(int i, ...) {
   // WIN32: store i92 %[[LOADV1]], i92*
 
 
-  _ExtInt(31) B = __builtin_va_arg(args, _ExtInt(31));
+  _BitInt(31) B = __builtin_va_arg(args, _BitInt(31));
   // LIN64: %[[AD2:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]]
   // LIN64: %[[OFA_P2:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD2]], i32 0, i32 0
   // LIN64: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P2]]
@@ -234,7 +241,7 @@ void TakesVarargs(int i, ...) {
   // WIN32: %[[LOADV2:.+]] = load i31, i31* %[[BC2]]
   // WIN32: store i31 %[[LOADV2]], i31*
 
-  _ExtInt(16) C = __builtin_va_arg(args, _ExtInt(16));
+  _BitInt(16) C = __builtin_va_arg(args, _BitInt(16));
   // LIN64: %[[AD3:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]]
   // LIN64: %[[OFA_P3:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD3]], i32 0, i32 0
   // LIN64: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P3]]
@@ -266,7 +273,7 @@ void TakesVarargs(int i, ...) {
   // WIN32: store i16 %[[LOADV3]], i16*
 
 
-  _ExtInt(129) D = __builtin_va_arg(args, _ExtInt(129));
+  _BitInt(129) D = __builtin_va_arg(args, _BitInt(129));
   // LIN64: %[[AD4:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]]
   // LIN64: %[[OFA_P4:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD4]], i32 0, i32 2
   // LIN64: %[[OFA4:.+]] = load i8*, i8** %[[OFA_P4]]
@@ -298,7 +305,7 @@ void TakesVarargs(int i, ...) {
   // WIN32: %[[LOADV4:.+]] = load i129, i129* %[[BC4]]
   // WIN32: store i129 %[[LOADV4]], i129*
 
-  _ExtInt(8388600) E = __builtin_va_arg(args, _ExtInt(8388600));
+  _BitInt(8388600) E = __builtin_va_arg(args, _BitInt(8388600));
   // LIN64: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]]
   // LIN64: %[[OFA_P5:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD5]], i32 0, i32 2
   // LIN64: %[[OFA5:.+]] = load i8*, i8** %[[OFA_P5]]
@@ -342,48 +349,48 @@ void TakesVarargs(int i, ...) {
 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);
- // LIN64: 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"*))
- // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*))
- // WIN64: 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"*))
- // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
+ // LIN64: 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"*))
+ // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIDU33_ to %"class.std::type_info"*))
+ // WIN64: 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"*))
+ // WIN32: call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UBitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
  auto B = typeid(U33_2);
- // LIN64: 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"*))
- // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*))
- // WIN64:  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"*))
- // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
+ // LIN64: 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"*))
+ // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIDU33_ to %"class.std::type_info"*))
+ // WIN64:  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"*))
+ // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UBitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
  auto C = typeid(S33_1);
- // LIN64: 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"*))
- // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*))
- // WIN64:  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"*))
- // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
+ // LIN64: 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"*))
+ // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIDB33_ to %"class.std::type_info"*))
+ // WIN64:  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"*))
+ // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
  auto D = typeid(S33_2);
- // LIN64: 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"*))
- // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*))
- // WIN64:  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"*))
- // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
+ // LIN64: 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"*))
+ // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIDB33_ to %"class.std::type_info"*))
+ // WIN64:  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"*))
+ // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*))
  auto E = typeid(S32_1);
- // LIN64: 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"*))
- // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*))
- // WIN64:  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"*))
- // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*))
+ // LIN64: 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"*))
+ // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIDB32_ to %"class.std::type_info"*))
+ // WIN64:  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"*))
+ // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CA@@__clang@@@8" to %"class.std::type_info"*))
  auto F = typeid(S32_2);
- // LIN64: 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"*))
- // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*))
- // WIN64:  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"*))
- // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*))
+ // LIN64: 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"*))
+ // LIN32: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) bitcast ({ i8*, i8* }* @_ZTIDB32_ to %"class.std::type_info"*))
+ // WIN64:  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"*))
+ // WIN32:  call x86_thiscallcc %"class.std::type_info"* @"??0type_info@std@@QAE@ABV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 4 dereferenceable(8) 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;
@@ -397,9 +404,9 @@ void ExplicitCasts() {
 }
 
 struct S {
-  _ExtInt(17) A;
-  _ExtInt(8388600) B;
-  _ExtInt(17) C;
+  _BitInt(17) A;
+  _BitInt(8388600) B;
+  _BitInt(17) C;
 };
 
 void OffsetOfTest() {
@@ -419,9 +426,9 @@ void OffsetOfTest() {
 }
 
 
-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;
@@ -438,9 +445,9 @@ void ShiftExtIntByConstant(_ExtInt(28) Ext) {
   // 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]]
@@ -455,9 +462,9 @@ void ConstantShiftByExtInt(_ExtInt(28) Ext, _ExtInt(65) LargeExt) {
   // 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]]
@@ -501,10 +508,9 @@ void Shift(_ExtInt(28) Ext, _ExtInt(65) LargeExt, int i) {
   // 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]]
@@ -521,9 +527,9 @@ void ComplexTest(_Complex _ExtInt(12) first,
 }
 
 // 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:.+]]
@@ -535,13 +541,13 @@ void TBAATest(_ExtInt(sizeof(int) * 8) ExtInt,
 // 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 4d2292d..adf4a97 100644 (file)
@@ -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 e57ef1d..3bb1dea 100644 (file)
@@ -265,6 +265,6 @@ struct B {
   typedef typename A_type<value>::type type;
 };
 
-void bar(_ExtInt(66) a) {
+void bar(_BitInt(66) a) {
   auto b = a;
 }
index 4926d51..e709493 100644 (file)
@@ -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 0e6152f..348a3a0 100644 (file)
@@ -21,21 +21,21 @@ void test(void) {
   __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 e534f47..51f61c3 100644 (file)
@@ -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 @@ void test21(const int *ptr) {
   __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 9cca3d2..ebc5bc6 100644 (file)
@@ -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 @@ void Ternary(_ExtInt(30) s30, EI31 s31a, _ExtInt(31) s31b,
 }
 
 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 Ops(void) {
 
 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 41ca949..9e57730 100644 (file)
@@ -34,6 +34,6 @@ struct Z {
 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 c7434d2..7661ebe 100644 (file)
@@ -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 b3bcd19..675aaa7 100644 (file)
@@ -2,72 +2,72 @@
 
 template<int Bounds>
 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<typename T>
 void deduced_whole_type(T){}
 template<int I>
-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<b> c;
-  constexpr _ExtInt(9) d = 1;
+  constexpr _BitInt(9) d = 1;
   ExtIntTemplParam<b> e;
 
   deduced_whole_type(b);
@@ -84,28 +84,28 @@ struct is_same<T,T> {
 };
 
 // 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 @@ void Ops() {
   x4_u - b;
   x43_s + b;
   x43_u - b;
-  static_assert(is_same<decltype(x43_s + x_int), _ExtInt(43)>::value, "");
-  static_assert(is_same<decltype(x43_u + x_int), unsigned _ExtInt(43)>::value, "");
+  static_assert(is_same<decltype(x43_s + x_int), _BitInt(43)>::value, "");
+  static_assert(is_same<decltype(x43_u + x_int), unsigned _BitInt(43)>::value, "");
   static_assert(is_same<decltype(x32_s + x_int), int>::value, "");
   static_assert(is_same<decltype(x32_u + x_int), unsigned int>::value, "");
   static_assert(is_same<decltype(x32_s + x_uint), unsigned int>::value, "");
@@ -157,71 +157,71 @@ void Ops() {
 
   // 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<decltype(x43_s + y43_s), _ExtInt(43)>::value,"");
-  static_assert(is_same<decltype(x4_s - y4_s), _ExtInt(4)>::value,"");
-  static_assert(is_same<decltype(x43_u * y43_u), unsigned _ExtInt(43)>::value,"");
-  static_assert(is_same<decltype(x4_u / y4_u), unsigned _ExtInt(4)>::value,"");
+  static_assert(is_same<decltype(x43_s + y43_s), _BitInt(43)>::value,"");
+  static_assert(is_same<decltype(x4_s - y4_s), _BitInt(4)>::value,"");
+  static_assert(is_same<decltype(x43_u * y43_u), unsigned _BitInt(43)>::value,"");
+  static_assert(is_same<decltype(x4_u / y4_u), unsigned _BitInt(4)>::value,"");
 
   // Unary ops shouldn't go through integer promotions.
-  static_assert(is_same<decltype(~x43_s), _ExtInt(43)>::value,"");
-  static_assert(is_same<decltype(~x4_s), _ExtInt(4)>::value,"");
-  static_assert(is_same<decltype(+x43_s), _ExtInt(43)>::value,"");
-  static_assert(is_same<decltype(+x4_s), _ExtInt(4)>::value,"");
-  static_assert(is_same<decltype(-x43_u), unsigned _ExtInt(43)>::value,"");
-  static_assert(is_same<decltype(-x4_u), unsigned _ExtInt(4)>::value,"");
+  static_assert(is_same<decltype(~x43_s), _BitInt(43)>::value,"");
+  static_assert(is_same<decltype(~x4_s), _BitInt(4)>::value,"");
+  static_assert(is_same<decltype(+x43_s), _BitInt(43)>::value,"");
+  static_assert(is_same<decltype(+x4_s), _BitInt(4)>::value,"");
+  static_assert(is_same<decltype(-x43_u), unsigned _BitInt(43)>::value,"");
+  static_assert(is_same<decltype(-x4_u), unsigned _BitInt(4)>::value,"");
   // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}}
-  static_assert(is_same<decltype(++x43_s), _ExtInt(43)&>::value,"");
+  static_assert(is_same<decltype(++x43_s), _BitInt(43)&>::value,"");
   // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}}
-  static_assert(is_same<decltype(--x4_s), _ExtInt(4)&>::value,"");
+  static_assert(is_same<decltype(--x4_s), _BitInt(4)&>::value,"");
   // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}}
-  static_assert(is_same<decltype(x43_s--), _ExtInt(43)>::value,"");
+  static_assert(is_same<decltype(x43_s--), _BitInt(43)>::value,"");
   // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}}
-  static_assert(is_same<decltype(x4_s++), _ExtInt(4)>::value,"");
-  static_assert(is_same<decltype(x4_s >> 1), _ExtInt(4)>::value,"");
-  static_assert(is_same<decltype(x4_u << 1), unsigned _ExtInt(4)>::value,"");
+  static_assert(is_same<decltype(x4_s++), _BitInt(4)>::value,"");
+  static_assert(is_same<decltype(x4_s >> 1), _BitInt(4)>::value,"");
+  static_assert(is_same<decltype(x4_u << 1), unsigned _BitInt(4)>::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<decltype(F), _ExtInt(42)>::value, "");
+  _BitInt(func()) F;
+  static_assert(is_same<decltype(F), _BitInt(42)>::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 @@ void overload_use() {
 
 // 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 @@ void ImplicitCasts(_ExtInt(31) s31, _ExtInt(33) s33, int i) {
   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<decltype(b ? s30 : s31a), _ExtInt(31)>::value, "");
-  static_assert(is_same<decltype(b ? s32 : s30), _ExtInt(32)>::value, "");
+  static_assert(is_same<decltype(b ? s30 : s31a), _BitInt(31)>::value, "");
+  static_assert(is_same<decltype(b ? s32 : s30), _BitInt(32)>::value, "");
   static_assert(is_same<decltype(b ? s30 : 0), int>::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<decltype(a2 * a3), _ExtInt(3)>::value, "");
+  static_assert(is_same<decltype(a2 * a3), _BitInt(3)>::value, "");
   static_assert(is_same<decltype(a2 * c), int>::value, "");
-  static_assert(is_same<decltype(a33 * c), _ExtInt(33)>::value, "");
+  static_assert(is_same<decltype(a33 * c), _BitInt(33)>::value, "");
 }
 
-void FromPaper2(_ExtInt(8) a1, _ExtInt(24) a2) {
-  static_assert(is_same<decltype(a1 * (_ExtInt(32))a2), _ExtInt(32)>::value, "");
+void FromPaper2(_BitInt(8) a1, _BitInt(24) a2) {
+  static_assert(is_same<decltype(a1 * (_BitInt(32))a2), _BitInt(32)>::value, "");
 }
index ab3bf22..b66cf57 100644 (file)
@@ -1815,8 +1815,8 @@ DEFAULT_TYPELOC_IMPL(Enum, TagType)
 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.