diff --git a/src/V3Ast.h b/src/V3Ast.h index dbea12f40..f6d42fdaf 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2569,14 +2569,6 @@ private: template inline static bool predicateImpl(ConstCorrectAstNode* nodep, const Callable& p); - template - struct Arg0NoPointerNoCV final { - using Traits = FunctionTraits; - using T_Arg0 = typename Traits::template arg<0>::type; - using T_Arg0NoPtr = typename std::remove_pointer::type; - using type = typename std::remove_cv::type; - }; - public: // Given a callable 'f' that takes a single argument of some AstNode subtype 'T_Node', traverse // the tree rooted at this node, and call 'f' in pre-order on each node that is of type @@ -2587,7 +2579,7 @@ public: // caches in modern CPUs, while it is basically unpredictable for VNVisitor. template void foreach(Callable&& f) { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable::value && std::is_base_of::value, "Callable 'f' must have a signature compatible with 'void(T_Node*)', " @@ -2598,7 +2590,7 @@ public: // Same as above, but for 'const' nodes template void foreach(Callable&& f) const { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable::value && std::is_base_of::value, "Callable 'f' must have a signature compatible with 'void(const T_Node*)', " @@ -2609,7 +2601,7 @@ public: // Same as 'foreach' but also traverses 'this->nextp()' transitively template void foreachAndNext(Callable&& f) { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable::value && std::is_base_of::value, "Callable 'f' must have a signature compatible with 'void(T_Node*)', " @@ -2620,7 +2612,7 @@ public: // Same as above, but for 'const' nodes template void foreachAndNext(Callable&& f) const { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable::value && std::is_base_of::value, "Callable 'f' must have a signature compatible with 'void(const T_Node*)', " @@ -2635,7 +2627,7 @@ public: // be determined. template bool exists(Callable&& p) { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable_r::value && std::is_base_of::value, "Predicate 'p' must have a signature compatible with 'bool(T_Node*)', " @@ -2646,7 +2638,7 @@ public: // Same as above, but for 'const' nodes template bool exists(Callable&& p) const { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable_r::value && std::is_base_of::value, "Predicate 'p' must have a signature compatible with 'bool(const T_Node*)', " @@ -2660,7 +2652,7 @@ public: // in some arbitrary order and is terminated as soon as the result can be determined. template bool forall(Callable&& p) { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable_r::value && std::is_base_of::value, "Predicate 'p' must have a signature compatible with 'bool(T_Node*)', " @@ -2671,7 +2663,7 @@ public: // Same as above, but for 'const' nodes template bool forall(Callable&& p) const { - using T_Node = typename Arg0NoPointerNoCV::type; + using T_Node = typename FunctionArgNoPointerNoCV::type; static_assert(vlstd::is_invocable_r::value && std::is_base_of::value, "Predicate 'p' must have a signature compatible with 'bool(const T_Node*)', " diff --git a/src/V3FunctionTraits.h b/src/V3FunctionTraits.h index 02acf2c8a..9287048b8 100644 --- a/src/V3FunctionTraits.h +++ b/src/V3FunctionTraits.h @@ -47,4 +47,12 @@ struct FunctionTraits VL_NOT_FINAL { }; }; +template +struct FunctionArgNoPointerNoCV final { + using Traits = FunctionTraits; + using T_Arg = typename Traits::template arg::type; + using T_ArgNoPtr = typename std::remove_pointer::type; + using type = typename std::remove_cv::type; +}; + #endif