================
@@ -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);
----------------
ChuanqiXu9 wrote:
I have a different feeling. I manually reduced the issue before. The product is
clang/test/Modules/polluted-operator.cppm . I think it is precise enough to
describe the original issue. And this is the form that most people/end users
may meet in practice like the original issue reports.
And also I don't think these 2 tests are the same test. As the modules version
is about a false-positive test and the Sema test is a false-negative test. They
just have the same underlying code reason. But I don't think they are the same
test topologically.
https://github.com/llvm/llvm-project/pull/195983
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits