Googletest export

Stop using ADL for InvokeArgument action.

PiperOrigin-RevId: 323234396
This commit is contained in:
ofats 2020-07-26 08:05:02 -04:00 committed by Mark Barolak
parent a781fe29bc
commit c64309924d
4 changed files with 24 additions and 59 deletions

View File

@ -423,7 +423,7 @@ messages, you can use:
<!-- GOOGLETEST_CM0026 DO NOT DELETE --> <!-- GOOGLETEST_CM0026 DO NOT DELETE -->
<!-- GOOGLETEST_CM0027 DO NOT DELETE --> <!--#include file="includes/g3_util_status_matcher.md"-->
### Multi-argument Matchers {#MultiArgMatchers} ### Multi-argument Matchers {#MultiArgMatchers}

View File

@ -1388,23 +1388,15 @@ class ActionImpl<Derived<Ts...>> {
std::tuple<Ts...> params_; std::tuple<Ts...> params_;
}; };
namespace invoke_argument { // internal::InvokeArgument - a helper for InvokeArgument action.
// Appears in InvokeArgumentAdl's argument list to help avoid
// accidental calls to user functions of the same name.
struct AdlTag {};
// InvokeArgumentAdl - a helper for InvokeArgument.
// The basic overloads are provided here for generic functors. // The basic overloads are provided here for generic functors.
// Overloads for other custom-callables are provided in the // Overloads for other custom-callables are provided in the
// internal/custom/gmock-generated-actions.h header. // internal/custom/gmock-generated-actions.h header.
template <typename F, typename... Args> template <typename F, typename... Args>
auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { auto InvokeArgument(F f, Args... args) -> decltype(f(args...)) {
return f(args...); return f(args...);
} }
} // namespace invoke_argument
#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \ #define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
, const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_ , const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \ #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \

View File

@ -47,6 +47,8 @@
#include "gmock/gmock-actions.h" #include "gmock/gmock-actions.h"
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
// Include any custom callback actions added by the local installation.
#include "gmock/internal/custom/gmock-generated-actions.h"
// Sometimes you want to give an action explicit template parameters // Sometimes you want to give an action explicit template parameters
// that cannot be inferred from its value parameters. ACTION() and // that cannot be inferred from its value parameters. ACTION() and
@ -511,91 +513,71 @@ namespace testing {
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_0_VALUE_PARAMS()) { AND_0_VALUE_PARAMS()) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args));
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args));
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(p0)) { AND_1_VALUE_PARAMS(p0)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0);
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args), p0);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_2_VALUE_PARAMS(p0, p1)) { AND_2_VALUE_PARAMS(p0, p1)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1);
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args), p0, p1);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_3_VALUE_PARAMS(p0, p1, p2)) { AND_3_VALUE_PARAMS(p0, p1, p2)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2);
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args), p0, p1, p2);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2, p3);
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args), p0, p1, p2, p3);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2, p3, p4);
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args), p0, p1, p2, p3, p4);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2, p3, p4, p5);
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args), p0, p1, p2, p3, p4, p5);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2, p3, p4, p5,
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), p6);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2, p3, p4, p5,
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), p6, p7);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2, p3, p4, p5,
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), p6, p7, p8);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7,
p8);
} }
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args), p0, p1, p2, p3, p4, p5,
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), p6, p7, p8, p9);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7,
p8, p9);
} }
#ifdef _MSC_VER #ifdef _MSC_VER
@ -604,9 +586,4 @@ ACTION_TEMPLATE(InvokeArgument,
} // namespace testing } // namespace testing
// Include any custom callback actions added by the local installation.
// We must include this header at the end to make sure it can use the
// declarations from this file.
#include "gmock/internal/custom/gmock-generated-actions.h"
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_

View File

@ -49,6 +49,9 @@ $$}} This meta comment fixes auto-indentation in editors.
#include "gmock/gmock-actions.h" #include "gmock/gmock-actions.h"
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
// Include any custom callback actions added by the local installation.
#include "gmock/internal/custom/gmock-generated-actions.h"
$range i 0..n $range i 0..n
$range k 0..n-1 $range k 0..n-1
@ -333,9 +336,7 @@ $range j 0..i-1
ACTION_TEMPLATE(InvokeArgument, ACTION_TEMPLATE(InvokeArgument,
HAS_1_TEMPLATE_PARAMS(int, k), HAS_1_TEMPLATE_PARAMS(int, k),
AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) { AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) {
using internal::invoke_argument::InvokeArgumentAdl; return internal::InvokeArgument(::std::get<k>(args)$for j[[, p$j]]);
return InvokeArgumentAdl(internal::invoke_argument::AdlTag(),
::std::get<k>(args)$for j[[, p$j]]);
} }
]] ]]
@ -346,9 +347,4 @@ ACTION_TEMPLATE(InvokeArgument,
} // namespace testing } // namespace testing
// Include any custom callback actions added by the local installation.
// We must include this header at the end to make sure it can use the
// declarations from this file.
#include "gmock/internal/custom/gmock-generated-actions.h"
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_