[libcxx-commits] [clang] [clang-tools-extra] [libcxx] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jun 28 19:11:44 PDT 2025
================
@@ -5216,6 +5237,25 @@ QualType ASTContext::getDependentBitIntType(bool IsUnsigned,
return QualType(New, 0);
}
+QualType ASTContext::getPredefinedSugarType(uint32_t KD) const {
+ using Kind = PredefinedSugarType::Kind;
+ auto getUnderlyingType = [](const ASTContext &Ctx, Kind KDI) -> QualType {
+ switch (KDI) {
+ case Kind::SizeT:
+ return Ctx.getFromTargetType(Ctx.Target->getSizeType());
+ case Kind::SignedSizeT:
+ return Ctx.getFromTargetType(Ctx.Target->getSignedSizeType());
+ case Kind::PtrdiffT:
+ return Ctx.getFromTargetType(Ctx.Target->getPtrDiffType(LangAS::Default));
+ }
+ llvm_unreachable("unexpected kind");
+ };
+ auto *New = new (*this, alignof(PredefinedSugarType)) PredefinedSugarType(
----------------
YexuanXiao wrote:
`SizeType` is frequently used both implicitly and explicitly. Looking it up via `FoldingSet` appears to be much slower than caching it. The other two are used much less frequently, and I have no preference.
https://github.com/llvm/llvm-project/pull/143653
More information about the libcxx-commits
mailing list