[clang] Reland [C++20] [Modules] Don't profiling the callee of CXXFoldExpr (#190732) (PR #195983)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Thu May 7 19:06:36 PDT 2026
================
@@ -2400,7 +2400,37 @@ void StmtProfiler::VisitMaterializeTemporaryExpr(
}
void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
- VisitExpr(S);
+ VisitStmtNoChildren(S);
+ // We intentionally not profile the callee sub-expression
+ // to keep the profiling result stable across different
+ // context.
+ //
+ // "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 might give different profiling results if we profile
+ // the callee sub-expression, which is nullptr in the first case
+ // an UnresolvedLookupExpr in the second case where there is a
+ // global operator&& operator that pollutes the fold expression.
+ if (S->getLHS())
+ Visit(S->getLHS());
+ else
+ ID.AddInteger(0);
+ if (S->getRHS())
+ Visit(S->getRHS());
+ else
+ ID.AddInteger(0);
----------------
mizvekov wrote:
But the bug has nothing to do with modules.
Surely we do not want to replicate or retest every test case as a modules test?
Our modus operandi here is to take a reproducer test from a bug report, and simplify it as much as possible.
If we take a bug report where the reproducer is a module test, but the bug has nothing to do with modules, we would just simplify that away.
https://github.com/llvm/llvm-project/pull/195983
More information about the cfe-commits
mailing list