[clang] 52534a1 - Revert "[C++20] [Modules] Don't profiling the callee of CXXFoldExpr (#190732)" (#193975)

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 24 07:22:04 PDT 2026


Author: Chuanqi Xu
Date: 2026-04-24T14:21:58Z
New Revision: 52534a1e1207aa1a983d7ee47e5e3a871b7373e5

URL: https://github.com/llvm/llvm-project/commit/52534a1e1207aa1a983d7ee47e5e3a871b7373e5
DIFF: https://github.com/llvm/llvm-project/commit/52534a1e1207aa1a983d7ee47e5e3a871b7373e5.diff

LOG: Revert "[C++20] [Modules] Don't profiling the callee of CXXFoldExpr (#190732)" (#193975)

This reverts commit 4c2e49dc5ce3125be9fb07dcefe9be970ce739ec.

See the discussion in https://github.com/llvm/llvm-project/pull/193885
for detail

Added: 
    

Modified: 
    clang/lib/AST/StmtProfile.cpp
    clang/test/Modules/polluted-operator.cppm

Removed: 
    clang/test/Modules/callable-require-clause-merge.cppm


################################################################################
diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index e71f6da8393f2..8219e57644be6 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -2400,35 +2400,7 @@ void StmtProfiler::VisitMaterializeTemporaryExpr(
 }
 
 void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
-  // For CXXFoldExpr, do not profile the callee 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 
diff erent profile results to F::operator() in
-  // "c.h" vs other use cases of "a.h". This is problematic in
-  // cases where we may have expression coming from 
diff erent
-  // headers, e.g., modules.
-  if (S->getLHS())
-    Visit(S->getLHS());
-  else
-    ID.AddInteger(0);
-  if (S->getRHS())
-    Visit(S->getRHS());
-  else
-    ID.AddInteger(0);
+  VisitExpr(S);
   ID.AddInteger(S->getOperator());
 }
 

diff  --git a/clang/test/Modules/callable-require-clause-merge.cppm b/clang/test/Modules/callable-require-clause-merge.cppm
deleted file mode 100644
index ae49dd7a58542..0000000000000
--- a/clang/test/Modules/callable-require-clause-merge.cppm
+++ /dev/null
@@ -1,35 +0,0 @@
-// RUN: rm -rf %t
-// RUN: mkdir -p %t
-// RUN: split-file %s %t
-//
-// RUN: %clang_cc1 -std=c++20 %t/mymod.cppm -emit-module-interface -o %t/mymod.pcm
-// RUN: %clang_cc1 -std=c++20 %t/consumer.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
-//
-// RUN: %clang_cc1 -std=c++20 %t/mymod.cppm -emit-reduced-module-interface -o %t/mymod.pcm
-// RUN: %clang_cc1 -std=c++20 %t/consumer.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
-
-// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/mymod.cppm -emit-module-interface -o %t/mymod.pcm
-// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/consumer.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
-//
-// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/mymod.cppm -emit-reduced-module-interface -o %t/mymod.pcm
-// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/consumer.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
-
-//--- r.h
-struct F {
-  template <typename... T> requires ((sizeof(T) > 0) && ...)
-  void operator()(T...) {}
-} f;
-
-//--- mymod.cppm
-module;
-#include "r.h"
-export module mymod;
-export using ::f;
-
-//--- consumer.cpp
-// expected-no-diagnostics
-void operator&&(struct X, struct X);
-#include "r.h"
-import mymod;
-
-void g() { f(); }

diff  --git a/clang/test/Modules/polluted-operator.cppm b/clang/test/Modules/polluted-operator.cppm
index e81a63c3e03de..45cc5e37d6a64 100644
--- a/clang/test/Modules/polluted-operator.cppm
+++ b/clang/test/Modules/polluted-operator.cppm
@@ -49,6 +49,8 @@ namespace std
 
 //--- a.cppm
 module;
+// The operator&& defined in 'foo.h' will pollute the 
+// expression '__is_trivial(_Types) && ...' in bar.h
 #include "foo.h"
 #include "bar.h"
 export module a;
@@ -69,4 +71,9 @@ export namespace std {
   using std::operator&&;
 }
 
+#ifdef SKIP_ODR_CHECK_IN_GMF
 // expected-no-diagnostics
+#else
+// expected-error@* {{has 
diff erent definitions in 
diff erent modules; first 
diff erence is defined here found data member '_S_copy_ctor' with an initializer}}
+// expected-note@* {{but in 'a.<global>' found data member '_S_copy_ctor' with a 
diff erent initializer}}
+#endif


        


More information about the cfe-commits mailing list