[clang] bbf19a6 - [AST] Use std::apply to pop front of tuples. NFCI.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 24 15:05:54 PDT 2022


Author: Benjamin Kramer
Date: 2022-08-25T00:03:08+02:00
New Revision: bbf19a6745d5e2caa60d466c3c9fc8bc8eac3474

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

LOG: [AST] Use std::apply to pop front of tuples. NFCI.

Added: 
    

Modified: 
    clang/lib/AST/ParentMapContext.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ParentMapContext.cpp b/clang/lib/AST/ParentMapContext.cpp
index e0d4700e4b10b..0840c573e0e45 100644
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -265,16 +265,6 @@ class ParentMapContext::ParentMap {
   }
 };
 
-template <typename Tuple, std::size_t... Is>
-auto tuple_pop_front_impl(const Tuple &tuple, std::index_sequence<Is...>) {
-  return std::make_tuple(std::get<1 + Is>(tuple)...);
-}
-
-template <typename Tuple> auto tuple_pop_front(const Tuple &tuple) {
-  return tuple_pop_front_impl(
-      tuple, std::make_index_sequence<std::tuple_size<Tuple>::value - 1>());
-}
-
 template <typename T, typename... U> struct MatchParents {
   static std::tuple<bool, DynTypedNodeList, const T *, const U *...>
   match(const DynTypedNodeList &NodeList,
@@ -285,10 +275,11 @@ template <typename T, typename... U> struct MatchParents {
       if (NextParentList.size() == 1) {
         auto TailTuple = MatchParents<U...>::match(NextParentList, ParentMap);
         if (std::get<bool>(TailTuple)) {
-          return std::tuple_cat(
-              std::make_tuple(true, std::get<DynTypedNodeList>(TailTuple),
-                              TypedNode),
-              tuple_pop_front(tuple_pop_front(TailTuple)));
+          return std::apply(
+              [TypedNode](bool, DynTypedNodeList NodeList, auto... TupleTail) {
+                return std::make_tuple(true, NodeList, TypedNode, TupleTail...);
+              },
+              TailTuple);
         }
       }
     }


        


More information about the cfe-commits mailing list