[llvm-branch-commits] [clang] release/22.x: [C++20] [Modules] Don't profile the callee of CXXFoldExpr (#190732) (PR #193885)

Aaron Ballman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 24 04:00:40 PDT 2026


================
@@ -2369,7 +2369,35 @@ void StmtProfiler::VisitMaterializeTemporaryExpr(
 }
 
 void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
-  VisitExpr(S);
+  // For CXXFoldExpr, not profile the call expression as it may
+  // be affected by the context. e.g.,
+  //
+  // "a.h"
+  //
+  //   struct F {
+  //     template <typename... T> requires ((sizeof(T) > 0) && ...)
+  //     void operator()(T...) {}
+  //   } f;
+  //
+  // and
+  //
+  // "c.h"
+  //
+  //   void operator&&(struct X, struct X);
+  //   #include "a.h"
+  //
+  // Here we may give different profile results to F::operator() in
----------------
AaronBallman wrote:

Oops, I accidentally added this as a comment on the commit instead of here, so repeating it:

What is special about fold expressions specifically -- wouldn't we hit the same issue with other binary expressions within a requires clause?

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


More information about the llvm-branch-commits mailing list