[clang] [clang] Fix side effects resolving overloads of builtin functions (#138651) (PR #154034)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 8 08:42:14 PDT 2025


================
@@ -6313,30 +6313,38 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
   unsigned i = 0;
   SmallVector<QualType, 8> OverloadParams;
 
-  for (QualType ParamType : FT->param_types()) {
+  {
+    // The lvalue conversions in this loop are only for type resolution and
+    // don't actually occur.
+    EnterExpressionEvaluationContext Unevaluated(
+        *Sema, Sema::ExpressionEvaluationContext::Unevaluated);
+    Sema::SFINAETrap Trap(*Sema);
----------------
cor3ntin wrote:

We probably want to do something like that
```suggestion
    Sema::SFINAETrap Trap(*Sema, /*ForValidityCheck=*/true);
```

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


More information about the cfe-commits mailing list