[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 21 03:02:20 PDT 2025


================
@@ -4745,7 +4760,10 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
 
   // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
   return new (Context) UnaryExprOrTypeTraitExpr(
-      ExprKind, E, Context.getSizeType(), OpLoc, E->getSourceRange().getEnd());
+      ExprKind, E,
+      Context.getCGlobalCXXStdNSTypedef(getStdNamespace(), "size_t",
+                                        Context.getSizeType()),
+      OpLoc, E->getSourceRange().getEnd());
----------------
zyn0217 wrote:

Mentioning `getStdNamespace` for C is really not great. Couldn't we merge getCGlobalCXXStdNSTypedef into Context.getSizeType?

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


More information about the cfe-commits mailing list