[clang] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 14 00:42:31 PDT 2025


================
@@ -8054,6 +8054,41 @@ class DependentBitIntType final : public Type, public llvm::FoldingSetNode {
   }
 };
 
+class PredefinedSugarType final : public Type {
+public:
+  enum Kind { SizeT, SignedSizeT, PtrdiffT };
+  friend class ASTContext;
+
+private:
+  Kind K;
+  QualType Underlying;
+  PredefinedSugarType(Kind KD, QualType UnderlyingType)
+      : Type(PredefinedSugar, UnderlyingType->getCanonicalTypeInternal(),
+             TypeDependence::None),
+        K(KD), Underlying(UnderlyingType) {}
+
+public:
+  bool isSugared() const { return true; }
+  QualType desugar() const { return Underlying; }
+  Kind getKind() const { return K; }
+
+  StringRef getName() const {
+    switch (K) {
+    case SizeT:
+      return "__size_t";
+    case SignedSizeT:
+      return "__signed_size_t";
+    case PtrdiffT:
+      return "__ptrdiff_t";
+    }
+    llvm_unreachable("");
----------------
mizvekov wrote:

```suggestion
    llvm_unreachable(unexpected kind");
```


https://github.com/llvm/llvm-project/pull/143653


More information about the cfe-commits mailing list