Prior to this change we had a mixture of pragmas and
GTEST_DISABLE_MSC_WARNINGS; this change consolidates all instances
to use the macros.
PiperOrigin-RevId: 505786926
Change-Id: I2be8f6304387393995081af42ed32c2ad1bba5a7
Avoid instantiating functions like std::get<index> for an out of range index
when doing SFINAE on the invocability of the action itself.
PiperOrigin-RevId: 439415110
Change-Id: Ifc20285a6d526c34830870cd1910c2b2b92e1e81
A few tests are examining code locations and looking af the resulting line
numbers to verify that GoogleTest shows those to users correctly. Some of those
locations change when clang-format is run. For those locations, I've wrapped
portions in:
// clang-format off
...
// clang-format on
There may be other locations that are currently not tickled by running
clang-format.
PiperOrigin-RevId: 434844712
Change-Id: I3a9f0a6f39eff741c576b6de389bef9b1d11139d
Use a tagged constructor for FlatTuple instead.
Some versions of MSVC are getting confused with that constructor and generating invalid code.
PiperOrigin-RevId: 342050957
Change ACTION{,_Pn,_TEMPLATE} macros to build functors rather than ActionInterface<> subclasses, thus changing the Action<> wrappers they create to use the modernized (non-const) argument tuple type, allowing these macros to mutate their arguments.
Functor-based Action<>s deep-copy the implementing object, so have the functors use a shared_ptr to the non-trivial state of bound value parameters. No longer specialize that shared state to the particular action signature, encoding that information instead only in the instantiation of the implementation function.
PiperOrigin-RevId: 341116208
Mark ACTION_Pn()-generated functions as must-use-result.
This catches when a client creates an action and discards it, thinking that the action has actually been applied to something.
This will help people who make the mistake of defining, for example, both `void Use(Foo*)` and `ACTION(Use) { Use(arg); }` for later application to a Foo. With such an overload, a client may then write `Use();`, forgetting the param and being confused why nothing happens.
This also catches when a client defines their own action in terms of an ACTION()-generated one, invokes the ACTION's builder, and then fails to invoke the resulting action, thinking it's operating on the outer action's parameters.
PiperOrigin-RevId: 330614454
Mark ACTION_Pn()-generated functions as must-use-result.
This catches when a client creates an action and discards it, thinking that the action has actually been applied to something.
This will help people who make the mistake of defining, for example, both `void Use(Foo*)` and `ACTION(Use) { Use(arg); }` for later application to a Foo. With such an overload, a client may then write `Use();`, forgetting the param and being confused why nothing happens.
This also catches when a client defines their own action in terms of an ACTION()-generated one, invokes the ACTION's builder, and then fails to invoke the resulting action, thinking it's operating on the outer action's parameters.
PiperOrigin-RevId: 312108101
Fix `-Wgnu-zero-variadic-macro-arguments` in GMock
Passing zero arguments to the variadic part of a macro is a GNU
extension and triggers warnings when build projects using GMock with
`-pedantic`.
- Fix uses of `GMOCK_PP_INTERNAL_16TH` to always receive at least 17
arguments. (this was triggered when `GMOCK_PP_NARG` or `GMOCK_PP_HAS_COMMA`
were used with an argument containing no commas).
- Fix `GMOCK_PP_HEAD` to append a dummy unused argument so that
`GMOCK_PP_INTERNAL_HEAD` always has two arguments.
PiperOrigin-RevId: 310414611
None of these are strictly needed for correctness.
A large number of them (maybe all of them?) trigger `-Wdeprecated`
warnings on Clang trunk as soon as you try to use the implicitly
defaulted (but deprecated) copy constructor of a class that has
deleted its copy assignment operator.
By declaring a deleted copy assignment operator, the old code
also caused the move constructor and move assignment operator
to be non-declared. This means that the old code never got move
semantics -- "move-construction" would simply call the defaulted
(but deprecated) copy constructor instead. With the new code,
"move-construction" calls the defaulted move constructor, which
I believe is what we want to happen. So this is a runtime
performance optimization.
Unfortunately we can't yet physically remove the definitions
of these macros from gtest-port.h, because they are being used
by other code internally at Google (according to zhangxy988).
But no new uses should be added going forward.
Use GMOCK_PP to create GMOCK_INTERNAL_ACTION macro.
Create GMOCK_INTERNAL_ACTION macro that generates ACTION_P* macroses using
GMOCK_PP.
PiperOrigin-RevId: 289815906
Use GMOCK_PP to generate args boilerplate.
Move common args describing part to separate macroses that uses GMOCK_PP to
generate sequences.
PiperOrigin-RevId: 289655624
Move part of functionality of Action* class to the base one. Reduce copypaste.
Make constructor and conversion operator of Action* class independent of pump.
PiperOrigin-RevId: 288907005
Use C++11 variadic templates for Invoke in gmock-generated-actions.h.
Replace InvokeArgumentAdl with Invoke that uses C++11 variadic templates.
PiperOrigin-RevId: 288449236
Use C++11 variadic templates for InvokeArgumentAdl in gmock-generated-actions.h.
Make InvokeArgumentAdl use variadic templates to generate its overloads instead
of using pump.py syntax.
PiperOrigin-RevId: 286267615
Use C++11 variadic templates for InvokeArgumentAdl in gmock-generated-actions.h.
Make InvokeArgumentAdl use variadic templates to generate its overloads instead
of using pump.py syntax.
PiperOrigin-RevId: 286148805
Use C++11 variadic templates for ActionHelper in gmock-generated-actions.h.
Make ActionHelper use variadic templates to generate Perform static member function specializations instead of using pump.py syntax.
PiperOrigin-RevId: 284988441
Mark more functions with "override" keyword, just like
it was done in commit 2460f97152.
This should prevent compiler from complaining while compiling both
user code, and the googletest code itself with the -Wsuggest-override
option turned on; with the exception of:
* calls to new MOCK_METHOD() in test/gmock-function-mocker_test.cc
* calls to old MOCK_METHODx()/MOCK_CONST_METHODx() in other
unit test files.
Closes#2493
Refactor the `Invoke` and `InvokeWithoutArgs` actions:
- Replace pump'd classes and functions with templates.
- Make the polymorphic actions be polymorphic functors instead.
- Fix Invoke(Callback*) to work with subclasses of the callbacks, instead of trying to diagnose that in gmock_doctor.
PiperOrigin-RevId: 229604112