[clang] [clang][NFC] Simplify implementation of `IgnoreExprNodes` (PR #164193)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 19 16:56:21 PDT 2025


https://github.com/localspook created https://github.com/llvm/llvm-project/pull/164193

Using a fold instead of template recursion.

>From b7188eaa663d10dccc45719fd6b0db8866d07a05 Mon Sep 17 00:00:00 2001
From: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: Sun, 19 Oct 2025 16:53:22 -0700
Subject: [PATCH] [clang][NFC] Simplify implementation of `IgnoreExprNodes`

---
 clang/include/clang/AST/IgnoreExpr.h | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/clang/include/clang/AST/IgnoreExpr.h b/clang/include/clang/AST/IgnoreExpr.h
index 917bada61fa6f..bf098f3f09068 100644
--- a/clang/include/clang/AST/IgnoreExpr.h
+++ b/clang/include/clang/AST/IgnoreExpr.h
@@ -17,16 +17,6 @@
 #include "clang/AST/ExprCXX.h"
 
 namespace clang {
-namespace detail {
-/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
-/// Return Fn_n(...(Fn_1(E)))
-inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; }
-template <typename FnTy, typename... FnTys>
-Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
-  return IgnoreExprNodesImpl(std::forward<FnTy>(Fn)(E),
-                             std::forward<FnTys>(Fns)...);
-}
-} // namespace detail
 
 /// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
 /// Recursively apply each of the functions to E until reaching a fixed point.
@@ -35,7 +25,7 @@ template <typename... FnTys> Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
   Expr *LastE = nullptr;
   while (E != LastE) {
     LastE = E;
-    E = detail::IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
+    ((E = std::forward<FnTys>(Fns)(E)), ...);
   }
   return E;
 }



More information about the cfe-commits mailing list