Mark invoker operator() as maybe-unused
Summary: [Folly] Mark invoker `operator()` as `[[maybe_unused]]` when defined in macros. If the macro is used in a `.cpp` but the generated `operator()` is not invoked, the compiler might warn. This can easily happen in the following situation: ``` FOLLY_CREATE_MEMBER_INVOKER(invoke_foo_fn, foo); FOLLY_CREATE_MEMBER_INVOKER(invoke_bar_fn, bar); using invoke_one_fn = std::conditional_t< /* cond */, invoke_foo_fn, invoke_bar_fn>; constexpr invoke_one_fn invoke_on; template <typename T> void go(T& t) { invoke_one(t); } ``` In such a situation, either `invoke_foo_fn::operator()` is seen at a call-site or `invoke_bar_fn::operator()` is seen at the call-site, but not both - one of them is unused, and if the right warnings are enabled, will be warned as unused. Reviewed By: luciang, markisaa Differential Revision: D22570047 fbshipit-source-id: a4caa7a95ab74ea075cf41c26525935f3d9186c0
Showing
Please register or sign in to comment