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

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 21 03:36:16 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());
----------------
YexuanXiao wrote:

Is it appropriate to change it to `getLangOpts().CPlusPlus ? getStdNamespace() : nullptr`? I’m concerned that moving it into `getSizeType` might introduce unintended effects.

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


More information about the cfe-commits mailing list