diff -Nru mysql-8.0-8.0.26/client/base/abstract_options_provider.cc mysql-8.0-8.0.27/client/base/abstract_options_provider.cc --- mysql-8.0-8.0.26/client/base/abstract_options_provider.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/abstract_options_provider.cc 2021-09-28 11:46:34.000000000 +0000 @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "client/base/i_options_provider.h" @@ -37,7 +38,6 @@ using std::string; using std::vector; using namespace Mysql::Tools::Base::Options; -using Mysql::Nullable; Simple_option *Abstract_options_provider::create_new_option( std::string name, std::string description) { @@ -58,13 +58,14 @@ } Password_option *Abstract_options_provider::create_new_password_option( - Nullable *value, std::string name, std::string description) { + std::optional *value, std::string name, std::string description) { return this->attach_new_option( new Password_option(value, name, description)); } String_option *Abstract_options_provider::create_new_option( - Nullable *value, std::string name, std::string description) { + std::optional *value, std::string name, + std::string description) { return this->attach_new_option( new String_option(value, name, description)); } diff -Nru mysql-8.0-8.0.26/client/base/abstract_options_provider.h mysql-8.0-8.0.27/client/base/abstract_options_provider.h --- mysql-8.0-8.0.26/client/base/abstract_options_provider.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/abstract_options_provider.h 2021-09-28 11:46:34.000000000 +0000 @@ -26,6 +26,7 @@ #define ABSTRACT_OPTIONS_PROVIDER_INCLUDED #include +#include #include #include "client/base/bool_option.h" @@ -81,22 +82,24 @@ Creates and attach new password option. It removes password from command-line on UNIX systems to prevent password to be seen when listing processes. - @param value Pointer to Nullable object to receive option value. + @param value Pointer to std::optional object to receive option + value. @param name Name of option. It is used in command line option name as --name. @param description Description of option to be printed in --help. */ - Password_option *create_new_password_option(Nullable *value, + Password_option *create_new_password_option(std::optional *value, std::string name, std::string description); /** Creates and attach new string option. - @param value Pointer to Nullable object to receive option value. + @param value Pointer to std::optional object to receive option + value. @param name Name of option. It is used in command line option name as --name. @param description Description of option to be printed in --help. */ - String_option *create_new_option(Nullable *value, + String_option *create_new_option(std::optional *value, std::string name, std::string description); /** Creates and attach new 32-bit signed number option. diff -Nru mysql-8.0-8.0.26/client/base/abstract_program.h mysql-8.0-8.0.27/client/base/abstract_program.h --- mysql-8.0-8.0.26/client/base/abstract_program.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/abstract_program.h 2021-09-28 11:46:34.000000000 +0000 @@ -120,9 +120,10 @@ Redirects call to option_parsed of main Abstract_program instance. If we have anonymous functions or binding this should be removed. */ - static bool callback_option_parsed( - int optid, const struct my_option *opt MY_ATTRIBUTE((unused)), - char *argument); + static bool callback_option_parsed(int optid, + const struct my_option *opt + [[maybe_unused]], + char *argument); Options::Debug_options m_debug_options; Options::Help_options m_help_options; diff -Nru mysql-8.0-8.0.26/client/base/abstract_string_option.h mysql-8.0-8.0.27/client/base/abstract_string_option.h --- mysql-8.0-8.0.26/client/base/abstract_string_option.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/abstract_string_option.h 2021-09-28 11:46:34.000000000 +0000 @@ -26,11 +26,11 @@ #define ABSTRACT_STRING_OPTION_INCLUDED #include +#include #include #include "client/base/abstract_value_option.h" #include "my_getopt.h" -#include "nullable.h" namespace Mysql { namespace Tools { @@ -58,10 +58,10 @@ --name. @param description Description of option to be printed in --help. */ - Abstract_string_option(Nullable *value, ulong var_type, + Abstract_string_option(std::optional *value, ulong var_type, std::string name, std::string description); - Nullable *m_destination_value; + std::optional *m_destination_value; private: void string_callback(char *argument); @@ -71,12 +71,12 @@ template Abstract_string_option::Abstract_string_option( - Nullable *value, ulong var_type, std::string name, + std::optional *value, ulong var_type, std::string name, std::string description) : Abstract_value_option(&this->m_original_value, var_type, name, description, (uint64)NULL), m_destination_value(value) { - *value = Nullable(); + *value = std::optional(); this->m_original_value = nullptr; this->add_callback(new std::function( @@ -86,7 +86,7 @@ template T_type *Abstract_string_option::set_value(std::string value) { - *this->m_destination_value = Nullable(value); + *this->m_destination_value = std::optional(value); this->m_original_value = this->m_destination_value->value().c_str(); this->m_option_structure.def_value = (uint64)this->m_destination_value->value().c_str(); @@ -97,7 +97,8 @@ void Abstract_string_option::string_callback(char *argument) { if (argument != nullptr) { // Copy argument value from char* to destination string. - *this->m_destination_value = Nullable(this->m_original_value); + *this->m_destination_value = + std::optional(this->m_original_value); } else { // There is no argument supplied, we shouldn't change default value. } diff -Nru mysql-8.0-8.0.26/client/base/CMakeLists.txt mysql-8.0-8.0.27/client/base/CMakeLists.txt --- mysql-8.0-8.0.26/client/base/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -20,6 +20,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/client/include +) + ADD_LIBRARY(client_base STATIC bool_option.cc char_array_option.cc @@ -44,6 +48,7 @@ show_variable_query_extractor.cc ${CMAKE_SOURCE_DIR}/sql-common/sql_string.cc + ${CMAKE_SOURCE_DIR}/client/multi_factor_passwordopt-vars.cc ) TARGET_LINK_LIBRARIES(client_base mysqlclient) diff -Nru mysql-8.0-8.0.26/client/base/debug_options.cc mysql-8.0-8.0.27/client/base/debug_options.cc --- mysql-8.0-8.0.26/client/base/debug_options.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/debug_options.cc 2021-09-28 11:46:34.000000000 +0000 @@ -77,8 +77,7 @@ #endif } -void Debug_options::debug_option_callback( - char *argument MY_ATTRIBUTE((unused))) { +void Debug_options::debug_option_callback(char *argument [[maybe_unused]]) { if (this->m_dbug_option.has_value()) { DBUG_PUSH(this->m_dbug_option.value().c_str()); } diff -Nru mysql-8.0-8.0.26/client/base/debug_options.h mysql-8.0-8.0.27/client/base/debug_options.h --- mysql-8.0-8.0.26/client/base/debug_options.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/debug_options.h 2021-09-28 11:46:34.000000000 +0000 @@ -25,9 +25,10 @@ #ifndef DEBUG_OPTIONS_INCLUDED #define DEBUG_OPTIONS_INCLUDED +#include + #include "client/base/abstract_options_provider.h" #include "my_compiler.h" -#include "nullable.h" namespace Mysql { namespace Tools { @@ -58,12 +59,12 @@ void options_parsed() override; private: - void debug_option_callback(char *argument MY_ATTRIBUTE((unused))); + void debug_option_callback(char *argument [[maybe_unused]]); Abstract_program *m_program; bool m_debug_info_flag{false}; bool m_debug_check_flag{false}; - Nullable m_dbug_option; + std::optional m_dbug_option; }; } // namespace Options diff -Nru mysql-8.0-8.0.26/client/base/help_options.cc mysql-8.0-8.0.27/client/base/help_options.cc --- mysql-8.0-8.0.26/client/base/help_options.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/help_options.cc 2021-09-28 11:46:34.000000000 +0000 @@ -55,12 +55,12 @@ std::bind(&Help_options::version_callback, this, _1))); } -void Help_options::help_callback(char *argument MY_ATTRIBUTE((unused))) { +void Help_options::help_callback(char *argument [[maybe_unused]]) { this->print_usage(); exit(0); } -void Help_options::version_callback(char *argument MY_ATTRIBUTE((unused))) { +void Help_options::version_callback(char *argument [[maybe_unused]]) { this->print_version_line(); exit(0); } diff -Nru mysql-8.0-8.0.26/client/base/help_options.h mysql-8.0-8.0.27/client/base/help_options.h --- mysql-8.0-8.0.26/client/base/help_options.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/help_options.h 2021-09-28 11:46:34.000000000 +0000 @@ -58,8 +58,8 @@ virtual void print_usage(); private: - void help_callback(char *argument MY_ATTRIBUTE((unused))); - void version_callback(char *argument MY_ATTRIBUTE((unused))); + void help_callback(char *argument [[maybe_unused]]); + void version_callback(char *argument [[maybe_unused]]); void print_version_line(); diff -Nru mysql-8.0-8.0.26/client/base/mysql_connection_options.cc mysql-8.0-8.0.27/client/base/mysql_connection_options.cc --- mysql-8.0-8.0.26/client/base/mysql_connection_options.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/mysql_connection_options.cc 2021-09-28 11:46:34.000000000 +0000 @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -34,10 +35,10 @@ #include "client/base/abstract_program.h" #include "compression.h" #include "m_ctype.h" +#include "multi_factor_passwordopt-vars.h" #include "mysys_err.h" #include "typelib.h" -using Mysql::Nullable; using Mysql::Tools::Base::Abstract_program; using namespace Mysql::Tools::Base::Options; using std::string; @@ -100,10 +101,20 @@ ->set_value_step(1024) ->set_value(1024 * 1024L - 1024); this->create_new_password_option( - &this->m_password, "password", + &this->m_password[0], "password", "Password to use when connecting to server. If password is not given," " it's solicited on the tty.") ->set_short_character('p'); + this->create_new_password_option( + &this->m_password[0], "password1", + "Password for first factor authentication plugin."); + this->create_new_password_option( + &this->m_password[1], "password2", + "Password for second factor authentication plugin."); + this->create_new_password_option( + &this->m_password[2], "password3", + "Password for third factor authentication plugin."); + #ifdef _WIN32 this->create_new_option("pipe", "Use named pipes to connect to server.") ->set_short_character('W') @@ -190,10 +201,12 @@ set_get_server_public_key_option(connection, &this->m_get_server_public_key); + /* set passwords for --password{1,2,3} */ + set_password_options(connection); + if (!mysql_real_connect(connection, this->get_null_or_string(this->m_host), - this->get_null_or_string(this->m_user), - this->get_null_or_string(this->m_password), nullptr, - this->m_mysql_port, + this->get_null_or_string(this->m_user), nullptr, + nullptr, this->m_mysql_port, this->get_null_or_string(this->m_mysql_unix_port), 0)) { this->db_error(connection, "while connecting to the MySQL server"); @@ -223,7 +236,7 @@ } const char *Mysql_connection_options::get_null_or_string( - Nullable &maybe_string) { + std::optional &maybe_string) { if (maybe_string.has_value()) { return maybe_string.value().c_str(); } else { @@ -232,14 +245,14 @@ } #ifdef _WIN32 -void Mysql_connection_options::pipe_protocol_callback( - char *not_used MY_ATTRIBUTE((unused))) { +void Mysql_connection_options::pipe_protocol_callback(char *not_used + [[maybe_unused]]) { this->m_protocol = MYSQL_PROTOCOL_PIPE; } #endif -void Mysql_connection_options::protocol_callback( - char *not_used MY_ATTRIBUTE((unused))) { +void Mysql_connection_options::protocol_callback(char *not_used + [[maybe_unused]]) { this->m_protocol = find_type_or_exit(this->m_protocol_string.value().c_str(), &sql_protocol_typelib, "protocol"); } diff -Nru mysql-8.0-8.0.26/client/base/mysql_connection_options.h mysql-8.0-8.0.27/client/base/mysql_connection_options.h --- mysql-8.0-8.0.26/client/base/mysql_connection_options.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/mysql_connection_options.h 2021-09-28 11:46:34.000000000 +0000 @@ -25,6 +25,7 @@ #ifndef MYSQL_CONNECTION_OPTIONS_INCLUDED #define MYSQL_CONNECTION_OPTIONS_INCLUDED +#include #include #include "client/base/abstract_program.h" @@ -33,7 +34,6 @@ #include "client/client_priv.h" #include "my_compiler.h" #include "my_inttypes.h" -#include "nullable.h" namespace Mysql { namespace Tools { @@ -64,8 +64,8 @@ bool apply_for_connection(MYSQL *connection); private: - Nullable m_ssl_mode_string; - Nullable m_ssl_fips_mode_string; + std::optional m_ssl_mode_string; + std::optional m_ssl_fips_mode_string; void ca_option_callback(char *argument); void mode_option_callback(char *argument); @@ -108,42 +108,42 @@ Returns pointer to constant array containing specified string or NULL value if string has length 0. */ - const char *get_null_or_string(Nullable &maybeString); + const char *get_null_or_string(std::optional &maybeString); /** Prints database connection error and exits program. */ void db_error(MYSQL *connection, const char *when); #ifdef _WIN32 - void pipe_protocol_callback(char *not_used MY_ATTRIBUTE((unused))); + void pipe_protocol_callback(char *not_used [[maybe_unused]]); #endif - void protocol_callback(char *not_used MY_ATTRIBUTE((unused))); + void protocol_callback(char *not_used [[maybe_unused]]); static bool mysql_inited; Ssl_options m_ssl_options_provider; Abstract_program *m_program; - Nullable m_protocol_string; + std::optional m_protocol_string; uint32 m_protocol; - Nullable m_bind_addr; - Nullable m_host; + std::optional m_bind_addr; + std::optional m_host; uint32 m_mysql_port; - Nullable m_mysql_unix_port; + std::optional m_mysql_unix_port; #if defined(_WIN32) - Nullable m_shared_memory_base_name; + std::optional m_shared_memory_base_name; #endif - Nullable m_default_auth; - Nullable m_plugin_dir; + std::optional m_default_auth; + std::optional m_plugin_dir; uint32 m_net_buffer_length; uint32 m_max_allowed_packet; bool m_compress; - Nullable m_user; - Nullable m_password; - Nullable m_default_charset; - Nullable m_server_public_key; + std::optional m_user; + std::optional m_password[3]; + std::optional m_default_charset; + std::optional m_server_public_key; bool m_get_server_public_key; uint m_zstd_compress_level; - Nullable m_compress_algorithm; + std::optional m_compress_algorithm; }; } // namespace Options diff -Nru mysql-8.0-8.0.26/client/base/password_option.cc mysql-8.0-8.0.27/client/base/password_option.cc --- mysql-8.0-8.0.26/client/base/password_option.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/password_option.cc 2021-09-28 11:46:34.000000000 +0000 @@ -23,18 +23,19 @@ */ #include "client/base/password_option.h" +#include "multi_factor_passwordopt-vars.h" #include #include +#include #include "client/client_priv.h" using namespace Mysql::Tools::Base::Options; -using Mysql::Nullable; using std::string; using std::placeholders::_1; -Password_option::Password_option(Nullable *value, string name, +Password_option::Password_option(std::optional *value, string name, string description) : Abstract_string_option(value, GET_PASSWORD, name, description) { @@ -42,32 +43,13 @@ std::bind(&Password_option::password_callback, this, _1))); } +Password_option::~Password_option() { free_passwords(); } + void Password_option::password_callback(char *argument) { - if (argument == ::disabled_my_option) { - // This prevents ::disabled_my_option being overriden later in this - // function. - argument = const_cast(""); - } - - if (argument != nullptr) { - /* - Destroy argument value, this modifies part of argv passed to main - routine. This makes command line on linux changed, so no user can see - password shortly after program starts. This works for example for - /proc//cmdline file and ps tool. - */ - for (char *pos = argument; *pos != 0; pos++) { - *pos = '*'; - } - - /* - This cuts argument length to hide password length on linux commandline - showing tools. - */ - if (*argument) argument[1] = 0; - } else { - char *password = ::get_tty_password(nullptr); - *this->m_destination_value = Nullable(password); - my_free(password); - } + struct my_option opt = get_my_option(); + parse_command_line_password_option(&opt, argument); + unsigned int factor = 0; + if (strcmp(opt.name, "password")) + factor = opt.name[strlen("password")] - '0' - 1; + *this->m_destination_value = std::optional(opt_password[factor]); } diff -Nru mysql-8.0-8.0.26/client/base/password_option.h mysql-8.0-8.0.27/client/base/password_option.h --- mysql-8.0-8.0.26/client/base/password_option.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/password_option.h 2021-09-28 11:46:34.000000000 +0000 @@ -25,11 +25,11 @@ #ifndef PASSWORD_OPTION_INCLUDED #define PASSWORD_OPTION_INCLUDED +#include #include #include "client/base/abstract_string_option.h" #include "my_getopt.h" -#include "nullable.h" namespace Mysql { namespace Tools { @@ -49,8 +49,9 @@ --name. @param description Description of option to be printed in --help. */ - Password_option(Nullable *value, std::string name, + Password_option(std::optional *value, std::string name, std::string description); + ~Password_option(); private: void password_callback(char *); diff -Nru mysql-8.0-8.0.26/client/base/ssl_options.cc mysql-8.0-8.0.27/client/base/ssl_options.cc --- mysql-8.0-8.0.26/client/base/ssl_options.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/ssl_options.cc 2021-09-28 11:46:34.000000000 +0000 @@ -71,8 +71,8 @@ this, _1))); } -void Mysql_connection_options::Ssl_options::ca_option_callback( - char *argument MY_ATTRIBUTE((unused))) { +void Mysql_connection_options::Ssl_options::ca_option_callback(char *argument [ + [maybe_unused]]) { if (!ssl_mode_set_explicitly) ::opt_ssl_mode = SSL_MODE_VERIFY_CA; } diff -Nru mysql-8.0-8.0.26/client/base/string_option.cc mysql-8.0-8.0.27/client/base/string_option.cc --- mysql-8.0-8.0.26/client/base/string_option.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/string_option.cc 2021-09-28 11:46:34.000000000 +0000 @@ -24,11 +24,12 @@ #include "client/base/string_option.h" +#include + using namespace Mysql::Tools::Base::Options; -using Mysql::Nullable; using std::string; -String_option::String_option(Nullable *value, string name, +String_option::String_option(std::optional *value, string name, string description) : Abstract_string_option(value, GET_STR, name, description) { } diff -Nru mysql-8.0-8.0.26/client/base/string_option.h mysql-8.0-8.0.27/client/base/string_option.h --- mysql-8.0-8.0.26/client/base/string_option.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/base/string_option.h 2021-09-28 11:46:34.000000000 +0000 @@ -25,11 +25,11 @@ #ifndef STRING_OPTION_INCLUDED #define STRING_OPTION_INCLUDED +#include #include #include "client/base/abstract_string_option.h" #include "my_getopt.h" -#include "nullable.h" namespace Mysql { namespace Tools { @@ -48,7 +48,7 @@ --name. @param description Description of option to be printed in --help. */ - String_option(Nullable *value, std::string name, + String_option(std::optional *value, std::string name, std::string description); }; diff -Nru mysql-8.0-8.0.26/client/check/mysqlcheck.cc mysql-8.0-8.0.27/client/check/mysqlcheck.cc --- mysql-8.0-8.0.26/client/check/mysqlcheck.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/check/mysqlcheck.cc 2021-09-28 11:46:34.000000000 +0000 @@ -57,17 +57,16 @@ opt_extended = false, opt_compress = false, opt_databases = false, opt_fast = false, opt_medium_check = false, opt_quick = false, opt_all_in_1 = false, opt_silent = false, opt_auto_repair = false, - ignore_errors = false, tty_password = false, opt_frm = false, - debug_info_flag = false, debug_check_flag = false, - opt_fix_table_names = false, opt_fix_db_names = false, - opt_upgrade = false, opt_write_binlog = true; + ignore_errors = false, opt_frm = false, debug_info_flag = false, + debug_check_flag = false, opt_fix_table_names = false, + opt_fix_db_names = false, opt_upgrade = false, + opt_write_binlog = true; static uint verbose = 0, opt_mysql_port = 0; static uint opt_enable_cleartext_plugin = 0; static bool using_opt_enable_cleartext_plugin = false; static int my_end_arg; static char *opt_mysql_unix_port = nullptr; -static char *opt_password = nullptr, *current_user = nullptr, - *current_host = nullptr; +static char *current_user = nullptr, *current_host = nullptr; static const char *default_charset = nullptr; static char *opt_plugin_dir = nullptr, *opt_default_auth = nullptr; static int first_error = 0; @@ -80,6 +79,8 @@ static uint opt_protocol = 0; static char *opt_bind_addr = nullptr; +#include "multi_factor_passwordopt-vars.h" + static struct my_option my_long_options[] = { {"all-databases", 'A', "Check all the databases. This is the same as --databases with all " @@ -183,11 +184,7 @@ nullptr, 0, nullptr}, {"optimize", 'o', "Optimize table.", nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, - {"password", 'p', - "Password to use when connecting to server. If password is not given, " - "it's solicited on the tty.", - nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, - nullptr}, +#include "multi_factor_passwordopt-longopts.h" #ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -267,7 +264,7 @@ static void usage(void); static int get_options(int *argc, char ***argv, MEM_ROOT *alloc); -static int dbConnect(char *host, char *user, char *passwd); +static int dbConnect(char *host, char *user); static void dbDisconnect(char *host); static void DBerror(MYSQL *mysql, const string &when); static void safe_exit(int error); @@ -319,7 +316,8 @@ what_to_do = DO_CHECK; opt_check_only_changed = true; break; - case 'I': /* Fall through */ + case 'I': + [[fallthrough]]; case '?': usage(); exit(0); @@ -330,24 +328,7 @@ case 'o': what_to_do = DO_OPTIMIZE; break; - case 'p': - if (argument == disabled_my_option) { - // Don't require password - static char empty_password[] = {'\0'}; - assert(empty_password[0] == - '\0'); // Check that it has not been overwritten - argument = empty_password; - } - if (argument) { - char *start = argument; - my_free(opt_password); - opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++ = 'x'; /* Destroy argument */ - if (*start) start[1] = 0; /* Cut length of argument */ - tty_password = false; - } else - tty_password = true; - break; + PARSE_COMMAND_LINE_PASSWORD_OPTION; case 'r': what_to_do = DO_REPAIR; break; @@ -453,13 +434,12 @@ printf("for more information.\n"); return 1; } - if (tty_password) opt_password = get_tty_password(NullS); if (debug_info_flag) my_end_arg = MY_CHECK_ERROR | MY_GIVE_INFO; if (debug_check_flag) my_end_arg = MY_CHECK_ERROR; return (0); } /* get_options */ -static int dbConnect(char *host, char *user, char *passwd) { +static int dbConnect(char *host, char *user) { DBUG_TRACE; if (verbose) { fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost"); @@ -503,8 +483,9 @@ "mysqlcheck"); set_server_public_key(&mysql_connection); set_get_server_public_key_option(&mysql_connection); + set_password_options(&mysql_connection); if (!(sock = - mysql_real_connect(&mysql_connection, host, user, passwd, nullptr, + mysql_real_connect(&mysql_connection, host, user, nullptr, nullptr, opt_mysql_port, opt_mysql_unix_port, 0))) { DBerror(&mysql_connection, "when trying to connect"); return 1; @@ -543,7 +524,7 @@ my_end(my_end_arg); exit(EX_USAGE); } - if (dbConnect(current_host, current_user, opt_password)) exit(EX_MYSQLERR); + if (dbConnect(current_host, current_user)) exit(EX_MYSQLERR); // Sun Studio does not work with range constructor from char** to string. vector conv; @@ -558,11 +539,11 @@ DBerror); dbDisconnect(current_host); - my_free(opt_password); + free_passwords(); #if defined(_WIN32) my_free(shared_memory_base_name); #endif - free_root(&alloc, MYF(0)); + alloc.Clear(); my_end(my_end_arg); return (first_error != 0); } /* main */ diff -Nru mysql-8.0-8.0.26/client/check/mysqlcheck_core.cc mysql-8.0-8.0.27/client/check/mysqlcheck_core.cc --- mysql-8.0-8.0.26/client/check/mysqlcheck_core.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/check/mysqlcheck_core.cc 2021-09-28 11:46:34.000000000 +0000 @@ -120,7 +120,7 @@ switch (src[i]) { case '`': /* Escape backtick character. */ res += '`'; - /* Fall through. */ + [[fallthrough]]; default: res += src[i]; } diff -Nru mysql-8.0-8.0.26/client/CMakeLists.txt mysql-8.0-8.0.27/client/CMakeLists.txt --- mysql-8.0-8.0.26/client/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -32,6 +32,10 @@ ## Subdirectory for mysql_migrate_keyring code. ADD_SUBDIRECTORY(migrate_keyring) +INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR}/include +) + MYSQL_ADD_EXECUTABLE(mysql ${CMAKE_SOURCE_DIR}/sql-common/net_ns.cc completion_hash.cc @@ -39,6 +43,8 @@ pattern_matcher.cc readline.cc client_query_attributes.cc + multi_factor_passwordopt-vars.cc + ${CMAKE_CURRENT_SOURCE_DIR}/common/user_registration.cc LINK_LIBRARIES mysqlclient client_base ${EDITLINE_LIBRARY} ) @@ -49,14 +55,6 @@ ) ENDIF() -# Enable inlining, to avoid stack overflow for some long regular expressions. -IF(SOLARIS_SPARC AND MY_COMPILER_IS_SUNPRO AND - CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") - ADD_COMPILE_FLAGS(mysqltest/regular_expressions.cc - COMPILE_FLAGS "-xO3" - ) -ENDIF() - MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc mysqltest/error_names.cc @@ -76,18 +74,22 @@ MYSQL_ADD_EXECUTABLE(mysqlcheck check/mysqlcheck.cc check/mysqlcheck_core.cc + multi_factor_passwordopt-vars.cc LINK_LIBRARIES mysqlclient ) MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.cc + multi_factor_passwordopt-vars.cc LINK_LIBRARIES mysqlclient ) MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.cc + multi_factor_passwordopt-vars.cc LINK_LIBRARIES mysqlclient ) MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.cc + multi_factor_passwordopt-vars.cc LINK_LIBRARIES mysqlclient ) @@ -251,10 +253,12 @@ MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc + multi_factor_passwordopt-vars.cc LINK_LIBRARIES mysqlclient ) MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.cc + multi_factor_passwordopt-vars.cc LINK_LIBRARIES mysqlclient ) MYSQL_ADD_EXECUTABLE(mysql_config_editor diff -Nru mysql-8.0-8.0.26/client/common/user_registration.cc mysql-8.0-8.0.27/client/common/user_registration.cc --- mysql-8.0-8.0.26/client/common/user_registration.cc 1970-01-01 00:00:00.000000000 +0000 +++ mysql-8.0-8.0.27/client/common/user_registration.cc 2021-09-28 11:46:34.000000000 +0000 @@ -0,0 +1,219 @@ + +/* +Copyright (c) 2021, Oracle and/or its affiliates. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License, version 2.0, +as published by the Free Software Foundation. + +This program is also distributed with certain software (including +but not limited to OpenSSL) that is licensed under separate terms, +as designated in a particular file or component or in included license +documentation. The authors of MySQL hereby grant you an additional +permission to link the program and your derivative works with the +separately licensed software that they have included with MySQL. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License, version 2.0, for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include + +#include "user_registration.h" + +#include "my_hostname.h" +#include "my_inttypes.h" +#include "my_sys.h" +#include "mysql/service_mysql_alloc.h" // my_malloc +#include "mysqld_error.h" + +/** + This helper method parses --fido-register-factor option values, and + inserts the parsed values in list. + + @param[in] what_factor comma separated string containing what all factors + are to be registered + @param[out] list container holding individual factors + + @return true failed + @return false success +*/ +static bool parse_register_option(char *what_factor, + std::vector &list) { + std::string token; + std::stringstream str(what_factor); + while (getline(str, token, ',')) { + unsigned int nth_factor = 0; + try { + nth_factor = std::stoul(token); + } catch (std::invalid_argument &) { + return true; + } catch (std::out_of_range &) { + return true; + } + /* nth_factor can be either 2 or 3 */ + if (nth_factor < 2 || nth_factor > 3) return true; + list.push_back(nth_factor); + } + return false; +} + +/** + This helper method is used to perform device registration against a user + account. Below are the messages exchanged between client, server and + authenticator (fido device) during registration process. + + == Initiate registration == + + client -> server : connect + server -> client : keep connection in registration mode + client -> server : ALTER USER account name nth FACTOR INITIATE REGISTRATION + server -> client : random challenge, user id, relying party ID + + == Finish registration == + + client -> server : ALTER USER account name nth FACTOR FINISH REGISTRATION + client -> authenticator : random challenge, user id, relying party ID + authenticator -> client : public key, credential ID (X.509 certificate, + signature) client -> server : public key, credential ID server -> client : Ok + packet upon successful verification of signature + + @param mysql mysql connection handle + @param register_option Comma separated list of values, which specifies + which factor requires registration. Valid values are "2", "3", "2,3" or "3,2" + @param errmsg Buffer tol hold error message in case of error. + + @return true failed + @return false success +*/ +bool user_device_registration(MYSQL *mysql, char *register_option, + char *errmsg) { + char query[1024] = {0}; + MYSQL_RES *result; + MYSQL_ROW row; + ulong *lengths; + uchar *server_challenge = nullptr; + uchar *server_challenge_response = nullptr; + MYSQL_STMT *finish_reg_stmt; + MYSQL_BIND rs_bind; + uchar *pos = nullptr; + + if (!mysql) { + sprintf(errmsg, "MySQL internal error. "); + return true; + } + + std::vector list; + if (parse_register_option(register_option, list)) { + sprintf(errmsg, + "Incorrect value specified for --fido-register-factor option. " + "Correct values can be '2', '3', '2,3' or '3,2'."); + return true; + } + + for (auto f : list) { + sprintf(query, "ALTER USER USER() %d FACTOR INITIATE REGISTRATION", f); + if (mysql_real_query(mysql, query, (ulong)strlen(query))) { + sprintf(errmsg, "Initiate registration failed with error: %s. ", + mysql_error(mysql)); + return true; + } + if (!(result = mysql_store_result(mysql))) { + sprintf(errmsg, "Initiate registration failed with error: %s. ", + mysql_error(mysql)); + return true; + } + if (mysql_num_rows(result) > 1) { + sprintf(errmsg, "Initiate registration failed with error: %s. ", + mysql_error(mysql)); + mysql_free_result(result); + return true; + } + row = mysql_fetch_row(result); + lengths = mysql_fetch_lengths(result); + /* + max length of challenge can be 32 (random challenge) + + 255 (relying party ID) + 255 (host name) + 32 (user name) + 4 byte for + length encodings + */ + if (lengths[0] > (CHALLENGE_LENGTH + RELYING_PARTY_ID_LENGTH + + HOSTNAME_LENGTH + USERNAME_LENGTH + 4)) { + sprintf(errmsg, "Received server challenge is corrupt. Please retry.\n"); + mysql_free_result(result); + return true; + } + server_challenge = static_cast(my_malloc( + PSI_NOT_INSTRUMENTED, lengths[0] + 1, MYF(MY_WME | MY_ZEROFILL))); + memcpy(server_challenge, row[0], lengths[0]); + mysql_free_result(result); + + /* load fido client authentication plugin if required */ + struct st_mysql_client_plugin *p = + mysql_client_find_plugin(mysql, "authentication_fido_client", + MYSQL_CLIENT_AUTHENTICATION_PLUGIN); + if (!p) { + my_free(server_challenge); + sprintf( + errmsg, + "Loading authentication_fido_client plugin failed with error: %s. ", + mysql_error(mysql)); + return true; + } + /* set server challenge in plugin */ + if (mysql_plugin_options(p, "registration_challenge", server_challenge)) { + my_free(server_challenge); + sprintf(errmsg, + "Failed to set plugin options \"registration_challenge\".\n"); + return true; + } + my_free(server_challenge); + server_challenge = nullptr; + /* get challenge response from plugin */ + if (mysql_plugin_get_option(p, "registration_response", + &server_challenge_response)) { + sprintf(errmsg, + "Failed to get plugin options \"registration_response\".\n"); + return true; + } + pos = server_challenge_response; + + finish_reg_stmt = mysql_stmt_init(mysql); + /* execute FINISH REGISTRATION sql */ + sprintf(query, + "ALTER USER USER() %d FACTOR FINISH REGISTRATION SET " + "CHALLENGE_RESPONSE AS '%s'", + f, server_challenge_response); + if (mysql_stmt_prepare(finish_reg_stmt, query, (ulong)strlen(query))) { + goto error; + } + /* Bind input buffers */ + memset(&rs_bind, 0, sizeof(rs_bind)); + rs_bind.buffer_type = MYSQL_TYPE_STRING; + rs_bind.buffer = (char *)(pos); + rs_bind.buffer_length = + (ulong)strlen(reinterpret_cast(server_challenge_response)); + rs_bind.is_null = nullptr; + + if (mysql_stmt_bind_param(finish_reg_stmt, &rs_bind)) { + goto error; + } + if (mysql_stmt_execute(finish_reg_stmt)) { + goto error; + } + if (mysql_stmt_close(finish_reg_stmt)) { + goto error; + } + } + return false; +error: + sprintf(errmsg, "Finish registration failed with error: %s.\n", + mysql_stmt_error(finish_reg_stmt)); + return true; +} \ No newline at end of file diff -Nru mysql-8.0-8.0.26/client/completion_hash.cc mysql-8.0-8.0.27/client/completion_hash.cc --- mysql-8.0-8.0.26/client/completion_hash.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/completion_hash.cc 2021-09-28 11:46:34.000000000 +0000 @@ -53,7 +53,7 @@ ht->initialized = 0; return FAILURE; } - init_alloc_root(PSI_NOT_INSTRUMENTED, &ht->mem_root, 8192, 0); + ::new ((void *)&ht->mem_root) MEM_ROOT(PSI_NOT_INSTRUMENTED, 8192); ht->pHashFunction = hashpjw; ht->nTableSize = nSize; ht->initialized = 1; @@ -192,7 +192,7 @@ } void completion_hash_clean(HashTable *ht) { - free_root(&ht->mem_root, MYF(0)); + ht->mem_root.Clear(); memset(ht->arBuckets, 0, ht->nTableSize * sizeof(Bucket *)); } diff -Nru mysql-8.0-8.0.26/client/dump/abstract_mysql_chain_element_extension.cc mysql-8.0-8.0.27/client/dump/abstract_mysql_chain_element_extension.cc --- mysql-8.0-8.0.26/client/dump/abstract_mysql_chain_element_extension.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/dump/abstract_mysql_chain_element_extension.cc 2021-09-28 11:46:34.000000000 +0000 @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "m_ctype.h" @@ -80,7 +81,7 @@ return my_strcasecmp(&my_charset_latin1, latin_name.c_str(), db_name.c_str()); } -Mysql::Nullable +std::optional Abstract_mysql_chain_element_extension::get_create_statement( Mysql::Tools::Base::Mysql_query_runner *runner, const std::string &database_name, const std::string &object_name, @@ -92,7 +93,7 @@ this->get_quoted_object_full_name(database_name, object_name), &result); - Mysql::Nullable res; + std::optional res; if (result.size() > 0) { if (object_type == "FUNCTION" || object_type == "PROCEDURE" || object_type == "TRIGGER") diff -Nru mysql-8.0-8.0.26/client/dump/abstract_mysql_chain_element_extension.h mysql-8.0-8.0.27/client/dump/abstract_mysql_chain_element_extension.h --- mysql-8.0-8.0.26/client/dump/abstract_mysql_chain_element_extension.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/dump/abstract_mysql_chain_element_extension.h 2021-09-28 11:46:34.000000000 +0000 @@ -25,8 +25,10 @@ #ifndef ABSTRACT_MYSQL_CHAIN_ELEMENT_EXTENSION_INCLUDED #define ABSTRACT_MYSQL_CHAIN_ELEMENT_EXTENSION_INCLUDED -#include #include +#include + +#include #include "client/base/message_data.h" #include "client/dump/abstract_data_object.h" @@ -34,7 +36,6 @@ #include "client/dump/i_connection_provider.h" #include "client/dump/mysql_chain_element_options.h" #include "my_inttypes.h" -#include "nullable.h" #define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8mb4" #define MAX_NAME_LEN (64 * 3) @@ -66,7 +67,7 @@ Gets CREATE statement for specified object. If object type is database, then object_name should be empty. */ - Mysql::Nullable get_create_statement( + std::optional get_create_statement( Mysql::Tools::Base::Mysql_query_runner *runner, const std::string &database_name, const std::string &object_name, const std::string &object_type, uint field_id = 1); diff -Nru mysql-8.0-8.0.26/client/dump/mysql_crawler.cc mysql-8.0-8.0.27/client/dump/mysql_crawler.cc --- mysql-8.0-8.0.26/client/dump/mysql_crawler.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/dump/mysql_crawler.cc 2021-09-28 11:46:34.000000000 +0000 @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -110,7 +111,7 @@ it != databases.end(); ++it) { std::string db_name = (**it)[0]; - Mysql::Nullable stmt = this->get_create_statement( + std::optional stmt = this->get_create_statement( runner, "", db_name, "DATABASE IF NOT EXISTS"); if (!stmt.has_value()) continue; // some error ocurred @@ -272,7 +273,7 @@ ? 0 : atoll(table_data[4].c_str()); // "Rows" bool isInnoDB = table_data[1] == "InnoDB"; // "Engine" - Mysql::Nullable stmt = + std::optional stmt = this->get_create_statement(runner, db.get_name(), table_name, "TABLE"); if (!stmt.has_value()) continue; // some error ocurred Table *table = new Table(this->generate_new_object_id(), table_name, @@ -347,7 +348,7 @@ return; } else runner->run_query(std::string("UNLOCK TABLES")); - Mysql::Nullable stmt = this->get_create_statement( + std::optional stmt = this->get_create_statement( runner, db.get_name(), table_name, "TABLE"); if (!stmt.has_value()) { @@ -387,7 +388,7 @@ it != functions.end(); ++it) { const Mysql::Tools::Base::Mysql_query_runner::Row &function_row = **it; - Mysql::Nullable stmt = this->get_create_statement( + std::optional stmt = this->get_create_statement( runner, db.get_name(), function_row[1], type, 2); if (!stmt.has_value()) // some error ocurred break; @@ -427,7 +428,7 @@ it != events.end(); ++it) { const Mysql::Tools::Base::Mysql_query_runner::Row &event_row = **it; - Mysql::Nullable stmt = this->get_create_statement( + std::optional stmt = this->get_create_statement( runner, db.get_name(), event_row[1], "EVENT", 3); if (!stmt.has_value()) // some error ocurred @@ -520,7 +521,7 @@ triggers.begin(); it != triggers.end(); ++it) { const Mysql::Tools::Base::Mysql_query_runner::Row &trigger_row = **it; - Mysql::Nullable stmt = this->get_create_statement( + std::optional stmt = this->get_create_statement( runner, table.get_schema(), trigger_row[0], "TRIGGER", 2); if (!stmt.has_value()) // some error occured break; diff -Nru mysql-8.0-8.0.26/client/dump/mysqldump_tool_chain_maker_options.h mysql-8.0-8.0.27/client/dump/mysqldump_tool_chain_maker_options.h --- mysql-8.0-8.0.26/client/dump/mysqldump_tool_chain_maker_options.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/dump/mysqldump_tool_chain_maker_options.h 2021-09-28 11:46:34.000000000 +0000 @@ -25,6 +25,8 @@ #ifndef MYSQLDUMP_TOOL_CHAIN_MAKER_OPTIONS_INCLUDED #define MYSQLDUMP_TOOL_CHAIN_MAKER_OPTIONS_INCLUDED +#include + #include "client/dump/abstract_data_object.h" #include "client/dump/mysql_object_reader_options.h" #include "client/dump/object_filter.h" @@ -65,8 +67,8 @@ bool m_dump_all_databases; bool m_dump_selected_databases; uint32 m_default_parallelism; - Mysql::Nullable m_result_file; - Mysql::Nullable m_compress_output_algorithm; + std::optional m_result_file; + std::optional m_compress_output_algorithm; bool m_skip_rows_data; private: @@ -78,7 +80,7 @@ */ std::map m_object_queue_threads; std::map m_database_to_object_queue_id; - Mysql::Nullable m_parallel_schemas_string; + std::optional m_parallel_schemas_string; int m_last_parallel_schemas_queue_id; /* count of parallel-schemas queues with default parallelism */ int m_def_thread_count; diff -Nru mysql-8.0-8.0.26/client/dump/object_filter.h mysql-8.0-8.0.27/client/dump/object_filter.h --- mysql-8.0-8.0.26/client/dump/object_filter.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/dump/object_filter.h 2021-09-28 11:46:34.000000000 +0000 @@ -25,13 +25,13 @@ #ifndef OBJECT_FILTER_INCLUDED #define OBJECT_FILTER_INCLUDED +#include #include #include #include "client/base/abstract_program.h" #include "client/base/composite_options_provider.h" #include "client/dump/abstract_data_object.h" -#include "nullable.h" namespace Mysql { namespace Tools { @@ -91,7 +91,7 @@ bool m_dump_triggers; bool m_dump_events; bool m_dump_users; - Mysql::Nullable m_include_tmp_string; + std::optional m_include_tmp_string; Mysql::Tools::Base::Abstract_program *m_program; }; diff -Nru mysql-8.0-8.0.26/client/dump/program.h mysql-8.0-8.0.27/client/dump/program.h --- mysql-8.0-8.0.26/client/dump/program.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/dump/program.h 2021-09-28 11:46:34.000000000 +0000 @@ -26,6 +26,7 @@ #define PROGRAM_INCLUDED #include +#include #include "client/base/abstract_connection_program.h" #include "client/dump/mysql_chain_element_options.h" @@ -70,7 +71,7 @@ Mysqldump_tool_chain_maker_options *m_mysqldump_tool_chain_maker_options; bool m_single_transaction; bool m_watch_progress; - Mysql::Nullable m_error_log_file; + std::optional m_error_log_file; FILE *m_stderr; std::atomic m_error_code; }; diff -Nru mysql-8.0-8.0.26/client/include/multi_factor_passwordopt-longopts.h mysql-8.0-8.0.27/client/include/multi_factor_passwordopt-longopts.h --- mysql-8.0-8.0.26/client/include/multi_factor_passwordopt-longopts.h 1970-01-01 00:00:00.000000000 +0000 +++ mysql-8.0-8.0.27/client/include/multi_factor_passwordopt-longopts.h 2021-09-28 11:46:34.000000000 +0000 @@ -0,0 +1,92 @@ +/* Copyright (c) 2021, Oracle and/or its affiliates. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License, version 2.0, for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file include/multi_factor_passwordopt-longopts.h + + This file contains password options to be specified as part of command-line + options for first,second,third authentication plugin factors for a given user. +*/ + +/* preserve existing option for backward compatibility */ +{"password", + 'p', + "Password to use when connecting to server. If password is not given it's " + "asked from the tty.", + nullptr, + nullptr, + nullptr, + GET_PASSWORD, + OPT_ARG, + 0, + 0, + 0, + nullptr, + 0, + nullptr}, + /* + --password1, --password2 --password3 are new options to handle password for + first, second and third factor authentication plugin defined for a given + user account + */ + {"password1", + MYSQL_OPT_USER_PASSWORD, + "Password for first factor authentication plugin.", + nullptr, + nullptr, + nullptr, + GET_PASSWORD, + OPT_ARG, + 0, + 0, + 0, + nullptr, + 0, + nullptr}, + {"password2", + MYSQL_OPT_USER_PASSWORD, + "Password for second factor authentication plugin.", + nullptr, + nullptr, + nullptr, + GET_PASSWORD, + OPT_ARG, + 0, + 0, + 0, + nullptr, + 0, + nullptr}, + {"password3", + MYSQL_OPT_USER_PASSWORD, + "Password for third factor authentication plugin.", + nullptr, + nullptr, + nullptr, + GET_PASSWORD, + OPT_ARG, + 0, + 0, + 0, + nullptr, + 0, + nullptr}, diff -Nru mysql-8.0-8.0.26/client/include/multi_factor_passwordopt-vars.h mysql-8.0-8.0.27/client/include/multi_factor_passwordopt-vars.h --- mysql-8.0-8.0.26/client/include/multi_factor_passwordopt-vars.h 1970-01-01 00:00:00.000000000 +0000 +++ mysql-8.0-8.0.27/client/include/multi_factor_passwordopt-vars.h 2021-09-28 11:46:34.000000000 +0000 @@ -0,0 +1,56 @@ +/* Copyright (c) 2021, Oracle and/or its affiliates. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License, version 2.0, for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file include/multi_factor_passwordopt-vars.h +*/ + +#ifndef MULTI_FACTOR_PASSWORDOPT_VARS_H +#define MULTI_FACTOR_PASSWORDOPT_VARS_H + +#include "mysql.h" + +extern char *opt_password[MAX_AUTH_FACTORS]; +extern bool tty_password[MAX_AUTH_FACTORS]; + +/** parse passwords for --password or --password option where N = 1,2,3 */ +void parse_command_line_password_option(const struct my_option *opt, + char *argument); +/** + If --password option is not specified with an argument, get password from + prompt +*/ +void set_tty_password(MYSQL *mysql); +/** Set password in mysql->options */ +void set_password_options(MYSQL *mysql); +/** Release memory for opt_password */ +void free_passwords(); + +#define PARSE_COMMAND_LINE_PASSWORD_OPTION \ + case 'p': \ + parse_command_line_password_option(opt, argument); \ + break; \ + case MYSQL_OPT_USER_PASSWORD: \ + parse_command_line_password_option(opt, argument); \ + break; + +#endif // MULTI_FACTOR_PASSWORDOPT_VARS_H diff -Nru mysql-8.0-8.0.26/client/include/user_registration.h mysql-8.0-8.0.27/client/include/user_registration.h --- mysql-8.0-8.0.26/client/include/user_registration.h 1970-01-01 00:00:00.000000000 +0000 +++ mysql-8.0-8.0.27/client/include/user_registration.h 2021-09-28 11:46:34.000000000 +0000 @@ -0,0 +1,34 @@ + +/* +Copyright (c) 2021, Oracle and/or its affiliates. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License, version 2.0, +as published by the Free Software Foundation. + +This program is also distributed with certain software (including +but not limited to OpenSSL) that is licensed under separate terms, +as designated in a particular file or component or in included license +documentation. The authors of MySQL hereby grant you an additional +permission to link the program and your derivative works with the +separately licensed software that they have included with MySQL. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License, version 2.0, for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef USER_REGISTRATION_H_ +#define USER_REGISTRATION_H_ + +#include + +bool user_device_registration(MYSQL *mysql, char *register_option, + char *errmsg); + +#endif // USER_REGISTRATION_H_ \ No newline at end of file diff -Nru mysql-8.0-8.0.26/client/migrate_keyring/options.cc mysql-8.0-8.0.27/client/migrate_keyring/options.cc --- mysql-8.0-8.0.26/client/migrate_keyring/options.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/migrate_keyring/options.cc 2021-09-28 11:46:34.000000000 +0000 @@ -178,7 +178,7 @@ usage(true); break; case 'I': - // Fall through + [[fallthrough]]; case '?': Options::s_help = true; usage(false); diff -Nru mysql-8.0-8.0.26/client/multi_factor_passwordopt-vars.cc mysql-8.0-8.0.27/client/multi_factor_passwordopt-vars.cc --- mysql-8.0-8.0.26/client/multi_factor_passwordopt-vars.cc 1970-01-01 00:00:00.000000000 +0000 +++ mysql-8.0-8.0.27/client/multi_factor_passwordopt-vars.cc 2021-09-28 11:46:34.000000000 +0000 @@ -0,0 +1,107 @@ +/* Copyright (c) 2021, Oracle and/or its affiliates. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License, version 2.0, for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file include/multi_factor_passwordopt-vars.h +*/ + +#include "multi_factor_passwordopt-vars.h" + +#include "my_getopt.h" +#include "mysql.h" +#include "mysql/service_mysql_alloc.h" // my_free, my_strdup + +char *opt_password[MAX_AUTH_FACTORS] = {0}; +bool tty_password[MAX_AUTH_FACTORS] = {false}; + +/** + Helper method used by clients to parse password set as part of command line. + This method checks if password value is specified or not. If not then a flag + is set to let client accept password from terminal. + + @param opt password option + @param argument value specified for --password<1,2,3> or --password +*/ +void parse_command_line_password_option(const struct my_option *opt, + char *argument) { + if (argument == disabled_my_option) { + // Don't require password + static char empty_password[] = {'\0'}; + assert(empty_password[0] == + '\0'); // Check that it has not been overwritten + argument = empty_password; + } + /* + password options can be --password or --password1 or --password2 or + --password3. Thus extract factor from option. + */ + unsigned int factor = 0; + if (strcmp(opt->name, "password")) + factor = opt->name[strlen("password")] - '0' - 1; + if (argument) { + char *start = argument; + my_free(opt_password[factor]); + opt_password[factor] = + my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); + while (*argument) *argument++ = 'x'; // Destroy argument + if (*start) start[1] = 0; + tty_password[factor] = false; + } else + tty_password[factor] = true; +} + +/** + Helper method used by clients to accept password from terminal +*/ +void set_tty_password(MYSQL *mysql) { + for (unsigned int factor = 1; factor <= MAX_AUTH_FACTORS; factor++) { + if (tty_password[factor - 1]) { + char *pwd = get_tty_password(NullS); + mysql_options4(mysql, MYSQL_OPT_USER_PASSWORD, &factor, pwd); + my_free(pwd); + } + } +} + +/** + Helper method used by clients to set password in mysql->options +*/ +void set_password_options(MYSQL *mysql) { + for (unsigned int factor = 1; factor <= MAX_AUTH_FACTORS; factor++) { + if (opt_password[factor - 1]) { + mysql_options4(mysql, MYSQL_OPT_USER_PASSWORD, &factor, + opt_password[factor - 1]); + } + } + /* get password from terminal */ + if (!(opt_password[0] && opt_password[1] && opt_password[2])) + set_tty_password(mysql); +} + +void free_passwords() { + for (unsigned int factor = 1; factor <= MAX_AUTH_FACTORS; factor++) { + if (opt_password[factor - 1]) { + my_free(opt_password[factor - 1]); + opt_password[factor - 1] = nullptr; + } + } +} \ No newline at end of file diff -Nru mysql-8.0-8.0.26/client/mysqladmin.cc mysql-8.0-8.0.27/client/mysqladmin.cc --- mysql-8.0-8.0.26/client/mysqladmin.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysqladmin.cc 2021-09-28 11:46:34.000000000 +0000 @@ -56,7 +56,7 @@ #define MAX_TRUNC_LENGTH 3 const char *host = nullptr; -char *user = nullptr, *opt_password = nullptr; +char *user = nullptr; const char *default_charset = MYSQL_AUTODETECT_CHARSET_NAME; char truncated_var_names[MAX_MYSQL_VAR][MAX_TRUNC_LENGTH]; char ex_var_names[MAX_MYSQL_VAR][FN_REFLEN]; @@ -64,10 +64,10 @@ static int interval = 0; static bool option_force = false, interrupted = false, new_line = false, opt_compress = false, opt_relative = false, opt_verbose = false, - opt_vertical = false, tty_password = false, opt_nobeep; + opt_vertical = false, opt_nobeep; static bool debug_info_flag = false, debug_check_flag = false; static uint tcp_port = 0, option_wait = 0, option_silent = 0, nr_iterations; -static uint opt_count_iterations = 0, my_end_arg; +static uint opt_count_iterations = 0, my_end_arg = 0; static char *opt_bind_addr = nullptr; static ulong opt_connect_timeout, opt_shutdown_timeout; static char *unix_port = nullptr; @@ -96,6 +96,7 @@ #include "sslopt-vars.h" #include "caching_sha2_passwordopt-vars.h" +#include "multi_factor_passwordopt-vars.h" static void usage(void); extern "C" bool get_one_option(int optid, const struct my_option *opt, @@ -228,11 +229,7 @@ REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, {"no-beep", 'b', "Turn off beep on error.", &opt_nobeep, &opt_nobeep, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, - {"password", 'p', - "Password to use when connecting to server. If password is not given it's " - "asked from the tty.", - nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, - nullptr}, +#include "multi_factor_passwordopt-longopts.h" #ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -321,8 +318,7 @@ static const char *load_default_groups[] = {"mysqladmin", "client", nullptr}; -bool get_one_option(int optid, - const struct my_option *opt MY_ATTRIBUTE((unused)), +bool get_one_option(int optid, const struct my_option *opt [[maybe_unused]], char *argument) { int error = 0; @@ -330,24 +326,7 @@ case 'c': opt_count_iterations = 1; break; - case 'p': - if (argument == disabled_my_option) { - // Don't require password - static char empty_password[] = {'\0'}; - assert(empty_password[0] == - '\0'); // Check that it has not been overwritten - argument = empty_password; - } - if (argument) { - char *start = argument; - my_free(opt_password); - opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++ = 'x'; /* Destroy argument */ - if (*start) start[1] = 0; /* Cut length of argument */ - tty_password = false; - } else - tty_password = true; - break; + PARSE_COMMAND_LINE_PASSWORD_OPTION; case 's': option_silent++; break; @@ -401,16 +380,16 @@ char **commands, **temp_argv; MY_INIT(argv[0]); - mysql_init(&mysql); my_getopt_use_args_separator = true; MEM_ROOT alloc{PSI_NOT_INSTRUMENTED, 512}; - if (load_defaults("my", load_default_groups, &argc, &argv, &alloc)) + if (load_defaults("my", load_default_groups, &argc, &argv, &alloc)) { + my_end(my_end_arg); return EXIT_FAILURE; + } my_getopt_use_args_separator = false; if ((ho_error = handle_options(&argc, &argv, my_long_options, get_one_option))) { - mysql_close(&mysql); my_end(my_end_arg); return ho_error; } @@ -420,6 +399,7 @@ if (argc == 0) { usage(); + my_end(my_end_arg); return EXIT_FAILURE; } @@ -427,11 +407,11 @@ temp_argc = argc; commands = temp_argv; - if (tty_password) opt_password = get_tty_password(NullS); (void)signal(SIGINT, endprog); /* Here if abort */ (void)signal(SIGTERM, endprog); /* Here if abort */ + mysql_init(&mysql); if (opt_bind_addr) mysql_options(&mysql, MYSQL_OPT_BIND, opt_bind_addr); if (opt_compress) mysql_options(&mysql, MYSQL_OPT_COMPRESS, NullS); if (opt_connect_timeout) { @@ -440,6 +420,8 @@ } if (SSL_SET_OPTIONS(&mysql)) { fprintf(stderr, "%s", SSL_SET_OPTIONS_ERROR); + mysql_close(&mysql); + my_end(my_end_arg); return EXIT_FAILURE; } if (opt_protocol) @@ -479,6 +461,8 @@ set_server_public_key(&mysql); set_get_server_public_key_option(&mysql); + + set_password_options(&mysql); if (sql_connect(&mysql, option_wait)) { /* We couldn't get an initial connection and will definitely exit. @@ -563,7 +547,7 @@ } /* got connection */ mysql_close(&mysql); - my_free(opt_password); + free_passwords(); my_free(user); #if defined(_WIN32) my_free(shared_memory_base_name); @@ -578,7 +562,7 @@ return error ? EXIT_FAILURE : EXIT_SUCCESS; } -void endprog(int signal_number MY_ATTRIBUTE((unused))) { interrupted = true; } +void endprog(int signal_number [[maybe_unused]]) { interrupted = true; } /** @brief connect to server, optionally waiting for same to come up @@ -596,7 +580,7 @@ bool info = false; for (;;) { - if (mysql_real_connect(mysql, host, user, opt_password, NullS, tcp_port, + if (mysql_real_connect(mysql, host, user, nullptr, NullS, tcp_port, unix_port, CLIENT_REMEMBER_OPTIONS)) { mysql->reconnect = true; if (info) { @@ -1118,7 +1102,7 @@ case ADMIN_START_SLAVE: CLIENT_WARN_DEPRECATED("start-slave", "start-replica"); - // FALLTHROUGH + [[fallthrough]]; case ADMIN_START_REPLICA: if (mysql_query(mysql, "START REPLICA")) { my_printf_error(0, "Error starting replication: %s", error_flags, @@ -1130,7 +1114,7 @@ case ADMIN_STOP_SLAVE: CLIENT_WARN_DEPRECATED("stop-slave", "stop-replica"); - // FALLTHROUGH + [[fallthrough]]; case ADMIN_STOP_REPLICA: if (mysql_query(mysql, "STOP REPLICA")) { my_printf_error(0, "Error stopping replication: %s", error_flags, @@ -1327,7 +1311,7 @@ /* 3.rd argument, uint row, is not in use. Don't remove! */ static void print_row(MYSQL_RES *result, MYSQL_ROW cur, - uint row MY_ATTRIBUTE((unused))) { + uint row [[maybe_unused]]) { uint i, length; MYSQL_FIELD *field; @@ -1357,7 +1341,7 @@ last_values[row] = tmp; } -static void print_relative_row_vert(MYSQL_RES *result MY_ATTRIBUTE((unused)), +static void print_relative_row_vert(MYSQL_RES *result [[maybe_unused]], MYSQL_ROW cur, uint row) { uint length; ulonglong tmp; diff -Nru mysql-8.0-8.0.26/client/mysqlbinlog.cc mysql-8.0-8.0.27/client/mysqlbinlog.cc --- mysql-8.0-8.0.26/client/mysqlbinlog.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysqlbinlog.cc 2021-09-28 11:46:34.000000000 +0000 @@ -1601,7 +1601,7 @@ goto end; } } - // Fall through + [[fallthrough]]; case binary_log::ROWS_QUERY_LOG_EVENT: case binary_log::WRITE_ROWS_EVENT: case binary_log::DELETE_ROWS_EVENT: @@ -1754,7 +1754,7 @@ "any case. If you want to exclude or include transactions, " "you should use the options --exclude-gtids or " "--include-gtids, respectively, instead."); - /* fall through */ + [[fallthrough]]; default: ev->print(result_file, print_event_info); if (head->error == -1) goto err; @@ -2241,7 +2241,7 @@ case OPT_READ_FROM_REMOTE_MASTER_DEPRECATED: warning(CLIENT_WARN_DEPRECATED_MSG("--read-from-remote-master", "--read-from-remote-source")); - /* FALLTHROUGH */ + [[fallthrough]]; case OPT_REMOTE_PROTO: opt_remote_proto = (enum_remote_proto)( find_type_or_exit(argument, &remote_proto_typelib, opt->name) - 1); diff -Nru mysql-8.0-8.0.26/client/mysql.cc mysql-8.0-8.0.27/client/mysql.cc --- mysql-8.0-8.0.26/client/mysql.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysql.cc 2021-09-28 11:46:34.000000000 +0000 @@ -53,6 +53,7 @@ #include "my_loglevel.h" #include "my_macros.h" #include "typelib.h" +#include "user_registration.h" #include "violite.h" #ifdef HAVE_SYS_IOCTL_H @@ -90,9 +91,8 @@ #include #include -#include "sql_common.h" - #include "sql-common/net_ns.h" +#include "sql_common.h" using std::max; using std::min; @@ -158,12 +158,12 @@ using_opt_local_infile = false, vertical = false, line_numbers = true, column_names = true, opt_html = false, opt_xml = false, opt_nopager = true, opt_outfile = false, - named_cmds = false, tty_password = false, opt_nobeep = false, - opt_reconnect = true, default_pager_set = false, - opt_sigint_ignore = false, auto_vertical_output = false, - show_warnings = false, executing_query = false, - interrupted_query = false, ignore_spaces = false, - sigint_received = false, opt_syslog = false, opt_binhex = false; + named_cmds = false, opt_nobeep = false, opt_reconnect = true, + default_pager_set = false, opt_sigint_ignore = false, + auto_vertical_output = false, show_warnings = false, + executing_query = false, interrupted_query = false, + ignore_spaces = false, sigint_received = false, opt_syslog = false, + opt_binhex = false; static bool opt_binary_as_hex_set_explicitly = false; static bool debug_info_flag, debug_check_flag; static bool column_types_flag; @@ -183,7 +183,6 @@ static char *dns_srv_name; static char *current_db; static char *current_user = nullptr; -static char *opt_password = nullptr; static char *current_prompt = nullptr; static char *delimiter_str = nullptr; static char *opt_init_command = nullptr; @@ -216,7 +215,7 @@ static char default_pager[FN_REFLEN]; static char pager[FN_REFLEN], outfile[FN_REFLEN]; static FILE *PAGER, *OUTFILE; -static MEM_ROOT hash_mem_root; +static MEM_ROOT hash_mem_root(PSI_NOT_INSTRUMENTED, 16384); static uint prompt_counter; static char delimiter[16] = DEFAULT_DELIMITER; static size_t delimiter_length = 1; @@ -230,7 +229,11 @@ static uint opt_protocol = 0; static const CHARSET_INFO *charset_info = &my_charset_latin1; +static char *opt_fido_register_factor = nullptr; +static char *opt_oci_config_file = nullptr; + #include "caching_sha2_passwordopt-vars.h" +#include "multi_factor_passwordopt-vars.h" #include "sslopt-vars.h" const char *default_dbug_option = "d:t:o,/tmp/mysql.trace"; @@ -320,8 +323,7 @@ static int read_and_execute(bool interactive); static bool init_connection_options(MYSQL *mysql); -static int sql_connect(char *host, char *database, char *user, char *password, - uint silent); +static int sql_connect(char *host, char *database, char *user, uint silent); static const char *server_version_string(MYSQL *mysql); static int put_info(const char *str, INFO_TYPE info, uint error = 0, const char *sql_state = nullptr); @@ -1328,11 +1330,9 @@ } glob_buffer.mem_realloc((status.batch) ? batch_io_size : 512); completion_hash_init(&ht, 128); - init_alloc_root(PSI_NOT_INSTRUMENTED, &hash_mem_root, 16384, 0); memset(&mysql, 0, sizeof(mysql)); global_attrs = new client_query_attributes(); - if (sql_connect(current_host, current_db, current_user, opt_password, - opt_silent)) { + if (sql_connect(current_host, current_db, current_user, opt_silent)) { quick = true; // Avoid history status.exit_status = 1; mysql_end(-1); @@ -1437,6 +1437,7 @@ "any more secure.", INFO_INFO); } + status.exit_status = read_and_execute(!status.batch); if (opt_outfile) end_tee(); mysql_end(0); @@ -1465,7 +1466,7 @@ } batch_readline_end(status.line_buff); completion_hash_free(&ht); - free_root(&hash_mem_root, MYF(0)); + hash_mem_root.Clear(); my_free(histfile); my_free(histfile_tmp); @@ -1482,7 +1483,7 @@ old_buffer.mem_free(); processed_prompt.mem_free(); my_free(server_version); - my_free(opt_password); + free_passwords(); my_free(opt_mysql_unix_port); my_free(current_db); my_free(current_host); @@ -1582,11 +1583,10 @@ MYSQL *ret; if (dns_srv_name) ret = mysql_real_connect_dns_srv(kill_mysql, dns_srv_name, current_user, - opt_password, "", 0); + nullptr, "", 0); else - ret = - mysql_real_connect(kill_mysql, current_host, current_user, opt_password, - "", opt_mysql_port, opt_mysql_unix_port, 0); + ret = mysql_real_connect(kill_mysql, current_host, current_user, nullptr, + "", opt_mysql_port, opt_mysql_unix_port, 0); if (!ret) { #ifdef HAVE_SETNS if (opt_network_namespace) (void)restore_original_network_namespace(); @@ -1787,11 +1787,7 @@ "This option is disabled by default.", nullptr, nullptr, nullptr, GET_STR, OPT_ARG, 0, 0, 0, nullptr, 0, nullptr}, #endif - {"password", 'p', - "Password to use when connecting to server. If password is not given it's " - "asked from the tty.", - nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, - nullptr}, +#include "multi_factor_passwordopt-longopts.h" #ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -1944,7 +1940,16 @@ "Directory path safe for LOAD DATA LOCAL INFILE to read from.", &opt_load_data_local_dir, &opt_load_data_local_dir, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, - + {"fido-register-factor", 0, + "Specifies authentication factor, for which registration needs to be " + "done.", + &opt_fido_register_factor, &opt_fido_register_factor, nullptr, GET_STR, + REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, + {"oci-config-file", 0, + "Specifies the location of the OCI configuration file. Default for Linux " + "is ~/.oci/config and %HOME/.oci/config on Windows.", + &opt_oci_config_file, &opt_oci_config_file, nullptr, GET_STR, REQUIRED_ARG, + 0, 0, 0, nullptr, 0, nullptr}, {nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}}; @@ -1959,8 +1964,7 @@ my_print_variables(my_long_options); } -bool get_one_option(int optid, - const struct my_option *opt MY_ATTRIBUTE((unused)), +bool get_one_option(int optid, const struct my_option *opt [[maybe_unused]], char *argument) { switch (optid) { case OPT_CHARSETS_DIR: @@ -2043,24 +2047,7 @@ else one_database = skip_updates = true; break; - case 'p': - if (argument == disabled_my_option) { - // Don't require password - static char empty_password[] = {'\0'}; - assert(empty_password[0] == - '\0'); // Check that it has not been overwritten - argument = empty_password; - } - if (argument) { - char *start = argument; - my_free(opt_password); - opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++ = 'x'; // Destroy argument - if (*start) start[1] = 0; - tty_password = false; - } else - tty_password = true; - break; + PARSE_COMMAND_LINE_PASSWORD_OPTION; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); debug_info_flag = true; @@ -2157,7 +2144,6 @@ my_free(current_db); current_db = my_strdup(PSI_NOT_INSTRUMENTED, *argv, MYF(MY_WME)); } - if (tty_password) opt_password = get_tty_password(NullS); if (debug_info_flag) my_end_arg = MY_CHECK_ERROR | MY_GIVE_INFO; if (debug_check_flag) my_end_arg = MY_CHECK_ERROR; @@ -2202,8 +2188,8 @@ line_length = status.line_buff->read_length; /* - ASCII 0x00 is not allowed appearing in queries if it is not in binary - mode. + ASCII 0x00 is not allowed appearing in queries if it is not in + binary mode. */ if (!real_binary_mode && strlen(line) != line_length) { status.exit_status = 1; @@ -2337,9 +2323,9 @@ #endif /* - If the function is called by 'source' command, it will return to interactive - mode, so real_binary_mode should be false. Otherwise, it will exit the - program, it is safe to set real_binary_mode to false. + If the function is called by 'source' command, it will return to + interactive mode, so real_binary_mode should be false. Otherwise, it will + exit the program, it is safe to set real_binary_mode to false. */ real_binary_mode = false; return status.exit_status; @@ -2747,9 +2733,8 @@ array of matches, or NULL if there aren't any. */ -static char **new_mysql_completion(const char *text, - int start MY_ATTRIBUTE((unused)), - int end MY_ATTRIBUTE((unused))) { +static char **new_mysql_completion(const char *text, int start [[maybe_unused]], + int end [[maybe_unused]]) { if (!status.batch && !quick) #if defined(USE_NEW_EDITLINE_INTERFACE) return rl_completion_matches(text, new_command_generator); @@ -2845,7 +2830,7 @@ /* Free old used memory */ if (field_names) field_names = nullptr; completion_hash_clean(&ht); - free_root(&hash_mem_root, MYF(0)); + hash_mem_root.Clear(); /* hash this file's known subset of SQL commands */ while (cmd->name) { @@ -3115,8 +3100,8 @@ tee_fprintf(PAGER, " %s\n", (*cur)[num_name]); } -static int com_server_help(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused)), char *help_arg) { +static int com_server_help(String *buffer [[maybe_unused]], + char *line [[maybe_unused]], char *help_arg) { MYSQL_ROW cur; const char *server_cmd; char cmd_buf[100 + 1]; @@ -3182,7 +3167,8 @@ tee_fprintf(PAGER, "You asked for help about help category: \"%s\"\n", cur[0]); put_info( - "For more information, type 'help ', where is one of " + "For more information, type 'help ', where is one " + "of " "the following", INFO_INFO); num_name = 1; @@ -3212,8 +3198,8 @@ return error; } -static int com_help(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_help(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { int i, j; char *help_arg = strchr(line, ' '), buff[32], *end; if (help_arg) { @@ -3253,14 +3239,14 @@ } /* ARGSUSED */ -static int com_clear(String *buffer, char *line MY_ATTRIBUTE((unused))) { +static int com_clear(String *buffer, char *line [[maybe_unused]]) { if (status.add_to_history) fix_line(buffer); buffer->length(0); return 0; } /* ARGSUSED */ -static int com_charset(String *buffer MY_ATTRIBUTE((unused)), char *line) { +static int com_charset(String *buffer [[maybe_unused]], char *line) { char buff[256], *param; const CHARSET_INFO *new_cs; strmake(buff, line, sizeof(buff) - 1); @@ -3287,7 +3273,7 @@ 1 if fatal error */ -static int com_go(String *buffer, char *line MY_ATTRIBUTE((unused))) { +static int com_go(String *buffer, char *line [[maybe_unused]]) { char buff[200]; /* about 110 chars used so far */ char time_buff[52 + 3 + 1]; /* time max + space&parens + NUL */ MYSQL_RES *result; @@ -3560,7 +3546,7 @@ const char *ptr = str, *end = ptr + len; ulong i; - if (len > 0) { + if (str != nullptr) { fprintf(output_file, "0x"); for (; ptr < end; ptr++) fprintf(output_file, "%02X", @@ -3646,12 +3632,13 @@ field_max_length = field->max_length; /* - How many text cells on the screen will this string span? If it contains - multibyte characters, then the number of characters we occupy on screen - will be fewer than the number of bytes we occupy in memory. + How many text cells on the screen will this string span? If it + contains multibyte characters, then the number of characters we occupy + on screen will be fewer than the number of bytes we occupy in memory. We need to find how much screen real-estate we will occupy to know how - many extra padding-characters we should send with the printing function. + many extra padding-characters we should send with the printing + function. */ visible_length = charset_info->cset->numcells(charset_info, buffer, buffer + data_length); @@ -3674,8 +3661,8 @@ } (void)tee_fputs("\n", PAGER); - // Check interrupted_query last; this ensures that we get at least one row. - // This is useful for aborted EXPLAIN ANALYZE queries. + // Check interrupted_query last; this ensures that we get at least one + // row. This is useful for aborted EXPLAIN ANALYZE queries. if (interrupted_query) break; } tee_puts(separator.ptr(), PAGER); @@ -3966,8 +3953,8 @@ } } -static int com_tee(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_tee(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { char file_name[FN_REFLEN], *end, *param; while (my_isspace(charset_info, *line)) line++; @@ -3999,8 +3986,8 @@ return 0; } -static int com_notee(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_notee(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { if (opt_outfile) end_tee(); tee_fprintf(stdout, "Outfile disabled.\n"); return 0; @@ -4011,8 +3998,8 @@ */ #ifdef USE_POPEN -static int com_pager(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_pager(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { char pager_name[FN_REFLEN], *end, *param; if (status.batch) return 0; @@ -4046,8 +4033,8 @@ return 0; } -static int com_nopager(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_nopager(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { my_stpcpy(pager, "stdout"); opt_nopager = true; PAGER = stdout; @@ -4061,7 +4048,7 @@ */ #ifdef USE_POPEN -static int com_edit(String *buffer, char *line MY_ATTRIBUTE((unused))) { +static int com_edit(String *buffer, char *line [[maybe_unused]]) { char filename[FN_REFLEN], buff[160]; int fd, tmp; const char *editor; @@ -4099,22 +4086,22 @@ /* If arg is given, exit without errors. This happens on command 'quit' */ -static int com_quit(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_quit(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { status.exit_status = 0; return 1; } -static int com_rehash(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_rehash(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { #ifdef HAVE_READLINE build_completion_hash(true, false); #endif return 0; } -static int com_shell(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_shell(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { char *shell_cmd; /* Skip space from line begin */ @@ -4134,7 +4121,7 @@ return 0; } -static int com_print(String *buffer, char *line MY_ATTRIBUTE((unused))) { +static int com_print(String *buffer, char *line [[maybe_unused]]) { tee_puts("--------------", stdout); (void)tee_fputs(buffer->c_ptr(), stdout); if (!buffer->length() || (*buffer)[buffer->length() - 1] != '\n') @@ -4177,7 +4164,7 @@ buffer->length(0); // command used } else opt_rehash = false; - error = sql_connect(current_host, current_db, current_user, opt_password, 0); + error = sql_connect(current_host, current_db, current_user, 0); opt_rehash = save_rehash; if (connected) { @@ -4190,7 +4177,7 @@ return error; } -static int com_source(String *buffer MY_ATTRIBUTE((unused)), char *line) { +static int com_source(String *buffer [[maybe_unused]], char *line) { char source_name[FN_REFLEN], *end, *param; LINE_BUFFER *line_buff; int error; @@ -4236,7 +4223,7 @@ } /* ARGSUSED */ -static int com_delimiter(String *buffer MY_ATTRIBUTE((unused)), char *line) { +static int com_delimiter(String *buffer [[maybe_unused]], char *line) { char buff[256], *tmp; strmake(buff, line, sizeof(buff) - 1); @@ -4259,7 +4246,7 @@ } /* ARGSUSED */ -static int com_use(String *buffer MY_ATTRIBUTE((unused)), char *line) { +static int com_use(String *buffer [[maybe_unused]], char *line) { char *tmp, buff[FN_REFLEN + 1]; int select_db; uint warnings; @@ -4386,22 +4373,21 @@ return 0; } -static int com_warnings(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_warnings(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { show_warnings = true; put_info("Show warnings enabled.", INFO_INFO); return 0; } -static int com_nowarnings(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_nowarnings(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { show_warnings = false; put_info("Show warnings disabled.", INFO_INFO); return 0; } -static int com_query_attributes(String *buffer MY_ATTRIBUTE((unused)), - char *line) { +static int com_query_attributes(String *buffer [[maybe_unused]], char *line) { char buff[1024], *param, name[1024]; memset(buff, 0, sizeof(buff)); strmake(buff, line, sizeof(buff) - 1); @@ -4490,8 +4476,8 @@ return quote_count; } -static int sql_real_connect(char *host, char *database, char *user, - char *password, uint silent) { +static int sql_real_connect(char *host, char *database, char *user, char *, + uint silent) { if (connected) { connected = false; #ifdef HAVE_SETNS @@ -4539,11 +4525,11 @@ #endif MYSQL *ret; if (dns_srv_name) - ret = mysql_real_connect_dns_srv(&mysql, dns_srv_name, user, password, + ret = mysql_real_connect_dns_srv(&mysql, dns_srv_name, user, nullptr, database, connect_flag | CLIENT_MULTI_STATEMENTS); else - ret = mysql_real_connect(&mysql, host, user, password, database, + ret = mysql_real_connect(&mysql, host, user, nullptr, database, opt_mysql_port, opt_mysql_unix_port, connect_flag | CLIENT_MULTI_STATEMENTS); if (!ret) { @@ -4565,6 +4551,15 @@ return -1; // Retryable } + /* do user registration */ + if (opt_fido_register_factor) { + char errmsg[FN_REFLEN]; + if (user_device_registration(&mysql, opt_fido_register_factor, errmsg)) { + put_info(errmsg, INFO_ERROR); + return 1; + } + } + #ifdef HAVE_SETNS if (opt_network_namespace && restore_original_network_namespace()) { if (!silent) { @@ -4696,16 +4691,33 @@ mysql_options(mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, &handle_expired); + set_password_options(mysql); + + if (opt_oci_config_file != nullptr) { + /* set OCI config file option if required */ + struct st_mysql_client_plugin *oci_iam_plugin = mysql_client_find_plugin( + mysql, "authentication_oci_client", MYSQL_CLIENT_AUTHENTICATION_PLUGIN); + if (!oci_iam_plugin) { + put_info("Cannot load the authentication_oci_client plugin.", INFO_ERROR); + return 1; + } + if (mysql_plugin_options(oci_iam_plugin, "oci-config-file", + opt_oci_config_file)) { + put_info( + "Failed to set config file for authentication_oci_client plugin.", + INFO_ERROR); + return 1; + } + } return false; } -static int sql_connect(char *host, char *database, char *user, char *password, - uint silent) { +static int sql_connect(char *host, char *database, char *user, uint silent) { bool message = false; uint count = 0; int error; for (;;) { - if ((error = sql_real_connect(host, database, user, password, wait_flag)) >= + if ((error = sql_real_connect(host, database, user, nullptr, wait_flag)) >= 0) { if (count) { tee_fputs("\n", stderr); @@ -4728,8 +4740,8 @@ } } -static int com_status(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_status(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { const char *status_str; char buff[40]; ulonglong id; @@ -5317,7 +5329,7 @@ return; } -static int com_prompt(String *buffer MY_ATTRIBUTE((unused)), char *line) { +static int com_prompt(String *buffer [[maybe_unused]], char *line) { char *ptr = strchr(line, ' '); prompt_counter = 0; my_free(current_prompt); @@ -5330,8 +5342,8 @@ return 0; } -static int com_resetconnection(String *buffer MY_ATTRIBUTE((unused)), - char *line MY_ATTRIBUTE((unused))) { +static int com_resetconnection(String *buffer [[maybe_unused]], + char *line [[maybe_unused]]) { int error; global_attrs->clear(connected ? &mysql : nullptr); error = mysql_reset_connection(&mysql); diff -Nru mysql-8.0-8.0.26/client/mysql_config_editor.cc mysql-8.0-8.0.27/client/mysql_config_editor.cc --- mysql-8.0-8.0.26/client/mysql_config_editor.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysql_config_editor.cc 2021-09-28 11:46:34.000000000 +0000 @@ -237,9 +237,10 @@ 0, nullptr, 0, nullptr}}; extern "C" { -static bool my_program_get_one_option( - int optid, const struct my_option *opt MY_ATTRIBUTE((unused)), - char *argument MY_ATTRIBUTE((unused))) { +static bool my_program_get_one_option(int optid, + const struct my_option *opt + [[maybe_unused]], + char *argument [[maybe_unused]]) { switch (optid) { case '#': DBUG_PUSH(argument ? argument : "d:t:o,/tmp/mysql_config_editor.trace"); diff -Nru mysql-8.0-8.0.26/client/mysqldump.cc mysql-8.0-8.0.27/client/mysqldump.cc --- mysql-8.0-8.0.26/client/mysqldump.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysqldump.cc 2021-09-28 11:46:34.000000000 +0000 @@ -110,9 +110,8 @@ opt_lock_all_tables = false, opt_set_charset = false, opt_dump_date = true, opt_autocommit = false, opt_disable_keys = true, opt_xml = false, - opt_delete_master_logs = false, tty_password = false, - opt_single_transaction = false, opt_comments = false, - opt_compact = false, opt_hex_blob = false, + opt_delete_master_logs = false, opt_single_transaction = false, + opt_comments = false, opt_compact = false, opt_hex_blob = false, opt_order_by_primary = false, opt_ignore = false, opt_complete_insert = false, opt_drop_database = false, opt_replace_into = false, opt_dump_triggers = false, @@ -128,8 +127,7 @@ static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection, *mysql = nullptr; static DYNAMIC_STRING insert_pat; -static char *opt_password = nullptr, *current_user = nullptr, - *current_host = nullptr, *path = nullptr, +static char *current_user = nullptr, *current_host = nullptr, *path = nullptr, *fields_terminated = nullptr, *lines_terminated = nullptr, *enclosed = nullptr, *opt_enclosed = nullptr, *escaped = nullptr, *where = nullptr, *opt_compatible_mode_str = nullptr, @@ -160,6 +158,7 @@ static char *opt_bind_addr = nullptr; static int first_error = 0; #include "caching_sha2_passwordopt-vars.h" +#include "multi_factor_passwordopt-vars.h" #include "sslopt-vars.h" FILE *md_result_file = nullptr; @@ -501,11 +500,7 @@ "InnoDB table, but will make the dump itself take considerably longer.", &opt_order_by_primary, &opt_order_by_primary, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, - {"password", 'p', - "Password to use when connecting to server. If password is not given it's " - "solicited on the tty.", - nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, - nullptr}, +#include "multi_factor_passwordopt-longopts.h" #ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -850,24 +845,7 @@ static bool get_one_option(int optid, const struct my_option *opt, char *argument) { switch (optid) { - case 'p': - if (argument == disabled_my_option) { - // Don't require password - static char empty_password[] = {'\0'}; - assert(empty_password[0] == - '\0'); // Check that it has not been overwritten - argument = empty_password; - } - if (argument) { - char *start = argument; - my_free(opt_password); - opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++ = 'x'; /* Destroy argument */ - if (*start) start[1] = 0; /* Cut length of argument */ - tty_password = false; - } else - tty_password = true; - break; + PARSE_COMMAND_LINE_PASSWORD_OPTION; case 'r': if (!(md_result_file = my_fopen(argument, O_WRONLY | MY_FOPEN_BINARY, MYF(MY_WME)))) @@ -918,7 +896,7 @@ exit(0); case (int)OPT_MASTER_DATA_DEPRECATED: CLIENT_WARN_DEPRECATED("--master-data", "--source-data"); - // FALLTHROUGH + [[fallthrough]]; case (int)OPT_SOURCE_DATA: if (!argument) /* work like in old versions */ opt_master_data = MYSQL_OPT_SOURCE_DATA_EFFECTIVE_SQL; @@ -932,7 +910,7 @@ break; case (int)OPT_MYSQLDUMP_SLAVE_DATA_DEPRECATED: CLIENT_WARN_DEPRECATED("--dump-slave", "--dump-replica"); - // FALLTHROUGH + [[fallthrough]]; case (int)OPT_MYSQLDUMP_REPLICA_DATA: if (!argument) /* work like in old versions */ opt_slave_data = MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL; @@ -1096,7 +1074,6 @@ short_usage(); return EX_USAGE; } - if (tty_password) opt_password = get_tty_password(NullS); return (0); } /* get_options */ @@ -1477,7 +1454,7 @@ static void free_resources() { if (md_result_file && md_result_file != stdout) my_fclose(md_result_file, MYF(0)); - my_free(opt_password); + free_passwords(); if (ignore_table != nullptr) { delete ignore_table; ignore_table = nullptr; @@ -1561,7 +1538,7 @@ db_connect -- connects to the host and selects DB. */ -static int connect_to_db(char *host, char *user, char *passwd) { +static int connect_to_db(char *host, char *user) { char buff[20 + FN_REFLEN]; DBUG_TRACE; @@ -1598,6 +1575,7 @@ "mysqldump"); set_server_public_key(&mysql_connection); set_get_server_public_key_option(&mysql_connection); + set_password_options(&mysql_connection); if (opt_compress_algorithm) mysql_options(&mysql_connection, MYSQL_OPT_COMPRESSION_ALGORITHMS, @@ -1618,7 +1596,7 @@ } if (!(mysql = - mysql_real_connect(&mysql_connection, host, user, passwd, nullptr, + mysql_real_connect(&mysql_connection, host, user, nullptr, nullptr, opt_mysql_port, opt_mysql_unix_port, 0))) { DB_error(&mysql_connection, "when trying to connect"); return 1; @@ -1695,6 +1673,7 @@ mysql, nullptr, "/*!80018 SET SESSION show_create_table_skip_secondary_engine=1 */")) return 1; + return 0; } /* connect_to_db */ @@ -1837,7 +1816,7 @@ fputs("_", xml_file); break; } - /* fall through */ + [[fallthrough]]; default: fputc(*str, xml_file); break; @@ -1963,7 +1942,7 @@ str += 2; continue; } - /* fall through */ + [[fallthrough]]; default: fputc(*str, xml_file); break; @@ -2059,7 +2038,7 @@ case '-': if (*(comment_string + 1) == '-') /* Only one hyphen allowed. */ break; - // Fall through. + [[fallthrough]]; default: fputc(*comment_string, xml_file); break; @@ -4493,7 +4472,7 @@ 0 Success. 1 Failure. */ -int init_dumping_views(char *qdatabase MY_ATTRIBUTE((unused))) { +int init_dumping_views(char *qdatabase [[maybe_unused]]) { return 0; } /* init_dumping_views */ @@ -4840,7 +4819,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) { char table_buff[NAME_LEN * 2 + 3]; DYNAMIC_STRING lock_tables_query; - MEM_ROOT root; + MEM_ROOT root(PSI_NOT_INSTRUMENTED, 8192); char **dump_tables, **pos, **end; DBUG_TRACE; @@ -4849,7 +4828,6 @@ if (init_dumping(db, init_dumping_tables)) return 1; - init_alloc_root(PSI_NOT_INSTRUMENTED, &root, 8192, 0); if (!(dump_tables = pos = (char **)root.Alloc(tables * sizeof(char *)))) die(EX_EOM, "alloc_root failure."); @@ -4867,7 +4845,7 @@ } else { if (!opt_force) { dynstr_free(&lock_tables_query); - free_root(&root, MYF(0)); + root.Clear(); } maybe_die(EX_ILLEGAL_TABLE, "Couldn't find table: \"%s\"", *table_names); /* We shall continue here, if --force was given */ @@ -4885,7 +4863,7 @@ (ulong)(lock_tables_query.length - 1))) { if (!opt_force) { dynstr_free(&lock_tables_query); - free_root(&root, MYF(0)); + root.Clear(); } DB_error(mysql, "when doing LOCK TABLES"); /* We shall continue here, if --force was given */ @@ -4894,7 +4872,7 @@ dynstr_free(&lock_tables_query); if (flush_logs) { if (mysql_refresh(mysql, REFRESH_LOG)) { - if (!opt_force) free_root(&root, MYF(0)); + if (!opt_force) root.Clear(); DB_error(mysql, "when doing refresh"); } /* We shall continue here, if --force was given */ @@ -4964,7 +4942,7 @@ DBUG_PRINT("info", ("Dumping routines for database %s", db)); dump_routines_for_db(db); } - free_root(&root, MYF(0)); + root.Clear(); if (opt_xml) { fputs("\n", md_result_file); check_io(md_result_file); @@ -5847,7 +5825,7 @@ } } - if (connect_to_db(current_host, current_user, opt_password)) { + if (connect_to_db(current_host, current_user)) { free_resources(); exit(EX_MYSQLERR); } diff -Nru mysql-8.0-8.0.26/client/mysqlimport.cc mysql-8.0-8.0.27/client/mysqlimport.cc --- mysql-8.0-8.0.26/client/mysqlimport.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysqlimport.cc 2021-09-28 11:46:34.000000000 +0000 @@ -63,15 +63,13 @@ static bool verbose = false, lock_tables = false, ignore_errors = false, opt_delete = false, replace = false, silent = false, ignore = false, - opt_compress = false, opt_low_priority = false, - tty_password = false; + opt_compress = false, opt_low_priority = false; static bool debug_info_flag = false, debug_check_flag = false; static uint opt_use_threads = 0, opt_local_file = 0, my_end_arg = 0; -static char *opt_password = nullptr, *current_user = nullptr, - *current_host = nullptr, *current_db = nullptr, - *fields_terminated = nullptr, *lines_terminated = nullptr, - *enclosed = nullptr, *opt_enclosed = nullptr, *escaped = nullptr, - *opt_columns = nullptr; +static char *current_user = nullptr, *current_host = nullptr, + *current_db = nullptr, *fields_terminated = nullptr, + *lines_terminated = nullptr, *enclosed = nullptr, + *opt_enclosed = nullptr, *escaped = nullptr, *opt_columns = nullptr; static const char *default_charset = MYSQL_AUTODETECT_CHARSET_NAME; static uint opt_enable_cleartext_plugin = 0; static bool using_opt_enable_cleartext_plugin = false; @@ -84,8 +82,8 @@ static char *opt_compress_algorithm = nullptr; #include "caching_sha2_passwordopt-vars.h" +#include "multi_factor_passwordopt-vars.h" #include "sslopt-vars.h" - #if defined(_WIN32) static char *shared_memory_base_name = 0; #endif @@ -178,11 +176,7 @@ "Use LOW_PRIORITY when updating the table.", &opt_low_priority, &opt_low_priority, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, - {"password", 'p', - "Password to use when connecting to server. If password is not given it's " - "asked from the tty.", - nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, - nullptr}, +#include "multi_factor_passwordopt-longopts.h" #ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -268,24 +262,7 @@ static bool get_one_option(int optid, const struct my_option *opt, char *argument) { switch (optid) { - case 'p': - if (argument == disabled_my_option) { - // Don't require password - static char empty_password[] = {'\0'}; - assert(empty_password[0] == - '\0'); // Check that it has not been overwritten - argument = empty_password; - } - if (argument) { - char *start = argument; - my_free(opt_password); - opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++ = 'x'; /* Destroy argument */ - if (*start) start[1] = 0; /* Cut length of argument */ - tty_password = false; - } else - tty_password = true; - break; + PARSE_COMMAND_LINE_PASSWORD_OPTION; #ifdef _WIN32 case 'W': opt_protocol = MYSQL_PROTOCOL_PIPE; @@ -343,7 +320,6 @@ } current_db = *((*argv)++); (*argc)--; - if (tty_password) opt_password = get_tty_password(NullS); return (0); } @@ -437,7 +413,7 @@ return 0; } -static MYSQL *db_connect(char *host, char *database, char *user, char *passwd) { +static MYSQL *db_connect(char *host, char *database, char *user, char *) { MYSQL *mysql; if (verbose) fprintf(stdout, "Connecting to %s\n", host ? host : "localhost"); if (opt_use_threads && !lock_tables) { @@ -487,7 +463,9 @@ "mysqlimport"); set_server_public_key(mysql); set_get_server_public_key_option(mysql); - if (!(mysql_real_connect(mysql, host, user, passwd, database, opt_mysql_port, + + set_password_options(mysql); + if (!(mysql_real_connect(mysql, host, user, nullptr, database, opt_mysql_port, opt_mysql_unix_port, 0))) { ignore_errors = false; /* NO RETURN FROM db_error */ db_error(mysql); @@ -580,8 +558,8 @@ if (mysql_thread_init()) goto error; - if (!(mysql = - db_connect(current_host, current_db, current_user, opt_password))) { + if (!(mysql = db_connect(current_host, current_db, current_user, + opt_password[0]))) { goto error; } @@ -699,7 +677,7 @@ my_free(worker_threads); } else { if (!(mysql = db_connect(current_host, current_db, current_user, - opt_password))) { + opt_password[0]))) { exitcode = 1; goto end; } @@ -724,7 +702,7 @@ } end: db_disconnect(current_host, mysql); - my_free(opt_password); + free_passwords(); #if defined(_WIN32) my_free(shared_memory_base_name); #endif diff -Nru mysql-8.0-8.0.26/client/mysql_secure_installation.cc mysql-8.0-8.0.27/client/mysql_secure_installation.cc --- mysql-8.0-8.0.26/client/mysql_secure_installation.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysql_secure_installation.cc 2021-09-28 11:46:34.000000000 +0000 @@ -131,9 +131,10 @@ } extern "C" { -static bool my_arguments_get_one_option( - int optid, const struct my_option *opt MY_ATTRIBUTE((unused)), - char *argument) { +static bool my_arguments_get_one_option(int optid, + const struct my_option *opt + [[maybe_unused]], + char *argument) { switch (optid) { case '?': usage(); diff -Nru mysql-8.0-8.0.26/client/mysqlshow.cc mysql-8.0-8.0.27/client/mysqlshow.cc --- mysql-8.0-8.0.26/client/mysqlshow.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysqlshow.cc 2021-09-28 11:46:34.000000000 +0000 @@ -49,10 +49,10 @@ #include "typelib.h" #include "welcome_copyright_notice.h" /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ -static char *host = nullptr, *opt_password = nullptr, *user = nullptr; +static char *host = nullptr, *user = nullptr; static bool opt_show_keys = false, opt_compress = false, opt_count = false, opt_status = false; -static bool tty_password = false, opt_table_type = false; +static bool opt_table_type = false; static bool debug_info_flag = false, debug_check_flag = false; static uint my_end_arg = 0; static uint opt_verbose = 0; @@ -64,6 +64,8 @@ static uint opt_zstd_compress_level = default_zstd_compression_level; static char *opt_compress_algorithm = nullptr; +#include "multi_factor_passwordopt-vars.h" + #if defined(_WIN32) static char *shared_memory_base_name = 0; #endif @@ -174,7 +176,8 @@ "mysqlshow"); set_server_public_key(&mysql); set_get_server_public_key_option(&mysql); - if (!(mysql_real_connect(&mysql, host, user, opt_password, + set_password_options(&mysql); + if (!(mysql_real_connect(&mysql, host, user, nullptr, (first_argument_uses_wildcards) ? "" : argv[0], opt_mysql_port, opt_mysql_unix_port, 0))) { fprintf(stderr, "%s: %s\n", my_progname, mysql_error(&mysql)); @@ -200,7 +203,7 @@ break; } mysql_close(&mysql); /* Close & free connection */ - my_free(opt_password); + free_passwords(); #if defined(_WIN32) my_free(shared_memory_base_name); #endif @@ -252,12 +255,7 @@ nullptr}, {"keys", 'k', "Show keys for table.", &opt_show_keys, &opt_show_keys, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, - {"password", 'p', - "Password to use when connecting to server. If password is not given, " - "it's " - "solicited on the tty.", - nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, - nullptr}, +#include "multi_factor_passwordopt-longopts.h" {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, @@ -341,24 +339,7 @@ case 'v': opt_verbose++; break; - case 'p': - if (argument == disabled_my_option) { - // Don't require password - static char empty_password[] = {'\0'}; - assert(empty_password[0] == - '\0'); // Check that it has not been overwritten - argument = empty_password; - } - if (argument) { - char *start = argument; - my_free(opt_password); - opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++ = 'x'; /* Destroy argument */ - if (*start) start[1] = 0; /* Cut length of argument */ - tty_password = false; - } else - tty_password = true; - break; + PARSE_COMMAND_LINE_PASSWORD_OPTION; case 'W': #ifdef _WIN32 opt_protocol = MYSQL_PROTOCOL_PIPE; @@ -395,7 +376,6 @@ if ((ho_error = handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); - if (tty_password) opt_password = get_tty_password(NullS); if (opt_count) { /* We need to set verbose to 2 as we need to change the output to include diff -Nru mysql-8.0-8.0.26/client/mysqlslap.cc mysql-8.0-8.0.27/client/mysqlslap.cc --- mysql-8.0-8.0.26/client/mysqlslap.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysqlslap.cc 2021-09-28 11:46:34.000000000 +0000 @@ -141,8 +141,7 @@ char **primary_keys; unsigned long long primary_keys_number_of; -static char *host = nullptr, *opt_password = nullptr, - *user_supplied_query = nullptr, +static char *host = nullptr, *user_supplied_query = nullptr, *user_supplied_pre_statements = nullptr, *user_supplied_post_statements = nullptr, *default_engine = nullptr, *pre_system = nullptr, *post_system = nullptr, @@ -159,7 +158,7 @@ static bool opt_preserve = true, opt_no_drop = false; static bool debug_info_flag = false, debug_check_flag = false; static bool opt_only_print = false; -static bool opt_compress = false, tty_password = false, opt_silent = false, +static bool opt_compress = false, opt_silent = false, auto_generate_sql_autoincrement = false, auto_generate_sql_guid_primary = false, auto_generate_sql = false; const char *auto_generate_sql_type = "mixed"; @@ -202,6 +201,8 @@ static uint opt_protocol = 0; +#include "multi_factor_passwordopt-vars.h" + static int get_options(int *argc, char ***argv); static uint opt_mysql_port = 0; @@ -379,8 +380,9 @@ (char *)&opt_enable_cleartext_plugin); set_server_public_key(&mysql); set_get_server_public_key_option(&mysql); + set_password_options(&mysql); if (!opt_only_print) { - if (!(mysql_real_connect(&mysql, host, user, opt_password, nullptr, + if (!(mysql_real_connect(&mysql, host, user, nullptr, nullptr, opt_mysql_port, opt_mysql_unix_port, connect_flags))) { fprintf(stderr, "%s: Error when connecting to server: %s\n", my_progname, @@ -427,7 +429,7 @@ mysql_close(&mysql); /* Close & free connection */ /* now free all the strings we created */ - my_free(opt_password); + free_passwords(); my_free(concurrency); statement_cleanup(create_statements); @@ -654,11 +656,7 @@ "been done.", &opt_only_print, &opt_only_print, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, - {"password", 'p', - "Password to use when connecting to server. If password is not given it's " - "asked from the tty.", - nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, - nullptr}, +#include "multi_factor_passwordopt-longopts.h" #ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -747,24 +745,7 @@ case 'v': verbose++; break; - case 'p': - if (argument == disabled_my_option) { - // Don't require password - static char empty_password[] = {'\0'}; - assert(empty_password[0] == - '\0'); // Check that it has not been overwritten - argument = empty_password; - } - if (argument) { - char *start = argument; - my_free(opt_password); - opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); - while (*argument) *argument++ = 'x'; /* Destroy argument */ - if (*start) start[1] = 0; /* Cut length of argument */ - tty_password = false; - } else - tty_password = true; - break; + PARSE_COMMAND_LINE_PASSWORD_OPTION; case 'W': #ifdef _WIN32 opt_protocol = MYSQL_PROTOCOL_PIPE; @@ -1415,8 +1396,6 @@ return 1; } } - - if (tty_password) opt_password = get_tty_password(NullS); return 0; } @@ -2054,10 +2033,15 @@ /* Connect to server */ static ulong connection_retry_sleep = 100000; /* Microseconds */ int x, connect_error = 1; + /* mysql options should be set to worker threads too */ + set_password_options(mysql); + if (using_opt_enable_cleartext_plugin) + mysql_options(mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN, + (char *)&opt_enable_cleartext_plugin); for (x = 0; x < 10; x++) { - if (mysql_real_connect(mysql, host, user, opt_password, - create_schema_string, opt_mysql_port, - opt_mysql_unix_port, connect_flags)) { + if (mysql_real_connect(mysql, host, user, nullptr, create_schema_string, + opt_mysql_port, opt_mysql_unix_port, + connect_flags)) { /* Connect suceeded */ connect_error = 0; break; diff -Nru mysql-8.0-8.0.26/client/mysqltest.cc mysql-8.0-8.0.27/client/mysqltest.cc --- mysql-8.0-8.0.26/client/mysqltest.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/client/mysqltest.cc 2021-09-28 11:46:34.000000000 +0000 @@ -246,6 +246,7 @@ static uint opt_zstd_compress_level = default_zstd_compression_level; static char *opt_compress_algorithm = nullptr; +static uint opt_test_ssl_fips_mode = 0; #ifdef _WIN32 static DWORD opt_safe_process_pid; @@ -677,7 +678,7 @@ ~AsyncTimer() { auto now = std::chrono::system_clock::now(); auto delta = now - start_; - ulonglong MY_ATTRIBUTE((unused)) micros = + [[maybe_unused]] ulonglong micros = std::chrono::duration_cast(delta).count(); DBUG_PRINT("async_timing", ("%s total micros: %llu", label_.c_str(), micros)); @@ -687,7 +688,7 @@ auto now = std::chrono::system_clock::now(); auto delta = now - time_; time_ = now; - ulonglong MY_ATTRIBUTE((unused)) micros = + [[maybe_unused]] ulonglong micros = std::chrono::duration_cast(delta).count(); DBUG_PRINT("async_timing", ("%s op micros: %llu", label_.c_str(), micros)); } @@ -2206,7 +2207,7 @@ break; /* ok */ case RESULT_LENGTH_MISMATCH: mess = "Result length mismatch\n"; - /* Fallthrough */ + [[fallthrough]]; case RESULT_CONTENT_MISMATCH: { /* Result mismatched, dump results to .reject file @@ -3194,7 +3195,7 @@ } static FILE *my_popen(DYNAMIC_STRING *ds_cmd, const char *mode, - struct st_command *command MY_ATTRIBUTE((unused))) { + struct st_command *command [[maybe_unused]]) { #ifdef _WIN32 /* --execw is for tests executing commands containing non-ASCII characters. @@ -4925,8 +4926,7 @@ return 0; } -static void do_wait_for_slave_to_stop( - struct st_command *c MY_ATTRIBUTE((unused))) { +static void do_wait_for_slave_to_stop(struct st_command *c [[maybe_unused]]) { static int SLAVE_POLL_INTERVAL = 300000; MYSQL *mysql = &cur_con->mysql; for (;;) { @@ -5660,7 +5660,7 @@ @param pid Process id. @param path Path to create minidump file in. */ -static void abort_process(int pid, const char *path MY_ATTRIBUTE((unused))) { +static void abort_process(int pid, const char *path [[maybe_unused]]) { #ifdef _WIN32 HANDLE proc; proc = OpenProcess(PROCESS_ALL_ACCESS, false, pid); @@ -6597,7 +6597,7 @@ static DYNAMIC_STRING ds_connection_name; static DYNAMIC_STRING ds_host; static DYNAMIC_STRING ds_user; - static DYNAMIC_STRING ds_password; + static DYNAMIC_STRING ds_password1; static DYNAMIC_STRING ds_database; static DYNAMIC_STRING ds_port; static DYNAMIC_STRING ds_sock; @@ -6606,12 +6606,14 @@ static DYNAMIC_STRING ds_shm; static DYNAMIC_STRING ds_compression_algorithm; static DYNAMIC_STRING ds_zstd_compression_level; + static DYNAMIC_STRING ds_password2; + static DYNAMIC_STRING ds_password3; const struct command_arg connect_args[] = { {"connection name", ARG_STRING, true, &ds_connection_name, "Name of the connection"}, {"host", ARG_STRING, true, &ds_host, "Host to connect to"}, {"user", ARG_STRING, false, &ds_user, "User to connect as"}, - {"passsword", ARG_STRING, false, &ds_password, + {"passsword", ARG_STRING, false, &ds_password1, "Password used when connecting"}, {"database", ARG_STRING, false, &ds_database, "Database to select after connect"}, @@ -6626,7 +6628,11 @@ {"default_zstd_compression_level", ARG_STRING, false, &ds_zstd_compression_level, "Default compression level to use " - "when using zstd compression."}}; + "when using zstd compression."}, + {"second_passsword", ARG_STRING, false, &ds_password2, + "Password used when connecting"}, + {"third_passsword", ARG_STRING, false, &ds_password3, + "Password used when connecting"}}; DBUG_TRACE; DBUG_PRINT("enter", ("connect: %s", command->first_argument)); @@ -6803,12 +6809,30 @@ mysql_options(&con_slot->mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN, (char *)&con_cleartext_enable); + unsigned int factor = 0; + if (ds_password1.length) { + factor = 1; + mysql_options4(&con_slot->mysql, MYSQL_OPT_USER_PASSWORD, &factor, + ds_password1.str); + } + /* set second and third password */ + if (ds_password2.length) { + factor = 2; + mysql_options4(&con_slot->mysql, MYSQL_OPT_USER_PASSWORD, &factor, + ds_password2.str); + } + if (ds_password3.length) { + factor = 3; + mysql_options4(&con_slot->mysql, MYSQL_OPT_USER_PASSWORD, &factor, + ds_password3.str); + } + /* Special database to allow one to connect without a database name */ if (ds_database.length && !std::strcmp(ds_database.str, "*NO-ONE*")) dynstr_set(&ds_database, ""); if (connect_n_handle_errors(command, &con_slot->mysql, ds_host.str, - ds_user.str, ds_password.str, ds_database.str, + ds_user.str, ds_password1.str, ds_database.str, con_port, ds_sock.str)) { DBUG_PRINT("info", ("Inserting connection %s in connection pool", ds_connection_name.str)); @@ -6826,7 +6850,7 @@ dynstr_free(&ds_connection_name); dynstr_free(&ds_host); dynstr_free(&ds_user); - dynstr_free(&ds_password); + dynstr_free(&ds_password1); dynstr_free(&ds_database); dynstr_free(&ds_port); dynstr_free(&ds_sock); @@ -6835,6 +6859,8 @@ dynstr_free(&ds_shm); dynstr_free(&ds_compression_algorithm); dynstr_free(&ds_zstd_compression_level); + dynstr_free(&ds_password2); + dynstr_free(&ds_password3); } static int do_done(struct st_command *command) { @@ -6940,11 +6966,14 @@ /* If this block is ignored */ if (!cur_block->ok) { - /* Inner block should be ignored too */ - cur_block++; - cur_block->cmd = cmd; - cur_block->ok = false; - cur_block->delim[0] = '\0'; + if (cmd == cmd_if || cmd == cmd_while) { + /* Inner block which comes with the command should be ignored */ + cur_block++; + cur_block->cmd = cmd; + cur_block->ok = false; + cur_block->delim[0] = '\0'; + } + /* No need to evaulate the condition */ return; } @@ -7782,6 +7811,12 @@ "inclusive. Default is 3.", &opt_zstd_compress_level, &opt_zstd_compress_level, nullptr, GET_UINT, REQUIRED_ARG, 3, 1, 22, nullptr, 0, nullptr}, + {"test-ssl-fips-mode", 0, + "Toggle SSL FIPS mode on or off, to see whether FIPS is supported. " + "Prints the result to stdout, and then exits. " + "Used by mtr to enable/disable FIPS tests. ", + &opt_test_ssl_fips_mode, nullptr, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, + nullptr, 0, nullptr}, {nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}}; @@ -7802,6 +7837,13 @@ static bool get_one_option(int optid, const struct my_option *opt, char *argument) { + if (opt_test_ssl_fips_mode) { + char ssl_err_string[OPENSSL_ERROR_LENGTH] = {'\0'}; + int fips_test = test_ssl_fips_mode(ssl_err_string); + fprintf(stdout, "--test-ssl-fips-mode %d %s\n", fips_test, + fips_test == 0 ? ssl_err_string : "Success"); + exit(0); + } switch (optid) { case '#': #ifndef NDEBUG @@ -9835,7 +9877,7 @@ command->query = command->first_argument; command->first_word_len = 0; } - /* fall through */ + [[fallthrough]]; case Q_QUERY: case Q_REAP: { bool old_display_result_vertically = display_result_vertically; @@ -10374,7 +10416,8 @@ to 1.2000000 */ if (size1 < (size_t)r) r = size1; - // fallthrough: all cases till next break are executed + // fallthrough: all cases till next break are executed + [[fallthrough]]; case 'e': case 'E': if (isdigit(*(from + size + 1))) { @@ -10505,7 +10548,7 @@ }; void replace_strings_append(REPLACE *rep, DYNAMIC_STRING *ds, const char *str, - size_t len MY_ATTRIBUTE((unused))) { + size_t len [[maybe_unused]]) { REPLACE *rep_pos; REPLACE_STRING *rep_str; const char *start, *from; diff -Nru mysql-8.0-8.0.26/cmake/boost.cmake mysql-8.0-8.0.27/cmake/boost.cmake --- mysql-8.0-8.0.26/cmake/boost.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/boost.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -39,7 +39,7 @@ # is installed on the compile host in the standard location. SET(BOOST_PACKAGE_NAME "boost_1_73_0") -SET(BOOST_TARBALL "${BOOST_PACKAGE_NAME}.tar.gz") +SET(BOOST_TARBALL "${BOOST_PACKAGE_NAME}.tar.bz2") SET(BOOST_DOWNLOAD_URL "https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/${BOOST_TARBALL}" ) @@ -146,7 +146,7 @@ IF (WITH_BOOST) ## Did we get a full path name, including file name? - IF (${WITH_BOOST} MATCHES ".*\\.tar.gz" OR ${WITH_BOOST} MATCHES ".*\\.zip") + IF (${WITH_BOOST} MATCHES ".*\\.tar.bz2" OR ${WITH_BOOST} MATCHES ".*\\.zip") GET_FILENAME_COMPONENT(BOOST_DIR ${WITH_BOOST} PATH) GET_FILENAME_COMPONENT(BOOST_ZIP ${WITH_BOOST} NAME) FIND_FILE(LOCAL_BOOST_ZIP @@ -155,9 +155,9 @@ NO_DEFAULT_PATH ) ENDIF() - ## Did we get a path name to the directory of the .tar.gz or .zip file? + ## Did we get a path name to the directory of the .tar.bz2 or .zip file? FIND_FILE(LOCAL_BOOST_ZIP - NAMES "${BOOST_PACKAGE_NAME}.tar.gz" "${BOOST_PACKAGE_NAME}.zip" + NAMES "${BOOST_PACKAGE_NAME}.tar.bz2" "${BOOST_PACKAGE_NAME}.zip" PATHS ${WITH_BOOST} NO_DEFAULT_PATH ) @@ -239,9 +239,9 @@ IF(LOCAL_BOOST_ZIP AND NOT LOCAL_BOOST_DIR) GET_FILENAME_COMPONENT(LOCAL_BOOST_DIR ${LOCAL_BOOST_ZIP} PATH) IF(NOT EXISTS "${LOCAL_BOOST_DIR}/${BOOST_PACKAGE_NAME}") - MESSAGE(STATUS "cd ${LOCAL_BOOST_DIR}; tar xfz ${LOCAL_BOOST_ZIP}") + MESSAGE(STATUS "cd ${LOCAL_BOOST_DIR}; tar xfj ${LOCAL_BOOST_ZIP}") EXECUTE_PROCESS( - COMMAND ${CMAKE_COMMAND} -E tar xfz "${LOCAL_BOOST_ZIP}" + COMMAND ${CMAKE_COMMAND} -E tar xfj "${LOCAL_BOOST_ZIP}" WORKING_DIRECTORY "${LOCAL_BOOST_DIR}" RESULT_VARIABLE tar_result ) diff -Nru mysql-8.0-8.0.26/cmake/build_configurations/compiler_options.cmake mysql-8.0-8.0.27/cmake/build_configurations/compiler_options.cmake --- mysql-8.0-8.0.26/cmake/build_configurations/compiler_options.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/build_configurations/compiler_options.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -24,19 +24,12 @@ INCLUDE(CheckCXXCompilerFlag) INCLUDE(cmake/floating_point.cmake) -IF(SIZEOF_VOIDP EQUAL 4) - SET(32BIT 1) -ENDIF() -IF(SIZEOF_VOIDP EQUAL 8) - SET(64BIT 1) -ENDIF() - SET(CMAKE_POSITION_INDEPENDENT_CODE ON) # Compiler options IF(UNIX) - IF(MY_COMPILER_IS_GNU_OR_CLANG AND NOT SOLARIS_SPARC) + IF(MY_COMPILER_IS_GNU_OR_CLANG AND NOT SOLARIS) SET(SECTIONS_FLAG "-ffunction-sections -fdata-sections") ELSE() SET(SECTIONS_FLAG) @@ -54,7 +47,7 @@ STRING_APPEND(COMMON_C_FLAGS " -ffp-contract=off") ENDIF() - SET(COMMON_CXX_FLAGS "-std=c++14 -fno-omit-frame-pointer") + SET(COMMON_CXX_FLAGS "-std=c++17 -fno-omit-frame-pointer") # Disable inline optimizations for valgrind testing to avoid false positives IF(WITH_VALGRIND) STRING_PREPEND(COMMON_CXX_FLAGS "-fno-inline ") @@ -68,7 +61,7 @@ # Default Clang flags IF(MY_COMPILER_IS_CLANG) SET(COMMON_C_FLAGS "-fno-omit-frame-pointer") - SET(COMMON_CXX_FLAGS "-std=c++14 -fno-omit-frame-pointer") + SET(COMMON_CXX_FLAGS "-std=c++17 -fno-omit-frame-pointer") ENDIF() # Faster TLS model @@ -77,178 +70,6 @@ STRING_APPEND(COMMON_CXX_FLAGS " -ftls-model=initial-exec") ENDIF() - # Solaris flags - IF(SOLARIS) - # Link mysqld with mtmalloc on Solaris 10 and later - SET(WITH_MYSQLD_LDFLAGS "-lmtmalloc" CACHE STRING "") - - IF(MY_COMPILER_IS_SUNPRO) - SET(SUNPRO_FLAGS "") - STRING_APPEND(SUNPRO_FLAGS " -xbuiltin=%all") - STRING_APPEND(SUNPRO_FLAGS " -xlibmil") - STRING_APPEND(SUNPRO_FLAGS " -xatomic=studio") - - # Show tags for warnings, so that they can be added to suppression list - SET(SUNPRO_FLAGS "${SUNPRO_FLAGS} -errtags") - - IF(SOLARIS_INTEL) - STRING_APPEND(SUNPRO_FLAGS " -nofstore") - ENDIF() - - SET(COMMON_C_FLAGS "${SUNPRO_FLAGS}") - - # Build list of C warning tags to suppress. Comment in/out as needed. - - # warning: useless declaration (E_USELESS_DECLARATION) - # Count: 8 - # LIST(APPEND SUNPRO_C_WARNING_SUPPRESSION_LIST E_USELESS_DECLARATION) - - # warning: empty translation unit (E_EMPTY_TRANSLATION_UNIT) - LIST(APPEND SUNPRO_C_WARNING_SUPPRESSION_LIST E_EMPTY_TRANSLATION_UNIT) - - # warning: initialization type mismatch (E_INITIALIZATION_TYPE_MISMATCH) - # Count: 114 - # LIST(APPEND SUNPRO_C_WARNING_SUPPRESSION_LIST - # E_INITIALIZATION_TYPE_MISMATCH) - - # warning: statement not reached (E_STATEMENT_NOT_REACHED) - # Count: 3 - # LIST(APPEND SUNPRO_C_WARNING_SUPPRESSION_LIST E_STATEMENT_NOT_REACHED) - - # warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND) - # Count: 1 - # LIST(APPEND SUNPRO_C_WARNING_SUPPRESSION_LIST E_INIT_SIGN_EXTEND) - - # warning: implicit function declaration: ntohl - # (E_NO_IMPLICIT_DECL_ALLOWED) - # Count: 2 - # LIST(APPEND SUNPRO_C_WARNING_SUPPRESSION_LIST E_NO_IMPLICIT_DECL_ALLOWED) - - # Convert CMAKE list to comma-separated string, and append to - # COMMON_C_FLAGS - STRING(REPLACE ";" "," SUNPRO_C_WARNING_SUPPRESSION_STRING - ${SUNPRO_C_WARNING_SUPPRESSION_LIST}) - SET(SUNPRO_C_WARNING_SUPPRESSION_FLAGS - "-erroff=${SUNPRO_C_WARNING_SUPPRESSION_STRING}") - STRING_APPEND(COMMON_C_FLAGS " ${SUNPRO_C_WARNING_SUPPRESSION_FLAGS}") - - - SET(COMMON_CXX_FLAGS "-std=c++14 ${SUNPRO_FLAGS}") - - # Build list of C++ warning tags to suppress. Comment in/out as needed. - - # Warning, anonnotype: Types cannot be declared in anonymous union. - # Count: 43 - LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST anonnotype) - - # Warning, fieldsemicolonw: extra ";" ignored. - # Count: 5 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST fieldsemicolonw) - - # Warning, wvarhidemem: key_type hides keyring::Key::key_type. - # Count: 2917 - LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST wvarhidemem) - - # Warning, anonstruct: Anonymous struct is being declared. - # Count: 717 - LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST anonstruct) - - # Warning, wlessrestrictedthrow: Function - # xcl::Connection_impl::~Connection_impl() can throw only the - # exceptions thrown by the function xcl::XConnection::~XConnection() - # it overrides. - # Count: 1221 - LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST wlessrestrictedthrow) - - # Warning, oklambdaretmulti: Deducing non-void lambda return type - # 'bool' from lambda without a single return statement. - # Count: 84 - LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST oklambdaretmulti) - - # Warning, nonewline: Last line in file ".../registry_metadata.cc.inc" - # is not terminated with a newline. - # Count: 58 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST nonewline) - - # Warning, voidretw: "worker_thread(void*)" is expected to return a - # value. - # Count: 1 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST voidretw) - - # Warning, unassigned: The variable ret has not yet been assigned a - # value. - # Count: 193 - LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST unassigned) - - # Warning, badinitstr: String literal converted to char* in - # initialization. - # Count: 6 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST badinitstr) - - # Warning, hidevf: meb::Process_data_mgr::get_buffer hides the virtual - # function meb::Data_mgr::get_buffer(unsigned long long). - # Count: 7 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST hidevf) - - # Warning, attrskipunsup: attribute unused is unsupported and will be - # skipped.. - # Count: 5 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST attrskipunsup) - - # Warning, nonvarrefww: A reference return value should be an lvalue - # (if the value of this function is used, the result is unpredictable). - # Count: 4 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST nonvarrefww) - - # Warning, explctspectypename: "typename" must be used within a template. - # Count: 1 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST explctspectypename) - - # Warning: Likely out-of-bound read: *(rhs+9[1]) in function decLnOp - # (SEC_ARR_OUTSIDE_BOUND_READ) - # Count: 10 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST SEC_ARR_OUTSIDE_BOUND_READ) - - # Warning (Anachronism), incomtypew: debug_sync_C_callback_ptr, of type - # void(*)(const char*,unsigned long), was previously declared - # extern "C" void(*)(const char*,unsigned long). - # Count: 1 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST, incomtypew) - - # Warning, symdeprecated: 'MD5_Init(MD5state_st*)' is deprecated - # (declared at /usr/include/openssl/md5.h, line 124). - # Count: 3 - #LIST(APPEND SUNPRO_CXX_WARNING_SUPPRESSION_LIST symdeprecated) - - # Convert CMAKE list to comma-separated string, and append to - # COMMON_CXX_FLAGS - STRING(REPLACE ";" "," SUNPRO_CXX_WARNING_SUPPRESSION_STRING - "${SUNPRO_CXX_WARNING_SUPPRESSION_LIST}") - SET(SUNPRO_CXX_WARNING_SUPPRESSION_FLAGS - "-erroff=${SUNPRO_CXX_WARNING_SUPPRESSION_STRING}") - STRING_APPEND(COMMON_CXX_FLAGS " ${SUNPRO_CXX_WARNING_SUPPRESSION_FLAGS}") - - - # Reduce size of debug binaries, by omitting function declarations. - # Note that we cannot set "-xdebuginfo=no%decl" during feature tests. - # We still may get linking errors for merge_large_tests-t with Studio 12.6 - # -g0 is the same as -g, except that inlining is enabled. - # When building -DWITH_NDBCLUSTER=1 even more of the merge_xxx_tests - # fail to link, so we keep -g0 for Studio 12.6 - STRING_APPEND(CMAKE_C_FLAGS_DEBUG " -g0 -xdebuginfo=no%decl") - STRING_APPEND(CMAKE_CXX_FLAGS_DEBUG " -g0 -xdebuginfo=no%decl") - STRING_APPEND(CMAKE_C_FLAGS_RELWITHDEBINFO " -xdebuginfo=no%decl") - STRING_APPEND(CMAKE_CXX_FLAGS_RELWITHDEBINFO " -xdebuginfo=no%decl") - - # Bugs in SunPro, compile/link error unless we add some debug info. - # Errors seem to be related to TLS functions. - STRING_APPEND(CMAKE_CXX_FLAGS_MINSIZEREL - " -g0 -xdebuginfo=no%line,no%param,no%decl,no%variable,no%tagtype") - STRING_APPEND(CMAKE_CXX_FLAGS_RELEASE - " -g0 -xdebuginfo=no%line,no%param,no%decl,no%variable,no%tagtype") - ENDIF() - ENDIF() - # Use STRING_PREPEND here, so command-line input can override our defaults. STRING_PREPEND(CMAKE_C_FLAGS "${COMMON_C_FLAGS} ") STRING_PREPEND(CMAKE_C_FLAGS_RELWITHDEBINFO "${SECTIONS_FLAG} ") diff -Nru mysql-8.0-8.0.26/cmake/cmake_policies.cmake mysql-8.0-8.0.27/cmake/cmake_policies.cmake --- mysql-8.0-8.0.26/cmake/cmake_policies.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/cmake_policies.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -39,6 +39,13 @@ CMAKE_POLICY(SET CMP0069 NEW) ENDIF() +# Do not produce ``_LIB_DEPENDS`` cache entries to propagate library +# link dependencies. In cmake code, use this instead: +# GET_TARGET_PROPERTY(TARGET_LIB_DEPENDS ${target} LINK_LIBRARIES) +IF(POLICY CMP0073) + CMAKE_POLICY(SET CMP0073 NEW) +ENDIF() + # In CMake 3.12 and above, the # # * ``check_include_file`` macro in the ``CheckIncludeFile`` module, the @@ -51,10 +58,3 @@ IF(POLICY CMP0075) CMAKE_POLICY(SET CMP0075 NEW) ENDIF() - -# Produce ``_LIB_DEPENDS`` cache entries to propagate library -# link dependencies. We use them in MERGE_CONVENIENCE_LIBRARIES. -# TODO(tdidriks): manage our own dependencies for "convenience" libraries. -IF(POLICY CMP0073) - CMAKE_POLICY(SET CMP0073 OLD) -ENDIF() diff -Nru mysql-8.0-8.0.26/cmake/compile_flags.cmake mysql-8.0-8.0.27/cmake/compile_flags.cmake --- mysql-8.0-8.0.26/cmake/compile_flags.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/compile_flags.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -53,13 +53,13 @@ ) ENDFOREACH() ENDFOREACH() -ENDFUNCTION() +ENDFUNCTION(ADD_COMPILE_FLAGS) -## ADD_COMPILE_DEFINITIONS( COMPILE_DEFINITIONS ) +## MY_ADD_COMPILE_DEFINITIONS( COMPILE_DEFINITIONS ) ## Use this for adding preprocessor flags VAR or VAR=value to source files. ## cmake will prefix with '-D' and sort all COMPILE_DEFINITIONS alphabetically. -FUNCTION(ADD_COMPILE_DEFINITIONS) +FUNCTION(MY_ADD_COMPILE_DEFINITIONS) SET(FILES "") SET(FLAGS "") SET(COMPILE_DEFINITIONS_SEEN) @@ -82,7 +82,7 @@ SET_SOURCE_FILES_PROPERTIES( ${FILE} PROPERTIES COMPILE_DEFINITIONS "${DEFS}") ENDFOREACH() -ENDFUNCTION() +ENDFUNCTION(MY_ADD_COMPILE_DEFINITIONS) # -flto[=n] or -flto=auto or -flto=jobserver SET(MY_COMPILER_FLAG_FLTO " -flto(=[0-9a-z]+)?") diff -Nru mysql-8.0-8.0.26/cmake/component.cmake mysql-8.0-8.0.27/cmake/component.cmake --- mysql-8.0-8.0.26/cmake/component.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/component.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -106,7 +106,12 @@ IF(UNIX) IF(MY_COMPILER_IS_CLANG AND WITH_UBSAN) # nothing, clang/ubsan gets confused + UNSET(COMPONENT_COMPILE_VISIBILITY CACHE) ELSE() + # Use this also for component libraries and tests. + SET(COMPONENT_COMPILE_VISIBILITY + "-fvisibility=hidden" CACHE INTERNAL + "Use -fvisibility=hidden for components" FORCE) TARGET_COMPILE_OPTIONS(${target} PRIVATE "-fvisibility=hidden") ENDIF() ENDIF() diff -Nru mysql-8.0-8.0.26/cmake/cpu_info.cmake mysql-8.0-8.0.27/cmake/cpu_info.cmake --- mysql-8.0-8.0.26/cmake/cpu_info.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/cpu_info.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -25,7 +25,7 @@ FIND_PROGRAM(GETCONF getconf) MARK_AS_ADVANCED(GETCONF) -IF(GETCONF AND NOT SOLARIS) +IF(GETCONF AND NOT SOLARIS AND NOT APPLE) EXECUTE_PROCESS( COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE diff -Nru mysql-8.0-8.0.26/cmake/fido2.cmake mysql-8.0-8.0.27/cmake/fido2.cmake --- mysql-8.0-8.0.26/cmake/fido2.cmake 1970-01-01 00:00:00.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/fido2.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -0,0 +1,129 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License, version 2.0, +# as published by the Free Software Foundation. +# +# This program is also distributed with certain software (including +# but not limited to OpenSSL) that is licensed under separate terms, +# as designated in a particular file or component or in included license +# documentation. The authors of MySQL hereby grant you an additional +# permission to link the program and your derivative works with the +# separately licensed software that they have included with MySQL. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License, version 2.0, for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# cmake -DWITH_FIDO=bundled|system + +# libudev is needed on Linux only. +FUNCTION(WARN_MISSING_SYSTEM_UDEV OUTPUT_WARNING) + IF(LINUX AND WITH_FIDO STREQUAL "bundled" AND NOT LIBUDEV_DEVEL_FOUND) + MESSAGE(WARNING "Cannot find development libraries. " + "You need to install the required packages:\n" + " Debian/Ubuntu: apt install libudev-dev\n" + " RedHat/Fedora/Oracle Linux: yum install libudev-devel\n" + " SuSE: zypper install libudev-devel\n" + ) + SET(${OUTPUT_WARNING} 1 PARENT_SCOPE) + ENDIF() + IF(SOLARIS) + MESSAGE(STATUS "No known libudev on SOLARIS") + SET(${OUTPUT_WARNING} 1 PARENT_SCOPE) + ENDIF() +ENDFUNCTION() + +# Bundled FIDO requires libudev. +MACRO(FIND_SYSTEM_UDEV_OR_HID) + IF(LINUX) + FIND_LIBRARY(UDEV_SYSTEM_LIBRARY NAMES udev) + CHECK_INCLUDE_FILE(libudev.h HAVE_LIBUDEV_H) + IF(UDEV_SYSTEM_LIBRARY AND HAVE_LIBUDEV_H) + SET(LIBUDEV_DEVEL_FOUND 1) + MESSAGE(STATUS "UDEV_SYSTEM_LIBRARY ${UDEV_SYSTEM_LIBRARY}") + ENDIF() + ELSEIF(FREEBSD) + FIND_LIBRARY(HID_LIBRARY NAMES hidapi) + IF(HID_LIBRARY) + MESSAGE(STATUS "HID_LIBRARY ${HID_LIBRARY}") + ELSE() + MESSAGE(WARNING "Cannot find development libraries. " + "You need to install the required packages:\n" + "FreeBSD: pkg install hidapi\n" + ) + ENDIF() + ENDIF() +ENDMACRO() + +FUNCTION(WARN_MISSING_SYSTEM_FIDO OUTPUT_WARNING) + IF(WITH_FIDO STREQUAL "system" AND NOT FIDO_FOUND) + MESSAGE(WARNING "Cannot find development libraries. " + "You need to install the required packages:\n" + " Debian/Ubuntu: apt install libfido2-dev\n" + " RedHat/Fedora/Oracle Linux: yum install libfido2-devel\n" + " SuSE: zypper install libfido2-devel\n" + ) + SET(${OUTPUT_WARNING} 1 PARENT_SCOPE) + ENDIF() +ENDFUNCTION() + +# Look for system fido2. If we find it, there is no need to look for libudev. +MACRO(FIND_SYSTEM_FIDO) + CHECK_INCLUDE_FILE(fido.h HAVE_FIDO_H) + FIND_LIBRARY(FIDO_LIBRARY fido2) + IF (FIDO_LIBRARY AND HAVE_FIDO_H) + SET(FIDO_FOUND TRUE) + FIND_PATH(FIDO_INCLUDE_DIR fido.h) + MESSAGE(STATUS "FIDO_LIBRARY ${FIDO_LIBRARY}") + ENDIF() +ENDMACRO() + +MACRO(MYSQL_USE_BUNDLED_FIDO) + SET(WITH_FIDO "bundled" CACHE STRING + "Bundled fido2 library") + + FIND_SYSTEM_UDEV_OR_HID() + + SET(CBOR_BUNDLE_SRC_PATH "extra/libcbor") + + SET(FIDO_BUNDLE_SRC_PATH "extra/libfido2") + SET(FIDO_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/${FIDO_BUNDLE_SRC_PATH}/src) + + # We use the bundled version, so: + SET(FIDO_FOUND TRUE) + + # Mark it as not found if libudev is missing, so we can give proper warnings. + IF(LINUX AND NOT LIBUDEV_DEVEL_FOUND) + SET(FIDO_FOUND FALSE) + ENDIF() + # So that we skip authentication_fido_client.so + IF(SOLARIS) + SET(FIDO_FOUND FALSE) + ENDIF() + SET(FIDO_LIBRARY fido2 CACHE INTERNAL "Bundled fido2 library") +ENDMACRO() + +MACRO(MYSQL_CHECK_FIDO) + IF (NOT WITH_FIDO) + SET(WITH_FIDO "bundled" + CACHE STRING "By default use bundled libfido2.") + ENDIF() + + IF(WITH_FIDO STREQUAL "bundled") + MYSQL_USE_BUNDLED_FIDO() + ELSEIF(WITH_FIDO STREQUAL "system") + FIND_SYSTEM_FIDO() + IF(NOT FIDO_FOUND) + MESSAGE(WARNING "Cannot find system fido2 libraries.") + ENDIF() + ELSE() + MESSAGE(WARNING "WITH_FIDO must be bundled or system") + ENDIF() + +ENDMACRO() diff -Nru mysql-8.0-8.0.26/cmake/googletest.cmake mysql-8.0-8.0.27/cmake/googletest.cmake --- mysql-8.0-8.0.26/cmake/googletest.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/googletest.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -20,7 +20,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(GOOGLETEST_RELEASE googletest-release-1.10.0) +SET(GOOGLETEST_RELEASE googletest-release-1.11.0) SET(GMOCK_SOURCE_DIR ${CMAKE_SOURCE_DIR}/extra/googletest/${GOOGLETEST_RELEASE}/googlemock) SET(GTEST_SOURCE_DIR @@ -59,14 +59,7 @@ TARGET_INCLUDE_DIRECTORIES(${googletest_library} SYSTEM PUBLIC ${GMOCK_INCLUDE_DIRS} ) - IF(MY_COMPILER_IS_SUNPRO) - TARGET_COMPILE_OPTIONS(${googletest_library} PRIVATE $<$:-xO4>) - ENDIF() IF(HAS_MISSING_PROFILE) TARGET_COMPILE_OPTIONS(${googletest_library} PRIVATE ${HAS_MISSING_PROFILE}) ENDIF() ENDFOREACH() - -IF(MY_COMPILER_IS_SUNPRO) - ADD_DEFINITIONS(-DGTEST_LANG_CXX11=1) -ENDIF() diff -Nru mysql-8.0-8.0.26/cmake/install_macros.cmake mysql-8.0-8.0.27/cmake/install_macros.cmake --- mysql-8.0-8.0.26/cmake/install_macros.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/install_macros.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -460,6 +460,87 @@ ENDIF() ENDMACRO() +MACRO(MYSQL_CHECK_FIDO_DLLS) + IF(APPLE AND WITH_FIDO STREQUAL "bundled") + ADD_CUSTOM_TARGET(symlink_fido2_dlls) + + # We want libfido2.1.dylib rather than libfido2.1.5.0.dylib below: + SET(TARGET_FILE_NAME_fido2 "libfido2.1.dylib") + + ADD_CUSTOM_TARGET(link_fido2_dlls_plugin ALL + COMMAND ${CMAKE_COMMAND} -E create_symlink + "../lib/${TARGET_FILE_NAME_fido2}" "${TARGET_FILE_NAME_fido2}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/plugin_output_directory" + + COMMENT "Creating fido2 symlinks in plugin_output_directory" + + BYPRODUCTS + "${CMAKE_BINARY_DIR}/plugin_output_directory/${TARGET_FILE_NAME_fido2}" + ) + ADD_DEPENDENCIES(symlink_fido2_dlls link_fido2_dlls_plugin) + + # Create some symlinks from lib/plugin/*.dylib to ../../lib/*.dylib + FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugin_output_directory/plugin") + ADD_CUSTOM_TARGET(link_fido2_dlls_plugin_install ALL + COMMAND ${CMAKE_COMMAND} -E create_symlink + "../../lib/${TARGET_FILE_NAME_fido2}" "${TARGET_FILE_NAME_fido2}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/plugin_output_directory/plugin" + ) + INSTALL(FILES + "${CMAKE_BINARY_DIR}/plugin_output_directory/plugin/${TARGET_FILE_NAME_fido2}" + DESTINATION ${INSTALL_PLUGINDIR} COMPONENT SharedLibraries + ) + IF(EXISTS ${DEBUGBUILDDIR}) + FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugin_output_directory/plugin/debug") + ADD_CUSTOM_TARGET(link_fido2_dlls_plugin_install_debug ALL + COMMAND ${CMAKE_COMMAND} -E create_symlink + "../../../lib/${TARGET_FILE_NAME_fido2}" "${TARGET_FILE_NAME_fido2}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/plugin_output_directory/plugin/debug" + ) + ADD_DEPENDENCIES(symlink_fido2_dlls link_fido2_dlls_plugin_install_debug) + INSTALL(FILES + "${CMAKE_BINARY_DIR}/plugin_output_directory/plugin/debug/${TARGET_FILE_NAME_fido2}" + DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT SharedLibraries + ) + ENDIF() + IF(NOT BUILD_IS_SINGLE_CONFIG) + ADD_CUSTOM_TARGET(link_fido2_dlls_plugin_xcode ALL + COMMAND ${CMAKE_COMMAND} -E create_symlink + "../../lib/${CMAKE_CFG_INTDIR}/${TARGET_FILE_NAME_fido2}" + "${TARGET_FILE_NAME_fido2}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/plugin_output_directory/${CMAKE_CFG_INTDIR}" + ) + ADD_DEPENDENCIES(symlink_fido2_dlls link_fido2_dlls_plugin_xcode) + ENDIF() + ENDIF() +ENDMACRO() + +MACRO(ADD_INSTALL_RPATH_FOR_FIDO2 TARGET) + MESSAGE(STATUS "ADD_INSTALL_RPATH_FOR_FIDO2 ${TARGET}") + IF(APPLE) + SET_PROPERTY(TARGET ${TARGET} PROPERTY INSTALL_RPATH "@loader_path") + # install_name_tool [-change old new] input + + SET(LIBFIDO_MAJOR_DYLIB "libfido2.1.dylib") + ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD + COMMAND install_name_tool -change + "@rpath/${LIBFIDO_MAJOR_DYLIB}" + "@loader_path/${LIBFIDO_MAJOR_DYLIB}" + "$" + ) + ELSEIF(UNIX) + GET_TARGET_PROPERTY(TARGET_TYPE_${TARGET} ${TARGET} TYPE) + IF(TARGET_TYPE_${TARGET} STREQUAL "EXECUTABLE") + ADD_INSTALL_RPATH(${TARGET} "\$ORIGIN/../${INSTALL_PRIV_LIBDIR}") + ELSEIF(TARGET_TYPE_${TARGET} STREQUAL "MODULE_LIBRARY") + ADD_INSTALL_RPATH(${TARGET} "\$ORIGIN/../private") + ELSE() + MESSAGE(FATAL_ERROR "unknown type ${TARGET_TYPE_${TARGET}} for ${TARGET}") + ENDIF() + ENDIF() +ENDMACRO() + + # For APPLE builds we support # -DWITH_SSL= # SSL libraries are installed in lib/ diff -Nru mysql-8.0-8.0.26/cmake/kerberos.cmake mysql-8.0-8.0.27/cmake/kerberos.cmake --- mysql-8.0-8.0.26/cmake/kerberos.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/kerberos.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -236,6 +236,14 @@ NO_SYSTEM_ENVIRONMENT_PATH ) + FIND_LIBRARY(GSSAPI_LIBRARIES + NAMES "gssapi_krb5" + PATHS ${WITH_KERBEROS}/lib + NO_DEFAULT_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + ) + FOREACH(EXTRA_LIB ${CUSTOM_KERBEROS_EXTRA_LIBRARIES}) SET(VAR_NAME "KERBEROS_CUSTOM_LIBRARY_${EXTRA_LIB}") FIND_LIBRARY(${VAR_NAME} @@ -271,6 +279,14 @@ SET(WITH_KERBEROS "none" CACHE INTERNAL "") ENDIF() + IF(WIN32) + SET(KERBEROS_LIB_SSPI 1) + MESSAGE(STATUS "Kerberos client is supported in windows using SSPI.") + ELSE() + UNSET(KERBEROS_LIB_SSPI) + UNSET(KERBEROS_LIB_SSPI CACHE) + ENDIF() + IF(NOT WITH_KERBEROS) IF(WITH_AUTHENTICATION_LDAP OR WITH_AUTHENTICATION_CLIENT_PLUGINS) SET(WITH_KERBEROS "system" CACHE STRING "${WITH_KERBEROS_DOC_STRING}") diff -Nru mysql-8.0-8.0.26/cmake/libutils.cmake mysql-8.0-8.0.27/cmake/libutils.cmake --- mysql-8.0-8.0.26/cmake/libutils.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/libutils.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -309,22 +309,24 @@ FUNCTION(GET_DEPENDEND_OS_LIBS target result) - SET(deps ${${target}_LIB_DEPENDS}) - IF(deps) - FOREACH(lib ${deps}) - # Filter out keywords for used for debug vs optimized builds - IF(NOT lib MATCHES "general" AND - NOT lib MATCHES "debug" AND - NOT lib MATCHES "optimized") - LIST(FIND KNOWN_CONVENIENCE_LIBRARIES ${lib} FOUNDIT) - IF(FOUNDIT LESS 0) - SET(ret ${ret} ${lib}) - ENDIF() + GET_TARGET_PROPERTY(TARGET_LIB_DEPENDS ${target} LINK_LIBRARIES) + SET(MY_DEPENDENT_OS_LIBS) + IF(TARGET_LIB_DEPENDS) + LIST(REMOVE_DUPLICATES TARGET_LIB_DEPENDS) + FOREACH(lib ${TARGET_LIB_DEPENDS}) + IF(lib MATCHES "${CMAKE_BINARY_DIR}") + # This is a "custom/imported" system lib (libssl libcrypto) + # MESSAGE(STATUS "GET_DEPENDEND_OS_LIBS ignore imported ${lib}") + ELSEIF(TARGET ${lib}) + # This is one of our own libraries + # MESSAGE(STATUS "GET_DEPENDEND_OS_LIBS ignore our ${lib}") + ELSE() + LIST(APPEND MY_DEPENDENT_OS_LIBS ${lib}) ENDIF() ENDFOREACH() ENDIF() - SET(${result} ${ret} PARENT_SCOPE) -ENDFUNCTION() + SET(${result} ${MY_DEPENDENT_OS_LIBS} PARENT_SCOPE) +ENDFUNCTION(GET_DEPENDEND_OS_LIBS) MACRO(MERGE_CONVENIENCE_LIBRARIES TARGET_ARG) @@ -338,9 +340,18 @@ SET(TARGET ${TARGET_ARG}) SET(LIBS ${ARG_UNPARSED_ARGUMENTS}) + # Add a dummy source file, with non-empty content, to avoid warning: + # libjson_binlog_static.a(json_binlog_static_depends.c.o) has no symbols SET(SOURCE_FILE ${CMAKE_BINARY_DIR}/archive_output_directory/${TARGET}_depends.c) + SET(SOURCE_FILE_CONTENT "void dummy_${TARGET}_function() {}") + CONFIGURE_FILE_CONTENT("${SOURCE_FILE_CONTENT}" "${SOURCE_FILE}") + ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE}) + MY_CHECK_CXX_COMPILER_WARNING("-Wmissing-profile" HAS_MISSING_PROFILE) + IF(FPROFILE_USE AND HAS_MISSING_PROFILE) + ADD_COMPILE_FLAGS(${SOURCE_FILE} COMPILE_FLAGS ${HAS_MISSING_PROFILE}) + ENDIF() IF(ARG_EXCLUDE_FROM_ALL) IF(NOT ARG_SKIP_INSTALL) diff -Nru mysql-8.0-8.0.26/cmake/maintainer.cmake mysql-8.0-8.0.27/cmake/maintainer.cmake --- mysql-8.0-8.0.26/cmake/maintainer.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/maintainer.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -59,8 +59,8 @@ SET(MY_CXX_WARNING_FLAGS "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wcast-qual") IF(MY_COMPILER_IS_GNU) - # The default =3 given by -Wextra is a bit too strict for our code. - MY_ADD_CXX_WARNING_FLAG("Wimplicit-fallthrough=2") + # Accept only the standard [[fallthrough]] attribute, no comments. + MY_ADD_CXX_WARNING_FLAG("Wimplicit-fallthrough=5") MY_ADD_C_WARNING_FLAG("Wjump-misses-init") # This is included in -Wall on some platforms, enable it explicitly. MY_ADD_C_WARNING_FLAG("Wstringop-truncation") @@ -186,15 +186,3 @@ ADD_COMPILE_OPTIONS("-Wshadow-uncaptured-local") ENDIF() ENDMACRO() - -# When builing with PGO, GCC 9 will report -Wmissing-profile when compiling -# files for which it cannot find profile data. It is valid to disable -# this warning for files we are not currently interested in profiling. -MACRO(DISABLE_MISSING_PROFILE_WARNING) - IF(FPROFILE_USE) - MY_CHECK_CXX_COMPILER_WARNING("-Wmissing-profile" HAS_WARN_FLAG) - IF(HAS_WARN_FLAG) - STRING_APPEND(CMAKE_CXX_FLAGS " ${HAS_WARN_FLAG}") - ENDIF() - ENDIF() -ENDMACRO() diff -Nru mysql-8.0-8.0.26/cmake/mysql_add_executable.cmake mysql-8.0-8.0.27/cmake/mysql_add_executable.cmake --- mysql-8.0-8.0.26/cmake/mysql_add_executable.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/mysql_add_executable.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -33,7 +33,6 @@ ENABLE_EXPORTS EXCLUDE_FROM_ALL # add target, but do not build it by default EXCLUDE_FROM_PGO # add target, but do not build for PGO - EXCLUDE_ON_SOLARIS # do not build by default on Solaris SKIP_INSTALL # do not install it ) SET(EXECUTABLE_ONE_VALUE_KW @@ -43,6 +42,8 @@ RUNTIME_OUTPUT_DIRECTORY ) SET(EXECUTABLE_MULTI_VALUE_KW + COMPILE_DEFINITIONS # for TARGET_COMPILE_DEFINITIONS + COMPILE_OPTIONS # for TARGET_COMPILE_OPTIONS DEPENDENCIES INCLUDE_DIRECTORIES # for TARGET_INCLUDE_DIRECTORIES LINK_LIBRARIES @@ -93,14 +94,6 @@ ENDIF() ENDIF() - IF(SOLARIS AND ARG_EXCLUDE_ON_SOLARIS) - MESSAGE(WARNING - "Likely link failure for this compiler, skipping target ${target}") - SET(ARG_EXCLUDE_FROM_ALL TRUE) - SET(ARG_SKIP_INSTALL TRUE) - UNSET(ARG_ADD_TEST) - ENDIF() - IF(ARG_ENABLE_EXPORTS) SET_TARGET_PROPERTIES(${target} PROPERTIES ENABLE_EXPORTS TRUE) ENDIF() @@ -116,6 +109,14 @@ SET_TARGET_PROPERTIES(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TARGET_RUNTIME_OUTPUT_DIRECTORY}) + IF(ARG_COMPILE_DEFINITIONS) + TARGET_COMPILE_DEFINITIONS(${target} PRIVATE ${ARG_COMPILE_DEFINITIONS}) + ENDIF() + + IF(ARG_COMPILE_OPTIONS) + TARGET_COMPILE_OPTIONS(${target} PRIVATE ${ARG_COMPILE_OPTIONS}) + ENDIF() + IF(WIN32_CLANG AND WITH_ASAN) TARGET_LINK_LIBRARIES(${target} "${ASAN_LIB_DIR}/clang_rt.asan-x86_64.lib") TARGET_LINK_LIBRARIES(${target} "${ASAN_LIB_DIR}/clang_rt.asan_cxx-x86_64.lib") diff -Nru mysql-8.0-8.0.26/cmake/mysql_version.cmake mysql-8.0-8.0.27/cmake/mysql_version.cmake --- mysql-8.0-8.0.26/cmake/mysql_version.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/mysql_version.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -25,7 +25,7 @@ # SET(SHARED_LIB_MAJOR_VERSION "21") -SET(SHARED_LIB_MINOR_VERSION "1") +SET(SHARED_LIB_MINOR_VERSION "2") SET(PROTOCOL_VERSION "10") # Generate "something" to trigger cmake rerun when MYSQL_VERSION changes diff -Nru mysql-8.0-8.0.26/cmake/os/Darwin.cmake mysql-8.0-8.0.27/cmake/os/Darwin.cmake --- mysql-8.0-8.0.26/cmake/os/Darwin.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/os/Darwin.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -28,16 +28,16 @@ SET(APPLE_ARM 1) ENDIF() -# We require at least XCode 9.0 +# We require at least XCode 10.0 IF(NOT FORCE_UNSUPPORTED_COMPILER) IF(MY_COMPILER_IS_CLANG) CHECK_C_SOURCE_RUNS(" int main() { - return (__clang_major__ < 9); + return (__clang_major__ < 10); }" HAVE_SUPPORTED_CLANG_VERSION) IF(NOT HAVE_SUPPORTED_CLANG_VERSION) - MESSAGE(FATAL_ERROR "XCode 9.0 or newer is required!") + MESSAGE(FATAL_ERROR "XCode 10.0 or newer is required!") ENDIF() ELSE() MESSAGE(FATAL_ERROR "Unsupported compiler!") @@ -53,8 +53,40 @@ ENDIF() ENDIF() -# Use Libtool -static rather than ranlib -SET(CMAKE_C_CREATE_STATIC_LIBRARY - "/usr/bin/libtool -static -no_warning_for_no_symbols -o ") -SET(CMAKE_CXX_CREATE_STATIC_LIBRARY - "/usr/bin/libtool -static -no_warning_for_no_symbols -o ") +# CMAKE_CXX_ARCHIVE_CREATE is by default +# " qc " +# And CMAKE_AR is "/usr/bin/ar" +# +# CMAKE_CXX_ARCHIVE_FINISH is by default +# " " +# and CMAKE_RANLIB is "/usr/bin/ranlib>" +# +# libtool has an option -no_warning_for_no_symbols +# but will generate lots of warnings for files with the same basename: +# /usr/bin/libtool: warning same member name (check_constraints.cc.o) .... +# +# To get a clean build, use 'ar' and ensure all source files are non-empty. +# Use this by default for Ninja and Makefiles. +IF(APPLE_XCODE) + SET(WITH_LIBTOOL_DEFAULT ON) +ELSE() + SET(WITH_LIBTOOL_DEFAULT OFF) +ENDIF() +OPTION(WITH_LIBTOOL + "Use 'libtool' rather than 'ar' for creating static libraries" + ${WITH_LIBTOOL_DEFAULT} + ) + +IF(WITH_LIBTOOL) + SET(CMAKE_C_CREATE_STATIC_LIBRARY + "/usr/bin/libtool -static -no_warning_for_no_symbols -o ") + SET(CMAKE_CXX_CREATE_STATIC_LIBRARY + "/usr/bin/libtool -static -no_warning_for_no_symbols -o ") +ELSE() + # This did not fix the "library.a(filename.cc.o) has no symbols" warnings. + # 'ranlib' has the -no_warning_for_no_symbols option, but 'ar' does not. + # STRING(REPLACE "" " -no_warning_for_no_symbols" + # CMAKE_C_ARCHIVE_FINISH "${CMAKE_C_ARCHIVE_FINISH}") + # STRING(REPLACE "" " -no_warning_for_no_symbols" + # CMAKE_CXX_ARCHIVE_FINISH "${CMAKE_CXX_ARCHIVE_FINISH}") +ENDIF() diff -Nru mysql-8.0-8.0.26/cmake/os/FreeBSD.cmake mysql-8.0-8.0.27/cmake/os/FreeBSD.cmake --- mysql-8.0-8.0.26/cmake/os/FreeBSD.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/os/FreeBSD.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -45,12 +45,8 @@ MESSAGE(FATAL_ERROR "Clang 6.0 or newer is required!") ENDIF() ELSEIF(MY_COMPILER_IS_GNU) - EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE GCC_VERSION) - IF(GCC_VERSION VERSION_LESS 5.3) - MESSAGE(FATAL_ERROR - "GCC 5.3 or newer is required (-dumpversion says ${GCC_VERSION})") + IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1) + MESSAGE(FATAL_ERROR "GCC 7.1 or newer is required") ENDIF() ELSE() MESSAGE(FATAL_ERROR "Unsupported compiler!") diff -Nru mysql-8.0-8.0.26/cmake/os/Linux.cmake mysql-8.0-8.0.27/cmake/os/Linux.cmake --- mysql-8.0-8.0.26/cmake/os/Linux.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/os/Linux.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -60,30 +60,15 @@ SET(LINUX_RPM_PLATFORM 1) ENDIF() -# We require at least GCC 5.3 or Clang 3.4. +# We require at least GCC 7.1 Clang 5 IF(NOT FORCE_UNSUPPORTED_COMPILER) IF(MY_COMPILER_IS_GNU) - EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE GCC_VERSION) - # -dumpversion may output only MAJOR.MINOR rather than MAJOR.MINOR.PATCH - IF(GCC_VERSION VERSION_LESS 5.3) - SET(WARNING_LEVEL WARNING) - IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) - SET(WARNING_LEVEL FATAL_ERROR) - ENDIF() - MESSAGE(${WARNING_LEVEL} - "GCC 5.3 or newer is required (-dumpversion says ${GCC_VERSION})") + IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1) + MESSAGE(FATAL_ERROR "GCC 7.1 or newer is required") ENDIF() ELSEIF(MY_COMPILER_IS_CLANG) - CHECK_C_SOURCE_RUNS(" - int main() - { - return (__clang_major__ < 3) || - (__clang_major__ == 3 && __clang_minor__ < 4); - }" HAVE_SUPPORTED_CLANG_VERSION) - IF(NOT HAVE_SUPPORTED_CLANG_VERSION) - MESSAGE(FATAL_ERROR "Clang 3.4 or newer is required!") + IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) + MESSAGE(FATAL_ERROR "Clang 5 or newer is required!") ENDIF() ELSE() MESSAGE(FATAL_ERROR "Unsupported compiler!") diff -Nru mysql-8.0-8.0.26/cmake/os/SunOS.cmake mysql-8.0-8.0.27/cmake/os/SunOS.cmake --- mysql-8.0-8.0.26/cmake/os/SunOS.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/os/SunOS.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -25,56 +25,33 @@ INCLUDE(CheckCSourceCompiles) INCLUDE(CheckCXXSourceCompiles) -SET(SOLARIS 1) IF(CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") SET(SOLARIS_SPARC 1) ELSE() - SET(SOLARIS_INTEL 1) + MESSAGE(FATAL_ERROR "Solaris on Intel is not supported.") ENDIF() -IF (NOT "${CMAKE_C_FLAGS}${CMAKE_CXX_FLAGS}" MATCHES "-m32|-m64") - IF(NOT FORCE_UNSUPPORTED_COMPILER) - MESSAGE("Adding -m64") - STRING_APPEND(CMAKE_C_FLAGS " -m64") - STRING_APPEND(CMAKE_CXX_FLAGS " -m64") - STRING_APPEND(CMAKE_C_LINK_FLAGS " -m64") - STRING_APPEND(CMAKE_CXX_LINK_FLAGS " -m64") - ENDIF() +IF("${CMAKE_C_FLAGS}${CMAKE_CXX_FLAGS}" MATCHES "-m32") + MESSAGE(FATAL_ERROR "32bit build not supported on Solaris.") +ENDIF() + +IF(NOT "${CMAKE_C_FLAGS}" MATCHES "-m64") + STRING_APPEND(CMAKE_C_FLAGS " -m64") +ENDIF() +IF(NOT "{CMAKE_CXX_FLAGS}" MATCHES "-m64") + STRING_APPEND(CMAKE_CXX_FLAGS " -m64") ENDIF() -INCLUDE(CheckTypeSize) -CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP) +STRING_APPEND(CMAKE_C_LINK_FLAGS " -m64") +STRING_APPEND(CMAKE_CXX_LINK_FLAGS " -m64") # We require at least SunStudio 12.6 (CC 5.15) IF(NOT FORCE_UNSUPPORTED_COMPILER) IF(MY_COMPILER_IS_SUNPRO) - IF(SIZEOF_VOIDP MATCHES 4) - MESSAGE(FATAL_ERROR "32 bit Solaris builds are not supported. ") - ENDIF() - # CC -V yields - # CC: Studio 12.6 Sun C++ 5.15 SunOS_sparc Beta 2016/12/19 - # CC: Studio 12.5 Sun C++ 5.14 SunOS_sparc Dodona 2016/04/04 - # CC: Sun C++ 5.13 SunOS_sparc Beta 2014/03/11 - # CC: Sun C++ 5.11 SunOS_sparc 2010/08/13 - EXECUTE_PROCESS( - COMMAND ${CMAKE_CXX_COMPILER} "-V" - OUTPUT_VARIABLE stdout - ERROR_VARIABLE stderr - RESULT_VARIABLE result - ) - STRING(REGEX MATCH "CC: Sun C\\+\\+ 5\\.([0-9]+)" VERSION_STRING ${stderr}) - IF (NOT CMAKE_MATCH_1 OR CMAKE_MATCH_1 STREQUAL "") - STRING(REGEX MATCH "CC: Studio 12\\.[56] Sun C\\+\\+ 5\\.([0-9]+)" - VERSION_STRING ${stderr}) - ENDIF() - SET(CC_MINOR_VERSION ${CMAKE_MATCH_1}) - IF(${CC_MINOR_VERSION} LESS 15) - MESSAGE(FATAL_ERROR "Oracle Studio 12.6 or newer is required!") - ENDIF() + MESSAGE(FATAL_ERROR "Oracle Studio is not supported.") ELSEIF(MY_COMPILER_IS_CLANG) MESSAGE(WARNING "Clang is experimental!!") ELSEIF(MY_COMPILER_IS_GNU) - MESSAGE(STATUS "CMAKE_CXX_COMPILER_VERSION is ${CMAKE_CXX_COMPILER_VERSION}") # 9.2.0 generated code which dumped core in optimized mode. IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.2) MESSAGE(FATAL_ERROR "GCC 10.2 or newer is required") @@ -94,10 +71,6 @@ # http://docs.oracle.com/cd/E19455-01/806-5257/6je9h033k/index.html ADD_DEFINITIONS(-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_PTHREADS) -# On Solaris, use of intrinsics will screw the lib search logic -# Force using -lm, so rint etc are found. -SET(LIBM m) - # CMake defined -lthread as thread flag. This crashes in dlopen # when trying to load plugins workaround with -lpthread SET(CMAKE_THREAD_LIBS_INIT -lpthread CACHE INTERNAL "" FORCE) @@ -105,142 +78,4 @@ # Solaris specific large page support CHECK_SYMBOL_EXISTS(MHA_MAPSIZE_VA sys/mman.h HAVE_SOLARIS_LARGE_PAGES) -# Solaris atomics -CHECK_C_SOURCE_RUNS( - " - #include - int main() - { - int foo = -10; int bar = 10; - int64_t foo64 = -10; int64_t bar64 = 10; - if (atomic_add_int_nv((uint_t *)&foo, bar) || foo) - return -1; - bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar); - if (bar || foo != 10) - return -1; - bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15); - if (bar) - return -1; - if (atomic_add_64_nv((volatile uint64_t *)&foo64, bar64) || foo64) - return -1; - bar64 = atomic_swap_64((volatile uint64_t *)&foo64, (uint64_t)bar64); - if (bar64 || foo64 != 10) - return -1; - bar64 = atomic_cas_64((volatile uint64_t *)&bar64, (uint_t)foo64, 15); - if (bar64) - return -1; - atomic_or_64((volatile uint64_t *)&bar64, 0); - return 0; - } -" HAVE_SOLARIS_ATOMIC) - -# This is used for the version_compile_machine variable. -IF(SIZEOF_VOIDP MATCHES 8 AND SOLARIS_INTEL) - SET(MYSQL_MACHINE_TYPE "x86_64") -ENDIF() - - -MACRO(DIRNAME IN OUT) - GET_FILENAME_COMPONENT(${OUT} ${IN} PATH) -ENDMACRO() - -# We assume that developer studio runtime libraries are installed. -IF(MY_COMPILER_IS_SUNPRO) - DIRNAME(${CMAKE_CXX_COMPILER} CXX_PATH) - - SET(LIBRARY_SUFFIX "lib/compilers/CC-gcc/lib") - IF(SIZEOF_VOIDP EQUAL 8 AND SOLARIS_SPARC) - SET(LIBRARY_SUFFIX "${LIBRARY_SUFFIX}/sparcv9") - ENDIF() - IF(SIZEOF_VOIDP EQUAL 8 AND SOLARIS_INTEL) - SET(LIBRARY_SUFFIX "${LIBRARY_SUFFIX}/amd64") - ENDIF() - FIND_LIBRARY(STL_LIBRARY_NAME - NAMES "stdc++" - PATHS ${CXX_PATH}/../${LIBRARY_SUFFIX} - NO_DEFAULT_PATH - ) - MESSAGE(STATUS "STL_LIBRARY_NAME ${STL_LIBRARY_NAME}") - IF(STL_LIBRARY_NAME) - DIRNAME(${STL_LIBRARY_NAME} STL_LIBRARY_PATH) - SET(LRFLAGS " -L${STL_LIBRARY_PATH} -R${STL_LIBRARY_PATH}") - SET(QUOTED_CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS}") - - STRING_APPEND(CMAKE_C_LINK_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_CXX_LINK_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_MODULE_LINKER_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_SHARED_LINKER_FLAGS "${LRFLAGS}") - STRING_APPEND(QUOTED_CMAKE_CXX_LINK_FLAGS "${LRFLAGS}") - ENDIF() - - STRING_APPEND(CMAKE_C_LINK_FLAGS " -lc") - STRING_APPEND(CMAKE_CXX_LINK_FLAGS " -lstdc++ -lgcc_s -lCrunG3 -lc") - STRING_APPEND(CMAKE_MODULE_LINKER_FLAGS " -lstdc++ -lgcc_s -lCrunG3 -lc") - STRING_APPEND(CMAKE_SHARED_LINKER_FLAGS " -lstdc++ -lgcc_s -lCrunG3 -lc") - STRING_APPEND(QUOTED_CMAKE_CXX_LINK_FLAGS " -lstdc++ -lgcc_s -lCrunG3 -lc") - - SET(LIBRARY_SUFFIX "lib/compilers/atomic") - IF(SIZEOF_VOIDP EQUAL 8 AND SOLARIS_SPARC) - SET(LIBRARY_SUFFIX "${LIBRARY_SUFFIX}/sparcv9") - ENDIF() - IF(SIZEOF_VOIDP EQUAL 8 AND SOLARIS_INTEL) - SET(LIBRARY_SUFFIX "${LIBRARY_SUFFIX}/amd64") - ENDIF() - FIND_LIBRARY(ATOMIC_LIBRARY_NAME - NAMES "statomic" - PATHS ${CXX_PATH}/../${LIBRARY_SUFFIX} - NO_DEFAULT_PATH - ) - MESSAGE(STATUS "ATOMIC_LIBRARY_NAME ${ATOMIC_LIBRARY_NAME}") - IF(ATOMIC_LIBRARY_NAME) - DIRNAME(${ATOMIC_LIBRARY_NAME} ATOMIC_LIB_PATH) - SET(LRFLAGS " -L${ATOMIC_LIB_PATH} -R${ATOMIC_LIB_PATH}") - - STRING_APPEND(CMAKE_C_LINK_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_CXX_LINK_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_MODULE_LINKER_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_SHARED_LINKER_FLAGS "${LRFLAGS}") - STRING_APPEND(QUOTED_CMAKE_CXX_LINK_FLAGS "${LRFLAGS}") - ENDIF() - - SET(QUOTED_CMAKE_CXX_LINK_FLAGS - "${QUOTED_CMAKE_CXX_LINK_FLAGS} -lstatomic ") -ENDIF() - -# Experimental support for clang on Intel Solaris. -# Try to build and run static_thread_local_test. -IF(MY_COMPILER_IS_CLANG AND SOLARIS_INTEL) - SET(CLANG_OUTPUT_FILE ${CMAKE_BINARY_DIR}/clang-output) - EXECUTE_PROCESS( - COMMAND ${CMAKE_CXX_COMPILER} --print-search-dirs - OUTPUT_FILE ${CLANG_OUTPUT_FILE} - ) - FILE(READ ${CLANG_OUTPUT_FILE} OUTPUT_FILE_CONTENTS) - STRING(REPLACE "\n" ";" OUTPUT_FILE_CONTENTS ${OUTPUT_FILE_CONTENTS}) - FOREACH(LINE ${OUTPUT_FILE_CONTENTS}) - STRING(REGEX MATCH "(libraries: =)(.*)" XXX ${LINE}) - IF(CMAKE_MATCH_1) - SET(LIBRARIES_STRING "${CMAKE_MATCH_2}") - ENDIF() - ENDFOREACH() - STRING(REPLACE ":" ";" LIBRARIES_LIST "${LIBRARIES_STRING}") - - SET(LRFLAGS "") - FOREACH(LIB_PATH ${LIBRARIES_LIST}) - GET_FILENAME_COMPONENT(REAL_PATH ${LIB_PATH} REALPATH) - STRING_APPEND(LRFLAGS " -Wl,-L${REAL_PATH} -Wl,-R${REAL_PATH}") - ENDFOREACH() - - STRING_APPEND(CMAKE_C_LINK_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_CXX_LINK_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_MODULE_LINKER_FLAGS "${LRFLAGS}") - STRING_APPEND(CMAKE_SHARED_LINKER_FLAGS "${LRFLAGS}") - - STRING_APPEND(CMAKE_C_LINK_FLAGS " -lc") - STRING_APPEND(CMAKE_CXX_LINK_FLAGS " -lstdc++ -lgcc_s -lc") - STRING_APPEND(CMAKE_MODULE_LINKER_FLAGS " -lstdc++ -lgcc_s -lc") - STRING_APPEND(CMAKE_SHARED_LINKER_FLAGS " -lstdc++ -lgcc_s -lc") - STRING_APPEND(QUOTED_CMAKE_CXX_LINK_FLAGS " -lstdc++ -lgcc_s -lc") -ENDIF() - SET(LINK_FLAG_Z_DEFS "-z,defs") diff -Nru mysql-8.0-8.0.26/cmake/os/Windows.cmake mysql-8.0-8.0.27/cmake/os/Windows.cmake --- mysql-8.0-8.0.26/cmake/os/Windows.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/os/Windows.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -38,22 +38,19 @@ SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/imsvc ") ENDIF() -# Optionally read user configuration, generated by configure.js. -# This is left for backward compatibility reasons only. -INCLUDE(${CMAKE_BINARY_DIR}/win/configure.data OPTIONAL) - # avoid running system checks by using pre-cached check results # system checks are expensive on VS since every tiny program is to be compiled # in a VC solution. GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake) -# We require at least Visual Studio 2019 Update 4 (aka 16.4), -# which has version nr 1924. +# We require at least Visual Studio 2019 Update 9 (aka 16.9), +# which has version nr 1928. +# https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-160 MESSAGE(STATUS "MSVC_VERSION is ${MSVC_VERSION}") -IF(NOT FORCE_UNSUPPORTED_COMPILER AND MSVC_VERSION LESS 1924) +IF(NOT FORCE_UNSUPPORTED_COMPILER AND MSVC_VERSION LESS 1928) MESSAGE(FATAL_ERROR - "Visual Studio 2019 Update 4 or newer is required!") + "Visual Studio 2019 Update 9 or newer is required!") ENDIF() # OS display name (version_compile_os etc). @@ -161,20 +158,13 @@ SET("${flag}" "${${flag}} /FC") ENDFOREACH() - # Turn on c++14 mode explicitly so that using c++17 features is disabled. - # For clang 10 we must use C++17. See: - # https://developercommunity.visualstudio.com/content/problem/665343/ - # vs2019-stl-with-clang-cl-and-stdc14-generates-dupl.html + # Turn on c++17 mode explicitly so that using c++20 features is disabled. FOREACH(flag CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT ) - IF(WIN32_CLANG) - SET("${flag}" "${${flag}} /std:c++17") - ELSE() - SET("${flag}" "${${flag}} /std:c++14") - ENDIF() + SET("${flag}" "${${flag}} /std:c++17") ENDFOREACH() FOREACH(type EXE SHARED MODULE) @@ -190,6 +180,25 @@ STRING_APPEND(CMAKE_CXX_FLAGS " /MP") ENDIF() + IF(WIN32_CLANG) + # Adding -Wno-deprecated-declarations does not silence warnings, + # so add misc. macros instead. + + # warning STL4015 The std::iterator class + # (used as a base class to provide typedefs) is deprecated in C++17 + STRING_APPEND(CMAKE_CXX_FLAGS + " -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING") + + # 'strcpy' is deprecated. This function or variable may be unsafe. + STRING_APPEND(CMAKE_C_FLAGS " -D_CRT_SECURE_NO_WARNINGS") + STRING_APPEND(CMAKE_CXX_FLAGS " -D_CRT_SECURE_NO_WARNINGS") + + # 'getpid' is deprecated. The POSIX name for this item is deprecated. + # Instead use the ISO C and C++ conformant name _getpid. + STRING_APPEND(CMAKE_C_FLAGS " -D_CRT_NONSTDC_NO_DEPRECATE") + STRING_APPEND(CMAKE_CXX_FLAGS " -D_CRT_NONSTDC_NO_DEPRECATE") + ENDIF() + #TODO: update the code and remove the disabled warnings # The compiler encountered a deprecated declaration. diff -Nru mysql-8.0-8.0.26/cmake/package_name.cmake mysql-8.0-8.0.27/cmake/package_name.cmake --- mysql-8.0-8.0.26/cmake/package_name.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/package_name.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -52,13 +52,7 @@ # SunOS 5.10=> solaris10 STRING(REPLACE "5." "" VER "${CMAKE_SYSTEM_VERSION}") SET(DEFAULT_PLATFORM "solaris${VER}") - IF(64BIT) - IF(SOLARIS_INTEL) - SET(DEFAULT_MACHINE "x86_64") - ELSE() - SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") - ENDIF() - ENDIF() + SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") ELSEIF(FREEBSD) STRING(REGEX MATCH "[0-9]+\\.[0-9]+" VER "${CMAKE_SYSTEM_VERSION}") SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}${VER}") diff -Nru mysql-8.0-8.0.26/cmake/plugin.cmake mysql-8.0-8.0.27/cmake/plugin.cmake --- mysql-8.0-8.0.26/cmake/plugin.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/plugin.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -33,6 +33,8 @@ STATIC_ONLY STORAGE_ENGINE TEST_ONLY + VISIBILITY_HIDDEN # Add -fvisibility=hidden on UNIX + # TODO(tdidriks) make this default if MODULE_ONLY ) SET(PLUGIN_ONE_VALUE_KW MODULE_OUTPUT_NAME @@ -273,7 +275,16 @@ TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) ENDIF() -ENDMACRO() + IF(BUILD_PLUGIN AND ARG_VISIBILITY_HIDDEN AND UNIX) + TARGET_COMPILE_OPTIONS(${target} PRIVATE "-fvisibility=hidden") + ENDIF() + + IF(BUILD_PLUGIN AND ARG_MODULE_ONLY) + ADD_OBJDUMP_TARGET(show_${target} "$" + DEPENDS ${target}) + ENDIF() + +ENDMACRO(MYSQL_ADD_PLUGIN) # Add all CMake projects under storage and plugin diff -Nru mysql-8.0-8.0.26/cmake/protobuf.cmake mysql-8.0-8.0.27/cmake/protobuf.cmake --- mysql-8.0-8.0.26/cmake/protobuf.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/protobuf.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -29,6 +29,37 @@ # Other values will be ignored, and we fall back to "bundled" # +# Bundled version is currently 3.11.1 +# Lowest checked system version is 3.5.0 on Oracle Linux 8. +# Older versions may generate code which breaks the -Werror build. +SET(MIN_PROTOBUF_VERSION_REQUIRED "3.5.0") + +MACRO(FIND_PROTOBUF_VERSION) + # Verify protobuf version number. Version information looks like: + # // The current version, represented as a single integer to make comparison + # // easier: major * 10^6 + minor * 10^3 + micro + # #define GOOGLE_PROTOBUF_VERSION 3012004 + FILE(STRINGS "${PROTOBUF_INCLUDE_DIR}/google/protobuf/stubs/common.h" + PROTOBUF_VERSION_NUMBER + REGEX "^#define[\t ]+GOOGLE_PROTOBUF_VERSION[\t ][0-9]+.*" + ) + MESSAGE(STATUS "PROTOBUF_VERSION_NUMBER is ${PROTOBUF_VERSION_NUMBER}") + STRING(REGEX MATCH + ".*VERSION[\t ]([0-9]+).*" V_NUM "${PROTOBUF_VERSION_NUMBER}") + + MATH(EXPR PB_MAJOR_VERSION "${CMAKE_MATCH_1} / 1000000") + MATH(EXPR MINOR_MICRO "${CMAKE_MATCH_1} - (1000000 * ${PB_MAJOR_VERSION})") + MATH(EXPR PB_MINOR_VERSION "${MINOR_MICRO} / 1000") + MATH(EXPR PB_MICRO_VERSION "${MINOR_MICRO} - (1000 * ${PB_MINOR_VERSION})") + + SET(PROTOBUF_VERSION + "${PB_MAJOR_VERSION}.${PB_MINOR_VERSION}.${PB_MICRO_VERSION}") + SET(PROTOBUF_VERSION "${PROTOBUF_VERSION}" CACHE INTERNAL + "PROTOBUF major.minor.micro") + MESSAGE(STATUS + "PROTOBUF_VERSION (${WITH_PROTOBUF}) is ${PROTOBUF_VERSION}") +ENDMACRO(FIND_PROTOBUF_VERSION) + MACRO(ECHO_PROTOBUF_VARIABLES) MESSAGE(STATUS "PROTOBUF_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIR}") MESSAGE(STATUS "PROTOBUF_LIBRARY ${PROTOBUF_LIBRARY}") @@ -38,8 +69,10 @@ MACRO(COULD_NOT_FIND_PROTOBUF) ECHO_PROTOBUF_VARIABLES() - MESSAGE(STATUS "Could not find (the correct version of) protobuf.") - MESSAGE(STATUS "MySQL currently requires at least protobuf version 3.0") + MESSAGE(WARNING + "Could not find (the correct version of) protobuf.\n" + "MySQL currently requires at least protobuf " + "version ${MIN_PROTOBUF_VERSION_REQUIRED}") MESSAGE(FATAL_ERROR "You can build with the bundled sources" ) @@ -85,7 +118,7 @@ NOT WITH_PROTOBUF STREQUAL "system") SET(WITH_PROTOBUF "bundled") ENDIF() - MESSAGE(STATUS "WITH_PROTOBUF=${WITH_PROTOBUF}") + IF(WITH_PROTOBUF STREQUAL "bundled") MYSQL_USE_BUNDLED_PROTOBUF() ELSE() @@ -110,27 +143,8 @@ MESSAGE(FATAL_ERROR "Use bundled protobuf, or install missing packages") ENDIF() - # Verify protobuf version number. Version information looks like: - # // The current version, represented as a single integer to make comparison - # // easier: major * 10^6 + minor * 10^3 + micro - # #define GOOGLE_PROTOBUF_VERSION 2006000 - FILE(STRINGS "${PROTOBUF_INCLUDE_DIR}/google/protobuf/stubs/common.h" - PROTOBUF_VERSION_NUMBER - REGEX "^#define[\t ]+GOOGLE_PROTOBUF_VERSION[\t ][0-9]+.*" - ) - STRING(REGEX REPLACE - "^.*GOOGLE_PROTOBUF_VERSION[\t ]([0-9])[0-9][0-9]([0-9])[0-9][0-9].*$" - "\\1" - PROTOBUF_MAJOR_VERSION "${PROTOBUF_VERSION_NUMBER}") - STRING(REGEX REPLACE - "^.*GOOGLE_PROTOBUF_VERSION[\t ]([0-9])[0-9][0-9]([0-9])[0-9][0-9].*$" - "\\2" - PROTOBUF_MINOR_VERSION "${PROTOBUF_VERSION_NUMBER}") - - MESSAGE(STATUS - "PROTOBUF_VERSION_NUMBER is ${PROTOBUF_VERSION_NUMBER}") - - IF("${PROTOBUF_MAJOR_VERSION}.${PROTOBUF_MINOR_VERSION}" VERSION_LESS "3.0") + FIND_PROTOBUF_VERSION() + IF("${PROTOBUF_VERSION}" VERSION_LESS "${MIN_PROTOBUF_VERSION_REQUIRED}") COULD_NOT_FIND_PROTOBUF() ENDIF() ECHO_PROTOBUF_VARIABLES() diff -Nru mysql-8.0-8.0.26/cmake/rapidjson.cmake mysql-8.0-8.0.27/cmake/rapidjson.cmake --- mysql-8.0-8.0.26/cmake/rapidjson.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/rapidjson.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -23,14 +23,6 @@ # We require rapidjson version 1.1.0 or higher. # -DWITH_RAPIDJSON=bundled is the default -IF(MY_COMPILER_IS_SUNPRO) - # Oracle Developer Studio 12.x isn't detected as c++11 compliant by rapidjson - # automatically. - ADD_DEFINITIONS(-DRAPIDJSON_HAS_CXX11_RANGE_FOR=1) - ADD_DEFINITIONS(-DRAPIDJSON_HAS_CXX11_NOEXCEPT=1) - ADD_DEFINITIONS(-DRAPIDJSON_HAS_CXX11_RVALUE_REFS=1) -ENDIF() - MACRO(WRONG_RAPIDJSON_VERSION) MESSAGE(FATAL_ERROR "rapidjson version 1.1.0 or higher is required.") ENDMACRO() diff -Nru mysql-8.0-8.0.26/cmake/zstd.cmake mysql-8.0-8.0.27/cmake/zstd.cmake --- mysql-8.0-8.0.26/cmake/zstd.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/cmake/zstd.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -62,10 +62,13 @@ ENDIF() ENDMACRO() +SET(ZSTD_VERSION_DIR "zstd-1.5.0") +SET(BUNDLED_ZSTD_PATH ${CMAKE_SOURCE_DIR}/extra/zstd/${ZSTD_VERSION_DIR}/lib) + MACRO (MYSQL_USE_BUNDLED_ZSTD) SET(ZSTD_LIBRARY zstd CACHE INTERNAL "Bundled zlib library") SET(WITH_ZSTD "bundled" CACHE STRING "Use bundled zstd") - SET(ZSTD_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extra/zstd/lib) + SET(ZSTD_INCLUDE_DIR ${BUNDLED_ZSTD_PATH}) INCLUDE_DIRECTORIES(BEFORE SYSTEM ${ZSTD_INCLUDE_DIR}) ADD_SUBDIRECTORY(extra/zstd) ENDMACRO() diff -Nru mysql-8.0-8.0.26/CMakeLists.txt mysql-8.0-8.0.27/CMakeLists.txt --- mysql-8.0-8.0.26/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -23,8 +23,8 @@ MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") IF(WIN32) - # CMake 3.8.0 is needed for Visual Studio 2017 and x64 toolset. - CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0) + # Load policies. This is needed in order to parse the wmic version check. + CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) EXECUTE_PROCESS(COMMAND wmic os get version OUTPUT_VARIABLE NT_RELEASE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE @@ -233,6 +233,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) INCLUDE(cmake_policies NO_POLICY_SCOPE) +IF(MY_HOST_SYSTEM_NAME MATCHES "SunOS") + SET(SOLARIS 1) +ENDIF() + IF(MY_HOST_SYSTEM_NAME MATCHES "Linux") # Trust 'rpm -qf /' rather than 'uname -s' STRING(REGEX MATCH "\\.el([678])\\." MATCH_FSYS "${MY_HOST_FILESYSTEM_NAME}") @@ -300,20 +304,52 @@ FIND_PROGRAM(ALTERNATIVE_GPP g++ NO_DEFAULT_PATH PATHS "${OPT_PATH}/root/usr/bin") + FIND_PROGRAM(ALTERNATIVE_LD ld + NO_DEFAULT_PATH + PATHS "${OPT_PATH}/root/usr/bin") + FIND_PROGRAM(ALTERNATIVE_AR ar + NO_DEFAULT_PATH + PATHS "${OPT_PATH}/root/usr/bin") + FIND_PROGRAM(ALTERNATIVE_RANLIB ranlib + NO_DEFAULT_PATH + PATHS "${OPT_PATH}/root/usr/bin") FIND_PROGRAM(ALTERNATIVE_ENABLE enable NO_DEFAULT_PATH PATHS "${OPT_PATH}") ENDFOREACH() - IF(ALTERNATIVE_GCC AND ALTERNATIVE_GPP) + # A missing ALTERNATIVE_LD may generate bad executables. + IF(ALTERNATIVE_GCC AND ALTERNATIVE_GPP AND ALTERNATIVE_LD) SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC}) SET(CMAKE_CXX_COMPILER ${ALTERNATIVE_GPP}) + SET(CMAKE_LINKER ${ALTERNATIVE_LD}) + SET(CMAKE_LINKER ${ALTERNATIVE_LD} CACHE PATH "Alternative ld") + IF(ALTERNATIVE_AR) + SET(CMAKE_AR ${ALTERNATIVE_AR}) + SET(CMAKE_AR ${ALTERNATIVE_AR} CACHE PATH "Alternative ar") + ENDIF() + IF(ALTERNATIVE_RANLIB) + SET(CMAKE_RANLIB ${ALTERNATIVE_RANLIB}) + SET(CMAKE_RANLIB ${ALTERNATIVE_RANLIB} CACHE PATH "Alternative ranlib") + ENDIF() MESSAGE(STATUS "Using ${ALTERNATIVE_GCC}") MESSAGE(STATUS "Using ${ALTERNATIVE_GPP}") ELSE() + IF(LINUX_RHEL6) + SET(DEV_PACKAGES + "devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils") + ELSEIF(LINUX_RHEL7) + SET(DEV_PACKAGES + "devtoolset-10-gcc devtoolset-10-gcc-c++ devtoolset-10-binutils") + ELSEIF(LINUX_RHEL8) + SET(DEV_PACKAGES + "gcc-toolset-10-gcc gcc-toolset-10-gcc-c++ gcc-toolset-10-binutils") + ENDIF() MESSAGE(WARNING - "Could not find devtoolset compiler in ${ALTERNATIVE_PATHS}") + "Could not find devtoolset compiler/linker in ${ALTERNATIVE_PATHS}") + MESSAGE(WARNING "You need to install the required packages:\n" + " yum install ${DEV_PACKAGES}\n") MESSAGE(FATAL_ERROR - "Please set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.") + "Or you can set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.") ENDIF() ELSEIF(LINUX_UBUNTU_18_04) @@ -324,6 +360,20 @@ FIND_PROGRAM(ALTERNATIVE_GPP g++-8 NO_DEFAULT_PATH PATHS "/usr/bin") + FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar-8 + NO_DEFAULT_PATH + PATHS "/usr/bin") + FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib-8 + NO_DEFAULT_PATH + PATHS "/usr/bin") + IF(GCC_AR_EXECUTABLE) + SET(CMAKE_AR ${GCC_AR_EXECUTABLE}) + SET(CMAKE_AR ${GCC_AR_EXECUTABLE} CACHE PATH "Alternative ar") + ENDIF() + IF(GCC_RANLIB_EXECUTABLE) + SET(CMAKE_RANLIB ${GCC_RANLIB_EXECUTABLE}) + SET(CMAKE_RANLIB ${GCC_RANLIB_EXECUTABLE} CACHE PATH "Alternative ranlib") + ENDIF() IF (ALTERNATIVE_GCC AND ALTERNATIVE_GPP) SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC}) SET(CMAKE_CXX_COMPILER ${ALTERNATIVE_GPP}) @@ -345,6 +395,12 @@ FIND_PROGRAM(ALTERNATIVE_GPP g++-10 NO_DEFAULT_PATH PATHS "/usr/bin") + FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar-10 + NO_DEFAULT_PATH + PATHS "/usr/bin") + FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib-10 + NO_DEFAULT_PATH + PATHS "/usr/bin") ELSEIF(LINUX_SUSE_15) FIND_PROGRAM(ALTERNATIVE_GCC gcc-9 NO_DEFAULT_PATH @@ -352,6 +408,20 @@ FIND_PROGRAM(ALTERNATIVE_GPP g++-9 NO_DEFAULT_PATH PATHS "/usr/bin") + FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar-9 + NO_DEFAULT_PATH + PATHS "/usr/bin") + FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib-9 + NO_DEFAULT_PATH + PATHS "/usr/bin") + ENDIF() + IF(GCC_AR_EXECUTABLE) + SET(CMAKE_AR ${GCC_AR_EXECUTABLE}) + SET(CMAKE_AR ${GCC_AR_EXECUTABLE} CACHE PATH "Alternative ar") + ENDIF() + IF(GCC_RANLIB_EXECUTABLE) + SET(CMAKE_RANLIB ${GCC_RANLIB_EXECUTABLE}) + SET(CMAKE_RANLIB ${GCC_RANLIB_EXECUTABLE} CACHE PATH "Alternative ranlib") ENDIF() IF (ALTERNATIVE_GCC AND ALTERNATIVE_GPP) SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC}) @@ -373,6 +443,22 @@ "or set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.") ENDIF() ENDIF() + ELSEIF(SOLARIS) + MESSAGE(STATUS "Looking for GCC 10 on Solaris.") + FIND_PROGRAM(ALTERNATIVE_GCC gcc + NO_DEFAULT_PATH + PATHS "/usr/gcc/10/bin") + FIND_PROGRAM(ALTERNATIVE_GPP g++ + NO_DEFAULT_PATH + PATHS "/usr/gcc/10/bin") + IF (ALTERNATIVE_GCC AND ALTERNATIVE_GPP) + SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC}) + SET(CMAKE_CXX_COMPILER ${ALTERNATIVE_GPP}) + MESSAGE(STATUS "Using ${ALTERNATIVE_GCC}") + MESSAGE(STATUS "Using ${ALTERNATIVE_GPP}") + ELSE() + MESSAGE(WARNING "Could not find /usr/gcc/10/bin/gcc") + ENDIF() ENDIF() ENDIF() ENDIF() @@ -593,11 +679,14 @@ # Add RPM or DEB platform flags for STANDALONE build. # Not for DEBUG builds, since both platforms use -O2 and _FORTIFY_SOURCE. +# Not for Release or MinSizeRel, it will inflate binary sizes. IF(LINUX_STANDALONE AND (LINUX_DEB_PLATFORM OR LINUX_RPM_PLATFORM)) IF(CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG" OR WITH_DEBUG) SET(WITH_PACKAGE_FLAGS_DEFAULT OFF) - ELSE() + ELSEIF(CMAKE_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO") SET(WITH_PACKAGE_FLAGS_DEFAULT ON) + ELSE() + SET(WITH_PACKAGE_FLAGS_DEFAULT OFF) ENDIF() OPTION(WITH_PACKAGE_FLAGS "Use DEB/RPM compiler flags" ${WITH_PACKAGE_FLAGS_DEFAULT}) @@ -628,6 +717,18 @@ INCLUDE(${CMAKE_SOURCE_DIR}/cmake/build_configurations/compiler_options.cmake) ENDIF() +# Set correct search path for executables, libraries, and data files. +IF(LINUX_RHEL) + IF(ALTERNATIVE_GCC) + GET_FILENAME_COMPONENT(GCC_B_PREFIX ${ALTERNATIVE_GCC} DIRECTORY) + STRING_PREPEND(CMAKE_C_FLAGS "-B${GCC_B_PREFIX} ") + ENDIF() + IF(ALTERNATIVE_GPP) + GET_FILENAME_COMPONENT(GPP_B_PREFIX ${ALTERNATIVE_GPP} DIRECTORY) + STRING_PREPEND(CMAKE_CXX_FLAGS "-B${GPP_B_PREFIX} ") + ENDIF() +ENDIF() + INCLUDE(CMakePushCheckState) # Add macros @@ -660,7 +761,7 @@ INCLUDE(rapidjson) INCLUDE(fprofile) INCLUDE(gloves) - +INCLUDE(fido2) IF(UNIX) OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF) @@ -736,10 +837,21 @@ "Report error if the Kerberos authentication plugin cannot be built." ${WITH_AUTHENTICATION_KERBEROS_DEFAULT}) +IF(WITH_INTERNAL AND (NOT SOLARIS)) + SET(WITH_AUTHENTICATION_FIDO_DEFAULT ON) +ELSE() + SET(WITH_AUTHENTICATION_FIDO_DEFAULT OFF) +ENDIF() + +OPTION(WITH_AUTHENTICATION_FIDO + "Report error if the FIDO authentication plugin cannot be built." + ${WITH_AUTHENTICATION_FIDO_DEFAULT}) + # Default ON if we are building server-side plugins. # Also default ON in pushbuild, for our community builds. IF(WITH_AUTHENTICATION_KERBEROS OR WITH_AUTHENTICATION_LDAP OR + WITH_AUTHENTICATION_FIDO OR DEFINED ENV{PB2WORKDIR}) SET(WITH_AUTHENTICATION_CLIENT_PLUGINS_DEFAULT ON) ELSE() @@ -751,6 +863,8 @@ # authentication_kerberos_client.so # The LDAP client authentication plugin # authentication_ldap_sasl_client.so +# The FIDO client authentication plugin +# authentication_fido_client.so OPTION(WITH_AUTHENTICATION_CLIENT_PLUGINS "Build client-side authentication plugins, even if server-side are disabled" ${WITH_AUTHENTICATION_CLIENT_PLUGINS_DEFAULT}) @@ -857,6 +971,19 @@ ENDIF() ENDFUNCTION() +# When builing with PGO, GCC will report -Wmissing-profile when compiling +# files for which it cannot find profile data. It is valid to disable +# this warning for files we are not currently interested in profiling. +MACRO(DISABLE_MISSING_PROFILE_WARNING) + IF(FPROFILE_USE) + MY_CHECK_CXX_COMPILER_WARNING("-Wmissing-profile" HAS_WARN_FLAG) + IF(HAS_WARN_FLAG) + STRING_APPEND(CMAKE_C_FLAGS " ${HAS_WARN_FLAG}") + STRING_APPEND(CMAKE_CXX_FLAGS " ${HAS_WARN_FLAG}") + ENDIF() + ENDIF() +ENDMACRO() + MACRO(MY_SANITIZER_CHECK SAN_OPT ADD_OPTIMIZATION RESULT) MY_CHECK_C_COMPILER_FLAG("${SAN_OPT}" C_RESULT) MY_CHECK_CXX_COMPILER_FLAG("${SAN_OPT}" CXX_RESULT) @@ -1188,8 +1315,12 @@ STRING_APPEND(CMAKE_C_FLAGS " ${DEBUG_PREFIX_FLAGS}") STRING_APPEND(CMAKE_CXX_FLAGS " ${DEBUG_PREFIX_FLAGS}") - STRING_APPEND(CMAKE_C_LINK_FLAGS " -Wl,--build-id=none") - STRING_APPEND(CMAKE_CXX_LINK_FLAGS " -Wl,--build-id=none") + # DEB/RPM will want to set build id. + IF(INSTALL_LAYOUT MATCHES "STANDALONE" OR INSTALL_LAYOUT MATCHES "TARGZ") + STRING_APPEND(CMAKE_C_LINK_FLAGS " -Wl,--build-id=none") + STRING_APPEND(CMAKE_CXX_LINK_FLAGS " -Wl,--build-id=none") + ENDIF() + SET(BISON_NO_LINE_OPT "--no-lines") SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE @@ -1412,6 +1543,7 @@ SSL ZLIB ZSTD + FIDO ) SET(WITH_SYSTEM_LIBS_DEFAULT OFF) @@ -1591,6 +1723,28 @@ # Add RapidJSON library. MYSQL_CHECK_RAPIDJSON() +# Look for fido2 library +MYSQL_CHECK_FIDO() +MYSQL_CHECK_FIDO_DLLS() + +IF(WITH_AUTHENTICATION_FIDO OR WITH_AUTHENTICATION_CLIENT_PLUGINS) + IF(WITH_FIDO STREQUAL "system" AND + NOT WITH_SSL STREQUAL "system") + MESSAGE(WARNING "-DWITH_AUTHENTICATION_FIDO=ON") + MESSAGE(FATAL_ERROR "Inconsistent options for FIDO/SSL") + ENDIF() + + # FIDO (or libudev) missing, warn about what is missing, and break the build. + IF(WITH_AUTHENTICATION_FIDO AND NOT FIDO_FOUND) + SET(UDEV_WARN_MISSING) + SET(FIDO_WARN_MISSING) + WARN_MISSING_SYSTEM_UDEV(UDEV_WARN_MISSING) + WARN_MISSING_SYSTEM_FIDO(FIDO_WARN_MISSING) + MESSAGE(FATAL_ERROR + "-DWITH_AUTHENTICATION_FIDO=ON, but missing required libraries") + ENDIF() +ENDIF() + MACRO(MY_INCLUDE_SYSTEM_DIRECTORIES LIBRARY) IF(${WITH_${LIBRARY}} STREQUAL "bundled") SET(BEFORE_OR_AFTER "BEFORE") @@ -1640,11 +1794,33 @@ HAVE_PTHREAD_SETNAME_NP) ENDIF() -IF(WITH_PROTOBUF STREQUAL "bundled") +IF(WITH_PROTOBUF STREQUAL "bundled" OR WITH_FIDO STREQUAL "bundled") # Protobuf library is a target, installed to /${INSTALL_PRIV_LIBDIR} # INSTALL_RPATH must be set for all binaries linking with libprotobuf. - SET(UNIX_INSTALL_RPATH_ORIGIN_PRIV_LIBDIR 1) - ADD_SUBDIRECTORY(extra/protobuf) + IF(WITH_PROTOBUF STREQUAL "bundled") + SET(UNIX_INSTALL_RPATH_ORIGIN_PRIV_LIBDIR 1) + ADD_SUBDIRECTORY(extra/protobuf) + ENDIF() + + # The Fido library is a target, installed to /${INSTALL_PRIV_LIBDIR} + # INSTALL_RPATH must be set for all binaries linking with libfido2. + IF(WITH_FIDO STREQUAL "bundled") + SET(INSTALL_RPATH_FOR_FIDO2 1) + + # Do not break the build here in case of missing libudev on Linux. + SET(UDEV_WARN_MISSING FALSE) + WARN_MISSING_SYSTEM_UDEV(UDEV_WARN_MISSING) + IF((WITH_AUTHENTICATION_FIDO OR WITH_AUTHENTICATION_CLIENT_PLUGINS) + AND NOT UDEV_WARN_MISSING) + # Silence warning about CMP0075 + CMAKE_PUSH_CHECK_STATE() + SET(CMAKE_REQUIRED_LIBRARIES) + ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${CBOR_BUNDLE_SRC_PATH}) + ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/${FIDO_BUNDLE_SRC_PATH}) + CMAKE_POP_CHECK_STATE() + ENDIF() + ENDIF() + IF(NOT APPLE AND NOT WIN32) # Debug versions of plugins may be installed to /lib/plugin/debug FOREACH(LINK_FLAG @@ -1702,18 +1878,6 @@ ADD_SUBDIRECTORY(libbinlogstandalone) IF(NOT WITHOUT_SERVER) - # Build failure on Solaris 11.3 for debug builds with NDBCLUSTER. - # Adding basic local optimizations unbreaks it. - # We *could* test 'uname -v' VERSION_LESS 11.4 here. - # A clean build takes roughly the same time with or without -xO1 - # Link time of mysqld is roughly 10% faster with -xO1. - IF(SOLARIS_SPARC AND MY_COMPILER_IS_SUNPRO AND - CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG") - MESSAGE(STATUS - "Adding -xO1 for debug builds on Solaris ${MY_KERNEL_VERSION}") - STRING_APPEND(CMAKE_CXX_FLAGS_DEBUG " -xO1") - ENDIF() - IF(WITH_UNIT_TESTS) IF(WIN32) SET(WITH_SHARED_UNITTEST_LIBRARY_DEFAULT OFF) @@ -2008,6 +2172,14 @@ ./library_output_directory lib WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) + # See ./mysql-test/suite/innodb_fts/include/mecab.inc + IF(MECAB_IPADIC_PARENT) + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E create_symlink + "${MECAB_IPADIC_PARENT}" mecab + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/library_output_directory + ) + ENDIF() ENDIF() # Without any --plugin-dir= the server will look in diff -Nru mysql-8.0-8.0.26/components/audit_api_message_emit/audit_api_message_emit.cc mysql-8.0-8.0.27/components/audit_api_message_emit/audit_api_message_emit.cc --- mysql-8.0-8.0.26/components/audit_api_message_emit/audit_api_message_emit.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/audit_api_message_emit/audit_api_message_emit.cc 2021-09-28 11:46:34.000000000 +0000 @@ -92,8 +92,7 @@ Check, whether the argument is not null pointer. */ static bool not_null(IError_handler &handler, const char *arg, - unsigned long length MY_ATTRIBUTE((unused)), - size_t arg_pos) { + unsigned long length [[maybe_unused]], size_t arg_pos) { if (arg == nullptr) { handler.error("Argument cannot be NULL [%d].", arg_pos); return false; @@ -426,10 +425,10 @@ /** UDF function itself. */ -static char *emit(UDF_INIT *initid MY_ATTRIBUTE((unused)), UDF_ARGS *args, +static char *emit(UDF_INIT *initid [[maybe_unused]], UDF_ARGS *args, char *result, unsigned long *length, - unsigned char *null_value MY_ATTRIBUTE((unused)), - unsigned char *error MY_ATTRIBUTE((unused))) { + unsigned char *null_value [[maybe_unused]], + unsigned char *error [[maybe_unused]]) { /* Store the error as the result of the UDF. */ diff -Nru mysql-8.0-8.0.26/components/keyrings/CMakeLists.txt mysql-8.0-8.0.27/components/keyrings/CMakeLists.txt --- mysql-8.0-8.0.26/components/keyrings/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/keyrings/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -20,6 +20,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +DISABLE_MISSING_PROFILE_WARNING() + ADD_SUBDIRECTORY(common) # Keyring_file component diff -Nru mysql-8.0-8.0.26/components/keyrings/common/CMakeLists.txt mysql-8.0-8.0.27/components/keyrings/common/CMakeLists.txt --- mysql-8.0-8.0.26/components/keyrings/common/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/keyrings/common/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -46,9 +46,14 @@ GenError ) +IF(COMPONENT_COMPILE_VISIBILITY) + SET(COMPILE_OPTIONS_ARG COMPILE_OPTIONS "${COMPONENT_COMPILE_VISIBILITY}") +ENDIF() + ADD_CONVENIENCE_LIBRARY( keyring_common ${KEYRING_COMMON_SOURCES} + ${COMPILE_OPTIONS_ARG} DEPENDENCIES ${KEYRING_COMMON_DEPENDENCIES} LINK_LIBRARIES library_mysys ) diff -Nru mysql-8.0-8.0.26/components/keyrings/common/encryption/aes.cc mysql-8.0-8.0.27/components/keyrings/common/encryption/aes.cc --- mysql-8.0-8.0.26/components/keyrings/common/encryption/aes.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/keyrings/common/encryption/aes.cc 2021-09-28 11:46:34.000000000 +0000 @@ -83,7 +83,7 @@ case Keyring_aes_opmode::keyring_aes_256_ofb: return EVP_aes_256_ofb(); case Keyring_aes_opmode::keyring_aes_opmode_invalid: - // Fall through + [[fallthrough]]; default: return nullptr; } diff -Nru mysql-8.0-8.0.26/components/library_mysys/CMakeLists.txt mysql-8.0-8.0.27/components/library_mysys/CMakeLists.txt --- mysql-8.0-8.0.26/components/library_mysys/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/library_mysys/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -20,6 +20,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +DISABLE_MISSING_PROFILE_WARNING() + ADD_LIBRARY(library_mysys STATIC my_memory.cc my_hex_tools.cc diff -Nru mysql-8.0-8.0.26/components/logging/log_filter_dragnet.cc mysql-8.0-8.0.27/components/logging/log_filter_dragnet.cc --- mysql-8.0-8.0.26/components/logging/log_filter_dragnet.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/logging/log_filter_dragnet.cc 2021-09-28 11:46:34.000000000 +0000 @@ -1438,8 +1438,7 @@ @retval false value OK, go ahead and update system variable (from "save") @retval true value rejected, do not update variable */ -static int check_var_filter_rules(MYSQL_THD thd, - SYS_VAR *self MY_ATTRIBUTE((unused)), +static int check_var_filter_rules(MYSQL_THD thd, SYS_VAR *self [[maybe_unused]], void *save, struct st_mysql_value *value) { int ret; log_filter_ruleset *log_filter_temp_rules; @@ -1507,8 +1506,8 @@ @param var_ptr where to save the resulting (char *) value @param save pointer to the new value (from check function) */ -static void update_var_filter_rules(MYSQL_THD thd MY_ATTRIBUTE((unused)), - SYS_VAR *self MY_ATTRIBUTE((unused)), +static void update_var_filter_rules(MYSQL_THD thd [[maybe_unused]], + SYS_VAR *self [[maybe_unused]], void *var_ptr, const void *save) { const char *state = nullptr; const char *new_val = *(static_cast(const_cast(save))); @@ -1542,7 +1541,7 @@ @returns int Number of matched rules */ DEFINE_METHOD(int, log_service_imp::run, - (void *instance MY_ATTRIBUTE((unused)), log_line *ll)) { + (void *instance [[maybe_unused]], log_line *ll)) { return log_bf->filter_run(log_filter_dragnet_rules, ll); } @@ -1565,7 +1564,7 @@ @returns otherwise A new instance could not be created */ DEFINE_METHOD(log_service_error, log_service_imp::open, - (log_line * ll MY_ATTRIBUTE((unused)), void **instance)) { + (log_line * ll [[maybe_unused]], void **instance)) { if (instance == nullptr) return LOG_SERVICE_INVALID_ARGUMENT; *instance = nullptr; @@ -1610,7 +1609,7 @@ @returns LOG_SERVICE_NOTHING_DONE no work was done */ DEFINE_METHOD(log_service_error, log_service_imp::flush, - (void **instance MY_ATTRIBUTE((unused)))) { + (void **instance [[maybe_unused]])) { return LOG_SERVICE_NOTHING_DONE; } diff -Nru mysql-8.0-8.0.26/components/logging/log_sink_json.cc mysql-8.0-8.0.27/components/logging/log_sink_json.cc --- mysql-8.0-8.0.26/components/logging/log_sink_json.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/logging/log_sink_json.cc 2021-09-28 11:46:34.000000000 +0000 @@ -462,7 +462,7 @@ @retval =0 success, returned hande is valid */ DEFINE_METHOD(log_service_error, log_service_imp::open, - (log_line * ll MY_ATTRIBUTE((unused)), void **instance)) { + (log_line * ll [[maybe_unused]], void **instance)) { log_service_error rr; my_state *mi; char buff[10]; diff -Nru mysql-8.0-8.0.26/components/logging/log_sink_syseventlog.cc mysql-8.0-8.0.27/components/logging/log_sink_syseventlog.cc --- mysql-8.0-8.0.26/components/logging/log_sink_syseventlog.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/logging/log_sink_syseventlog.cc 2021-09-28 11:46:34.000000000 +0000 @@ -417,8 +417,8 @@ @retval false value OK, go ahead and update system variable (from "save") @retval true value rejected, do not update variable */ -static int sysvar_check_tag(MYSQL_THD thd MY_ATTRIBUTE((unused)), - SYS_VAR *self MY_ATTRIBUTE((unused)), void *save, +static int sysvar_check_tag(MYSQL_THD thd [[maybe_unused]], + SYS_VAR *self [[maybe_unused]], void *save, struct st_mysql_value *value) { int value_len = 0; const char *proposed_value; @@ -448,9 +448,9 @@ @param var_ptr where to save the resulting (char *) value @param save pointer to the new value (from check function) */ -static void sysvar_update_tag(MYSQL_THD thd MY_ATTRIBUTE((unused)), - SYS_VAR *self MY_ATTRIBUTE((unused)), - void *var_ptr, const void *save) { +static void sysvar_update_tag(MYSQL_THD thd [[maybe_unused]], + SYS_VAR *self [[maybe_unused]], void *var_ptr, + const void *save) { const char *new_val = *(static_cast(const_cast(save))); var_update_tag(new_val); @@ -549,8 +549,8 @@ @retval false value OK, go ahead and update system variable (from "save") @retval true value rejected, do not update variable */ -static int sysvar_check_fac(MYSQL_THD thd MY_ATTRIBUTE((unused)), - SYS_VAR *self MY_ATTRIBUTE((unused)), void *save, +static int sysvar_check_fac(MYSQL_THD thd [[maybe_unused]], + SYS_VAR *self [[maybe_unused]], void *save, struct st_mysql_value *value) { int value_len = 0; const char *proposed_value; @@ -580,9 +580,9 @@ @param var_ptr where to save the resulting (char *) value @param save pointer to the new value (from check function) */ -static void sysvar_update_fac(MYSQL_THD thd MY_ATTRIBUTE((unused)), - SYS_VAR *self MY_ATTRIBUTE((unused)), - void *var_ptr, const void *save) { +static void sysvar_update_fac(MYSQL_THD thd [[maybe_unused]], + SYS_VAR *self [[maybe_unused]], void *var_ptr, + const void *save) { char *new_val = *(static_cast(const_cast(save))); var_update_fac(new_val); @@ -672,9 +672,9 @@ @param var_ptr where to save the resulting (char *) value @param save pointer to the new value (from check function) */ -static void sysvar_update_pid(MYSQL_THD thd MY_ATTRIBUTE((unused)), - SYS_VAR *self MY_ATTRIBUTE((unused)), - void *var_ptr MY_ATTRIBUTE((unused)), +static void sysvar_update_pid(MYSQL_THD thd [[maybe_unused]], + SYS_VAR *self [[maybe_unused]], + void *var_ptr [[maybe_unused]], const void *save) { var_update_pid(*(static_cast(const_cast(save)))); } @@ -731,7 +731,7 @@ @returns LOG_SERVICE_MISC_ERROR failure not otherwise specified */ DEFINE_METHOD(int, log_service_imp::run, - (void *instance MY_ATTRIBUTE((unused)), log_line *ll)) { + (void *instance [[maybe_unused]], log_line *ll)) { const char *msg = nullptr; int out_fields = 0; enum loglevel level = ERROR_LEVEL; @@ -897,7 +897,7 @@ /* flush logs */ DEFINE_METHOD(log_service_error, log_service_imp::flush, - (void **instance MY_ATTRIBUTE((unused)))) { + (void **instance [[maybe_unused]])) { if (!inited || !log_syslog_enabled) return LOG_SERVICE_NOT_AVAILABLE; log_syslog_reopen(); @@ -912,7 +912,7 @@ @returns otherwise a new instance could not be created */ DEFINE_METHOD(log_service_error, log_service_imp::open, - (log_line * ll MY_ATTRIBUTE((unused)), void **instance)) { + (log_line * ll [[maybe_unused]], void **instance)) { if (instance == nullptr) return LOG_SERVICE_INVALID_ARGUMENT; *instance = nullptr; @@ -926,7 +926,7 @@ @returns LOG_SERVICE_SUCCESS */ DEFINE_METHOD(log_service_error, log_service_imp::close, - (void **instance MY_ATTRIBUTE((unused)))) { + (void **instance [[maybe_unused]])) { return LOG_SERVICE_SUCCESS; } diff -Nru mysql-8.0-8.0.26/components/logging/log_sink_test.cc mysql-8.0-8.0.27/components/logging/log_sink_test.cc --- mysql-8.0-8.0.26/components/logging/log_sink_test.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/logging/log_sink_test.cc 2021-09-28 11:46:34.000000000 +0000 @@ -785,7 +785,7 @@ @returns <0 failure */ DEFINE_METHOD(int, log_service_imp::run, - (void *instance MY_ATTRIBUTE((unused)), log_line *ll)) { + (void *instance [[maybe_unused]], log_line *ll)) { char out_buff[LOG_BUFF_MAX]; char *out_writepos = out_buff; size_t out_left = LOG_BUFF_MAX - 1, // bytes left in output buffer @@ -1077,7 +1077,7 @@ /* flush logs */ DEFINE_METHOD(log_service_error, log_service_imp::flush, - (void **instance MY_ATTRIBUTE((unused)))) { + (void **instance [[maybe_unused]])) { int res; if (inited) log_service_exit(); @@ -1095,7 +1095,7 @@ @retval otherwise a new instance could not be created */ DEFINE_METHOD(log_service_error, log_service_imp::open, - (log_line * ll MY_ATTRIBUTE((unused)), void **instance)) { + (log_line * ll [[maybe_unused]], void **instance)) { if (instance == nullptr) return LOG_SERVICE_INVALID_ARGUMENT; *instance = nullptr; @@ -1110,7 +1110,7 @@ @retval otherwise an error occurred */ DEFINE_METHOD(log_service_error, log_service_imp::close, - (void **instance MY_ATTRIBUTE((unused)))) { + (void **instance [[maybe_unused]])) { return LOG_SERVICE_SUCCESS; } diff -Nru mysql-8.0-8.0.26/components/mysqlbackup/backup_page_tracker.cc mysql-8.0-8.0.27/components/mysqlbackup/backup_page_tracker.cc --- mysql-8.0-8.0.26/components/mysqlbackup/backup_page_tracker.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/mysqlbackup/backup_page_tracker.cc 2021-09-28 11:46:34.000000000 +0000 @@ -192,8 +192,8 @@ /** Callback method for initialization of UDF "mysqlbackup_page_track_set". */ -void Backup_page_tracker::set_page_tracking_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))) {} +void Backup_page_tracker::set_page_tracking_deinit(UDF_INIT *initid + [[maybe_unused]]) {} /** UDF for "mysqlbackup_page_track_set" @@ -245,8 +245,8 @@ Callback method for initialization of UDF "mysqlbackup_page_track_get_start_lsn" */ -void Backup_page_tracker::page_track_get_start_lsn_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))) {} +void Backup_page_tracker::page_track_get_start_lsn_deinit(UDF_INIT *initid + [[maybe_unused]]) {} /** UDF for "mysqlbackup_page_track_get_start_lsn" @@ -290,7 +290,7 @@ "mysqlbackup_page_track_get_changed_page_count". */ void Backup_page_tracker::page_track_get_changed_page_count_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))) {} + UDF_INIT *initid [[maybe_unused]]) {} /** UDF for "mysqlbackup_page_track_get_changed_page_count" @@ -340,8 +340,8 @@ Callback method for initialization of UDF "mysqlbackup_page_track_get_changed_pages". */ -void Backup_page_tracker::page_track_get_changed_pages_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))) { +void Backup_page_tracker::page_track_get_changed_pages_deinit(UDF_INIT *initid [ + [maybe_unused]]) { free(m_changed_pages_buf); m_changed_pages_buf = nullptr; } @@ -436,17 +436,20 @@ @retval 0 success @retval non-zero failure */ -int page_track_callback(MYSQL_THD opaque_thd MY_ATTRIBUTE((unused)), +int page_track_callback(MYSQL_THD opaque_thd [[maybe_unused]], const uchar *buffer, - size_t buffer_length MY_ATTRIBUTE((unused)), - int page_count, void *context MY_ATTRIBUTE((unused))) { + size_t buffer_length [[maybe_unused]], int page_count, + void *context [[maybe_unused]]) { // Append to the disk file in binary mode FILE *fd = fopen(Backup_page_tracker::m_changed_pages_file, "ab"); if (!fd) { + std::string msg{std::string("[page-track] Cannot open '") + + Backup_page_tracker::m_changed_pages_file + + "': " + strerror(errno) + "\n"}; LogEvent() .type(LOG_TYPE_ERROR) .prio(ERROR_LEVEL) - .lookup(ER_MYSQLBACKUP_MSG, "[page-track] File open failed."); + .lookup(ER_MYSQLBACKUP_MSG, msg.c_str()); return (1); } @@ -456,10 +459,13 @@ // write failed if (write_count != data_size) { + std::string msg{std::string("[page-track] Cannot write '") + + Backup_page_tracker::m_changed_pages_file + + "': " + strerror(errno) + "\n"}; LogEvent() .type(LOG_TYPE_ERROR) .prio(ERROR_LEVEL) - .lookup(ER_MYSQLBACKUP_MSG, "[page-track] Writing to file failed."); + .lookup(ER_MYSQLBACKUP_MSG, msg.c_str()); return (1); } diff -Nru mysql-8.0-8.0.26/components/mysqlbackup/backup_page_tracker.h mysql-8.0-8.0.27/components/mysqlbackup/backup_page_tracker.h --- mysql-8.0-8.0.26/components/mysqlbackup/backup_page_tracker.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/mysqlbackup/backup_page_tracker.h 2021-09-28 11:46:34.000000000 +0000 @@ -81,31 +81,31 @@ static mysql_service_status_t unregister_udfs(); static bool set_page_tracking_init(UDF_INIT *initid, UDF_ARGS *, char *); - static void set_page_tracking_deinit(UDF_INIT *initid MY_ATTRIBUTE((unused))); + static void set_page_tracking_deinit(UDF_INIT *initid [[maybe_unused]]); static long long set_page_tracking(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error); static bool page_track_get_changed_pages_init(UDF_INIT *initid, UDF_ARGS *, char *); - static void page_track_get_changed_pages_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))); + static void page_track_get_changed_pages_deinit(UDF_INIT *initid + [[maybe_unused]]); static long long page_track_get_changed_pages(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error); static bool page_track_get_start_lsn_init(UDF_INIT *initid, UDF_ARGS *, char *); - static void page_track_get_start_lsn_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))); + static void page_track_get_start_lsn_deinit(UDF_INIT *initid + [[maybe_unused]]); static long long page_track_get_start_lsn(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, unsigned char *error); static bool page_track_get_changed_page_count_init(UDF_INIT *initid, UDF_ARGS *, char *); - static void page_track_get_changed_page_count_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))); + static void page_track_get_changed_page_count_deinit(UDF_INIT *initid + [[maybe_unused]]); static long long page_track_get_changed_page_count(UDF_INIT *initid, UDF_ARGS *, unsigned char *is_null, diff -Nru mysql-8.0-8.0.26/components/mysqlbackup/mysqlbackup.cc mysql-8.0-8.0.27/components/mysqlbackup/mysqlbackup.cc --- mysql-8.0-8.0.26/components/mysqlbackup/mysqlbackup.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/mysqlbackup/mysqlbackup.cc 2021-09-28 11:46:34.000000000 +0000 @@ -193,7 +193,7 @@ @retval 0 on success, errorno on failure */ static int mysqlbackup_backup_id_check(MYSQL_THD thd, - SYS_VAR *self MY_ATTRIBUTE((unused)), + SYS_VAR *self [[maybe_unused]], void *save, struct st_mysql_value *value) { if (!have_backup_admin_privilege(thd)) @@ -334,11 +334,14 @@ /* If failed before the last initialization succeeded, deinitialize. */ switch (failpoint) { case 3: - unregister_status_variables(); /*FALLTHROUGH*/ + unregister_status_variables(); + [[fallthrough]]; case 2: - unregister_system_variables(); /*FALLTHROUGH*/ + unregister_system_variables(); + [[fallthrough]]; case 1: - deinitialize_log_service(); /*FALLTHROUGH*/ + deinitialize_log_service(); + [[fallthrough]]; case 0: return (1); } diff -Nru mysql-8.0-8.0.26/components/pfs_example/CMakeLists.txt mysql-8.0-8.0.27/components/pfs_example/CMakeLists.txt --- mysql-8.0-8.0.26/components/pfs_example/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/pfs_example/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -20,6 +20,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +DISABLE_MISSING_PROFILE_WARNING() + MYSQL_ADD_COMPONENT(pfs_example pfs_example.cc MODULE_ONLY diff -Nru mysql-8.0-8.0.26/components/query_attributes/query_attributes.cc mysql-8.0-8.0.27/components/query_attributes/query_attributes.cc --- mysql-8.0-8.0.26/components/query_attributes/query_attributes.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/query_attributes/query_attributes.cc 2021-09-28 11:46:34.000000000 +0000 @@ -48,10 +48,12 @@ static PSI_memory_key KEY_memory; -static char *mysql_query_attribute_string( - UDF_INIT *initid, UDF_ARGS *args, char *result MY_ATTRIBUTE((unused)), - unsigned long *length, unsigned char *is_null, - unsigned char *error MY_ATTRIBUTE((unused))) { +static char *mysql_query_attribute_string(UDF_INIT *initid, UDF_ARGS *args, + char *result [[maybe_unused]], + unsigned long *length, + unsigned char *is_null, + unsigned char *error + [[maybe_unused]]) { const char *name = args->args[0]; mysqlh_query_attributes_iterator iter = nullptr; char *ret = nullptr; @@ -120,8 +122,8 @@ return false; } -static void mysql_query_attribute_string_deinit( - UDF_INIT *initid MY_ATTRIBUTE((unused))) { +static void mysql_query_attribute_string_deinit(UDF_INIT *initid + [[maybe_unused]]) { if (initid->ptr) my_free(initid->ptr); } diff -Nru mysql-8.0-8.0.26/components/test/keyring_encryption_test/CMakeLists.txt mysql-8.0-8.0.27/components/test/keyring_encryption_test/CMakeLists.txt --- mysql-8.0-8.0.26/components/test/keyring_encryption_test/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/test/keyring_encryption_test/CMakeLists.txt 2021-09-28 11:46:34.000000000 +0000 @@ -21,6 +21,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ADD_WSHADOW_WARNING() +DISABLE_MISSING_PROFILE_WARNING() SET(KEYRING_ENCRYPTION_TEST_SOURCE # Options diff -Nru mysql-8.0-8.0.26/components/test/keyring_encryption_test/options.cc mysql-8.0-8.0.27/components/test/keyring_encryption_test/options.cc --- mysql-8.0-8.0.26/components/test/keyring_encryption_test/options.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/test/keyring_encryption_test/options.cc 2021-09-28 11:46:34.000000000 +0000 @@ -91,7 +91,7 @@ usage(true); break; case 'I': - // Fall through + [[fallthrough]]; case '?': usage(false); break; diff -Nru mysql-8.0-8.0.26/components/test/test_audit_api_message.cc mysql-8.0-8.0.27/components/test/test_audit_api_message.cc --- mysql-8.0-8.0.26/components/test/test_audit_api_message.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/test/test_audit_api_message.cc 2021-09-28 11:46:34.000000000 +0000 @@ -53,11 +53,10 @@ @retval 0 This function always returns 0. */ -static long long message_internal(UDF_INIT *init MY_ATTRIBUTE((unused)), - UDF_ARGS *args MY_ATTRIBUTE((unused)), - unsigned char *null_value - MY_ATTRIBUTE((unused)), - unsigned char *error MY_ATTRIBUTE((unused))) { +static long long message_internal(UDF_INIT *init [[maybe_unused]], + UDF_ARGS *args [[maybe_unused]], + unsigned char *null_value [[maybe_unused]], + unsigned char *error [[maybe_unused]]) { mysql_event_message_key_value_t val; lex_cstring_set(&val.key, "my_numeric_key"); @@ -83,10 +82,10 @@ @retval 0 This function always returns 0. */ -static long long message_user(UDF_INIT *init MY_ATTRIBUTE((unused)), - UDF_ARGS *args MY_ATTRIBUTE((unused)), - unsigned char *null_value MY_ATTRIBUTE((unused)), - unsigned char *error MY_ATTRIBUTE((unused))) { +static long long message_user(UDF_INIT *init [[maybe_unused]], + UDF_ARGS *args [[maybe_unused]], + unsigned char *null_value [[maybe_unused]], + unsigned char *error [[maybe_unused]]) { mysql_event_message_key_value_t val; lex_cstring_set(&val.key, "my_string_key"); diff -Nru mysql-8.0-8.0.26/components/test/test_udf_registration.cc mysql-8.0-8.0.27/components/test/test_udf_registration.cc --- mysql-8.0-8.0.26/components/test/test_udf_registration.cc 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/components/test/test_udf_registration.cc 2021-09-28 11:46:34.000000000 +0000 @@ -105,7 +105,7 @@ return false; } -static void dynamic_udf_deinit(UDF_INIT *initid MY_ATTRIBUTE((unused))) { +static void dynamic_udf_deinit(UDF_INIT *initid [[maybe_unused]]) { assert(initid->ptr == test_init || initid->ptr == test_udf); } @@ -120,7 +120,7 @@ return 42; } -static void dynamic_agg_deinit(UDF_INIT *initid MY_ATTRIBUTE((unused))) { +static void dynamic_agg_deinit(UDF_INIT *initid [[maybe_unused]]) { assert(initid->ptr == test_init || initid->ptr == test_udf || initid->ptr == test_udf_clear || initid->ptr == test_udf_add); } diff -Nru mysql-8.0-8.0.26/config.h.cmake mysql-8.0-8.0.27/config.h.cmake --- mysql-8.0-8.0.26/config.h.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/config.h.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -104,6 +104,9 @@ #cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 #cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1 #cmakedefine HAVE_PTHREAD_SIGMASK 1 +#cmakedefine HAVE_PTHREAD_SETNAME_NP_LINUX 1 +#cmakedefine HAVE_PTHREAD_SETNAME_NP_MACOS 1 +#cmakedefine HAVE_SET_THREAD_DESCRIPTION 1 #cmakedefine HAVE_SLEEP 1 #cmakedefine HAVE_STPCPY 1 #cmakedefine HAVE_STPNCPY 1 @@ -194,6 +197,7 @@ #define SYSTEM_TYPE "@SYSTEM_TYPE@" /* This should mean case insensitive file system */ #cmakedefine FN_NO_CASE_SENSE 1 +#cmakedefine APPLE_ARM 1 /* * From main CMakeLists.txt @@ -212,6 +216,7 @@ #cmakedefine KERBEROS_LIB_CONFIGURED #cmakedefine SCRAM_LIB_CONFIGURED #cmakedefine WITH_HYPERGRAPH_OPTIMIZER +#cmakedefine KERBEROS_LIB_SSPI /* Lock Order */ #cmakedefine WITH_LOCK_ORDER 1 diff -Nru mysql-8.0-8.0.26/configure.cmake mysql-8.0-8.0.27/configure.cmake --- mysql-8.0-8.0.26/configure.cmake 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/configure.cmake 2021-09-28 11:46:34.000000000 +0000 @@ -615,6 +615,28 @@ FAIL_REGEX "warning: incompatible pointer to integer conversion" ) +# Check for pthread_setname_np() on linux +CHECK_C_SOURCE_COMPILES(" +#define _GNU_SOURCE +#include +int main(int argc, char **argv) +{ + pthread_t tid = 0; + const char *name = NULL; + return pthread_setname_np(tid, name); +}" +HAVE_PTHREAD_SETNAME_NP_LINUX) + +# Check for pthread_setname_np() on macos +CHECK_C_SOURCE_COMPILES(" +#include +int main(int argc, char **argv) +{ + char name[16] = {0}; + return pthread_setname_np(name); +}" +HAVE_PTHREAD_SETNAME_NP_MACOS) + #-------------------------------------------------------------------- # Check for IPv6 support #-------------------------------------------------------------------- diff -Nru mysql-8.0-8.0.26/debian/changelog mysql-8.0-8.0.27/debian/changelog --- mysql-8.0-8.0.26/debian/changelog 2021-07-22 11:53:03.000000000 +0000 +++ mysql-8.0-8.0.27/debian/changelog 2021-10-22 14:51:26.000000000 +0000 @@ -1,3 +1,24 @@ +mysql-8.0 (8.0.27-0ubuntu0.21.04.1) hirsute-security; urgency=medium + + * SECURITY UPDATE: Update to 8.0.27 to fix security issues + - CVE-2021-2478, CVE-2021-2479, CVE-2021-2481, CVE-2021-35546, + CVE-2021-35575, CVE-2021-35577, CVE-2021-35584, CVE-2021-35591, + CVE-2021-35596, CVE-2021-35597, CVE-2021-35602, CVE-2021-35604, + CVE-2021-35607, CVE-2021-35608, CVE-2021-35610, CVE-2021-35612, + CVE-2021-35613, CVE-2021-35622, CVE-2021-35623, CVE-2021-35624, + CVE-2021-35625, CVE-2021-35626, CVE-2021-35627, CVE-2021-35628, + CVE-2021-35630, CVE-2021-35631, CVE-2021-35632, CVE-2021-35633, + CVE-2021-35634, CVE-2021-35635, CVE-2021-35636, CVE-2021-35637, + CVE-2021-35638, CVE-2021-35639, CVE-2021-35640, CVE-2021-35641, + CVE-2021-35642, CVE-2021-35643, CVE-2021-35644, CVE-2021-35645, + CVE-2021-35646, CVE-2021-35647, CVE-2021-35648 + * debian/rules: disable innodb_fts.mecab_utf8 test, it hasn't run + successfully in a long time, but now gives an error. + * debian/patches/fix_ppc64el_longdouble_ftbfs.patch: removed, no longer + needed. + + -- Marc Deslauriers Fri, 22 Oct 2021 10:51:26 -0400 + mysql-8.0 (8.0.26-0ubuntu0.21.04.3) hirsute-security; urgency=medium * SECURITY UPDATE: Update to 8.0.26 to fix security issues diff -Nru mysql-8.0-8.0.26/debian/patches/fix_ppc64el_longdouble_ftbfs.patch mysql-8.0-8.0.27/debian/patches/fix_ppc64el_longdouble_ftbfs.patch --- mysql-8.0-8.0.26/debian/patches/fix_ppc64el_longdouble_ftbfs.patch 2021-07-22 11:53:03.000000000 +0000 +++ mysql-8.0-8.0.27/debian/patches/fix_ppc64el_longdouble_ftbfs.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -Description: disable long double test on ppc64el causing FTBFS until a - proper fix is found. -Author: Marc Deslauriers - ---- a/unittest/gunit/innodb/ut0new-t.cc -+++ b/unittest/gunit/innodb/ut0new-t.cc -@@ -39,7 +39,11 @@ using int_types = - - using char_types = ::testing::Types; - -+#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT -+using floating_point_types = ::testing::Types; -+#else - using floating_point_types = ::testing::Types; -+#endif - - /** - * This is a typed test template, it's instantiated below for all primitive diff -Nru mysql-8.0-8.0.26/debian/patches/revert_faster_tls_model.patch mysql-8.0-8.0.27/debian/patches/revert_faster_tls_model.patch --- mysql-8.0-8.0.26/debian/patches/revert_faster_tls_model.patch 2021-03-13 02:11:54.000000000 +0000 +++ mysql-8.0-8.0.27/debian/patches/revert_faster_tls_model.patch 2021-10-22 14:50:16.000000000 +0000 @@ -2,11 +2,12 @@ Author: Marc Deslauriers Forwarded: No, not needed Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1889851 +Updated: 2021-10-21 --- a/cmake/build_configurations/compiler_options.cmake +++ b/cmake/build_configurations/compiler_options.cmake -@@ -71,12 +71,6 @@ IF(UNIX) - SET(COMMON_CXX_FLAGS "-std=c++14 -fno-omit-frame-pointer") +@@ -64,12 +64,6 @@ IF(UNIX) + SET(COMMON_CXX_FLAGS "-std=c++17 -fno-omit-frame-pointer") ENDIF() - # Faster TLS model @@ -15,6 +16,6 @@ - STRING_APPEND(COMMON_CXX_FLAGS " -ftls-model=initial-exec") - ENDIF() - - # Solaris flags - IF(SOLARIS) - # Link mysqld with mtmalloc on Solaris 10 and later + # Use STRING_PREPEND here, so command-line input can override our defaults. + STRING_PREPEND(CMAKE_C_FLAGS "${COMMON_C_FLAGS} ") + STRING_PREPEND(CMAKE_C_FLAGS_RELWITHDEBINFO "${SECTIONS_FLAG} ") diff -Nru mysql-8.0-8.0.26/debian/patches/series mysql-8.0-8.0.27/debian/patches/series --- mysql-8.0-8.0.26/debian/patches/series 2021-07-22 11:53:03.000000000 +0000 +++ mysql-8.0-8.0.27/debian/patches/series 2021-10-22 14:50:40.000000000 +0000 @@ -6,4 +6,3 @@ revert_faster_tls_model.patch fix_path_mysql_keyring_encryption_test.patch disable_root_files.patch -fix_ppc64el_longdouble_ftbfs.patch diff -Nru mysql-8.0-8.0.26/debian/rules mysql-8.0-8.0.27/debian/rules --- mysql-8.0-8.0.26/debian/rules 2021-07-22 11:53:03.000000000 +0000 +++ mysql-8.0-8.0.27/debian/rules 2021-10-22 14:51:06.000000000 +0000 @@ -160,7 +160,6 @@ # Skip replication tests since they are timing sensitive and may # result in false positives. cd $(builddir)/mysql-test && ./mtr --report-unstable-tests --parallel=$(TESTJOBS) --skip-rpl $(MTR_SUITE) --force --skip-test-list=./skiplist || $(TESTSUITE_FAIL_CMD) ; - cd $(builddir)/mysql-test && ./mtr --report-unstable-tests --force innodb_fts.mecab_utf8 endif endif diff -Nru mysql-8.0-8.0.26/Docs/INFO_SRC mysql-8.0-8.0.27/Docs/INFO_SRC --- mysql-8.0-8.0.26/Docs/INFO_SRC 2021-07-01 08:13:51.000000000 +0000 +++ mysql-8.0-8.0.27/Docs/INFO_SRC 2021-09-28 13:19:38.000000000 +0000 @@ -1,7 +1,7 @@ -commit: f64af5bfff4c3a65eb44d9e513ca1c882850b030 -date: 2021-07-01 07:17:38 +0200 -build-date: 2021-07-01 07:54:49 +0000 -short: f64af5bfff4 -branch: mysql-8.0.26-release +commit: 5c5b83a19a7ee94f7418d6e4fbb37da4b63d5d96 +date: 2021-09-28 13:36:27 +0200 +build-date: 2021-09-28 11:47:35 +0000 +short: 5c5b83a19a7 +branch: mysql-8.0.27-release -MySQL source 8.0.26 +MySQL source 8.0.27 diff -Nru mysql-8.0-8.0.26/Docs/README.build mysql-8.0-8.0.27/Docs/README.build --- mysql-8.0-8.0.26/Docs/README.build 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/Docs/README.build 2021-09-28 11:46:34.000000000 +0000 @@ -67,15 +67,21 @@ It is possible to compile with Clang on Windows, which compiles faster and also yields faster binaries, but this is experimental and not officially -supported. To compile, use LLVM 6.0.1 or newer from releases.llvm.org -(Clang/C2, which is Microsoft's own version of Clang, is not supported), -and put a Windows compile of Ninja in your path. Then execute the following -in a shell: - - "c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - set PATH=;%PATH% - "c:\Program Files\CMake 3.8\bin\cmake.exe" -G Ninja -DCMAKE_C_COMPILER="c:/program files/llvm/msbuild-bin/cl.exe" -DCMAKE_CXX_COMPILER="c:/program files/llvm/msbuild-bin/cl.exe" -DCMAKE_LINKER="c:/program files/llvm/bin/lld-link.exe" -DWITH_BOOST= .. - ninja +supported. To compile, install the most recent version from +https://github.com/llvm/llvm-project/releases +(Clang/C2, which is Microsoft's own version of Clang, is not supported) + +Ensure that you have ninja and cmake in your path. +Source the appropriate vcvarsall.bat file which comes with Visual Studio, +so that Visual Studio executables are in your PATH. + +cmake -G Ninja -DFORCE_UNSUPPORTED_COMPILER=1 + -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" + -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" + -DCMAKE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe" + -DWITH_BOOST= .. + +ninja This configuration also supports ASAN (-DWITH_ASAN=1), although currently only when linking with MSVC's linker (not with LLD). @@ -85,9 +91,4 @@ === -Note: For building with unit tests, you need to tell cmake where to find -the sources, see ../cmake/googletest.cmake -You should *not* 'make install' googletest/googlemock on your system, -the libraries must be built from source, with the unit tests. - Note: You need to tell cmake where to find boost, see ../cmake/boost.cmake diff -Nru mysql-8.0-8.0.26/Doxyfile-ignored mysql-8.0-8.0.27/Doxyfile-ignored --- mysql-8.0-8.0.26/Doxyfile-ignored 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/Doxyfile-ignored 2021-09-28 11:46:34.000000000 +0000 @@ -64,6 +64,7 @@ sql/rpl_handler.h:* sql/rpl_io_monitor.h:* sql/rpl_rli_pdb.h:* +sql/rpl_info_dummy.cc:* sql/rpl_trx_tracking.h:* sql/rpl_utility.h:* libbinlogevents/include/binlog_event.h:* @@ -73,7 +74,7 @@ # BUG#32245629 - FIX DOXYGEN WARNINGS IN THE OPTIMIZER CODE # 07-DEC-2020 Erlend Dahl sql/join_optimizer/join_optimizer.cc:* -sql/opt_range.cc:* +sql/range_optimizer/range_optimizer.cc:* sql/protocol_callback.h:* sql/protocol_classic.cc:* sql/spatial.cc:* diff -Nru mysql-8.0-8.0.26/Doxyfile.in mysql-8.0-8.0.27/Doxyfile.in --- mysql-8.0-8.0.26/Doxyfile.in 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/Doxyfile.in 2021-09-28 11:46:34.000000000 +0000 @@ -2278,6 +2278,7 @@ # This tag requires that the tag SEARCH_INCLUDES is set to YES. INCLUDE_PATH = . \ + client/include \ include \ include/mysql \ sql @@ -2324,7 +2325,8 @@ ALWAYS_INLINE(X)=X \ UNIV_DEBUG \ UNIV_NOTHROW \ - __cplusplus + __cplusplus \ + DOXYGEN_IF_DEBUG # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The @@ -2348,7 +2350,8 @@ DEFINE_METHOD \ DEFINE_BOOL_METHOD \ DECLARE_METHOD \ - DECLARE_BOOL_METHOD + DECLARE_BOOL_METHOD \ + IF_DEBUG # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/appveyor.yml mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/appveyor.yml --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/appveyor.yml 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/appveyor.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ -version: '{build}' - -os: Visual Studio 2015 - -environment: - matrix: - - compiler: msvc-15-seh - generator: "Visual Studio 15 2017" - build_system: cmake - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - - compiler: msvc-15-seh - generator: "Visual Studio 15 2017 Win64" - build_system: cmake - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - enabled_on_pr: yes - - - compiler: msvc-15-seh - build_system: bazel - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - enabled_on_pr: yes - - - compiler: msvc-14-seh - build_system: cmake - generator: "Visual Studio 14 2015" - enabled_on_pr: yes - - - compiler: msvc-14-seh - build_system: cmake - generator: "Visual Studio 14 2015 Win64" - - - compiler: gcc-6.3.0-posix - build_system: cmake - generator: "MinGW Makefiles" - cxx_path: 'C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin' - enabled_on_pr: yes - -configuration: - - Debug - -build: - verbosity: minimal - -install: -- ps: | - Write-Output "Compiler: $env:compiler" - Write-Output "Generator: $env:generator" - Write-Output "Env:Configuation: $env:configuration" - Write-Output "Env: $env" - if (-not (Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER)) { - Write-Output "This is *NOT* a pull request build" - } else { - Write-Output "This is a pull request build" - if (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes") { - Write-Output "PR builds are *NOT* explicitly enabled" - } - } - - # install Bazel - if ($env:build_system -eq "bazel") { - appveyor DownloadFile https://github.com/bazelbuild/bazel/releases/download/0.28.1/bazel-0.28.1-windows-x86_64.exe -FileName bazel.exe - } - - if ($env:build_system -eq "cmake") { - # git bash conflicts with MinGW makefiles - if ($env:generator -eq "MinGW Makefiles") { - $env:path = $env:path.replace("C:\Program Files\Git\usr\bin;", "") - if ($env:cxx_path -ne "") { - $env:path += ";$env:cxx_path" - } - } - } - -before_build: -- ps: | - $env:root=$env:APPVEYOR_BUILD_FOLDER - Write-Output "env:root: $env:root" - -build_script: -- ps: | - # Only enable some builds for pull requests, the AppVeyor queue is too long. - if ((Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER) -And (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes")) { - return - } else { - # special case - build with Bazel - if ($env:build_system -eq "bazel") { - & $env:root\bazel.exe build -c opt //:gtest_samples - if ($LastExitCode -eq 0) { # bazel writes to StdErr and PowerShell interprets it as an error - $host.SetShouldExit(0) - } else { # a real error - throw "Exec: $ErrorMessage" - } - return - } - } - # by default build with CMake - md _build -Force | Out-Null - cd _build - - $conf = if ($env:generator -eq "MinGW Makefiles") {"-DCMAKE_BUILD_TYPE=$env:configuration"} else {"-DCMAKE_CONFIGURATION_TYPES=Debug;Release"} - # Disable test for MinGW (gtest tests fail, gmock tests can not build) - $gtest_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgtest_build_tests=OFF"} else {"-Dgtest_build_tests=ON"} - $gmock_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgmock_build_tests=OFF"} else {"-Dgmock_build_tests=ON"} - & cmake -G "$env:generator" $conf -Dgtest_build_samples=ON $gtest_build_tests $gmock_build_tests .. - if ($LastExitCode -ne 0) { - throw "Exec: $ErrorMessage" - } - $cmake_parallel = if ($env:generator -eq "MinGW Makefiles") {"-j2"} else {"/m"} - & cmake --build . --config $env:configuration -- $cmake_parallel - if ($LastExitCode -ne 0) { - throw "Exec: $ErrorMessage" - } - - -skip_commits: - files: - - '**/*.md' - -test_script: -- ps: | - # Only enable some builds for pull requests, the AppVeyor queue is too long. - if ((Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER) -And (-not (Test-Path env:enabled_on_pr) -or $env:enabled_on_pr -ne "yes")) { - return - } - if ($env:build_system -eq "bazel") { - # special case - testing with Bazel - & $env:root\bazel.exe test //:gtest_samples - if ($LastExitCode -eq 0) { # bazel writes to StdErr and PowerShell interprets it as an error - $host.SetShouldExit(0) - } else { # a real error - throw "Exec: $ErrorMessage" - } - } - if ($env:build_system -eq "cmake") { - # built with CMake - test with CTest - if ($env:generator -eq "MinGW Makefiles") { - return # No test available for MinGW - } - - & ctest -C $env:configuration --timeout 600 --output-on-failure - if ($LastExitCode -ne 0) { - throw "Exec: $ErrorMessage" - } - } - -artifacts: - - path: '_build/CMakeFiles/*.log' - name: logs - - path: '_build/Testing/**/*.xml' - name: test_results - - path: 'bazel-testlogs/**/test.log' - name: test_logs - - path: 'bazel-testlogs/**/test.xml' - name: test_results diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/BUILD.bazel mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/BUILD.bazel --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/BUILD.bazel 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -# Copyright 2017 Google Inc. -# All Rights Reserved. -# -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# Bazel Build for Google C++ Testing Framework(Google Test) - -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -config_setting( - name = "windows", - constraint_values = ["@bazel_tools//platforms:windows"], -) - -config_setting( - name = "has_absl", - values = {"define": "absl=1"}, -) - -# Library that defines the FRIEND_TEST macro. -cc_library( - name = "gtest_prod", - hdrs = ["googletest/include/gtest/gtest_prod.h"], - includes = ["googletest/include"], -) - -# Google Test including Google Mock -cc_library( - name = "gtest", - srcs = glob( - include = [ - "googletest/src/*.cc", - "googletest/src/*.h", - "googletest/include/gtest/**/*.h", - "googlemock/src/*.cc", - "googlemock/include/gmock/**/*.h", - ], - exclude = [ - "googletest/src/gtest-all.cc", - "googletest/src/gtest_main.cc", - "googlemock/src/gmock-all.cc", - "googlemock/src/gmock_main.cc", - ], - ), - hdrs = glob([ - "googletest/include/gtest/*.h", - "googlemock/include/gmock/*.h", - ]), - copts = select({ - ":windows": [], - "//conditions:default": ["-pthread"], - }), - defines = select({ - ":has_absl": ["GTEST_HAS_ABSL=1"], - "//conditions:default": [], - }), - features = select({ - ":windows": ["windows_export_all_symbols"], - "//conditions:default": [], - }), - includes = [ - "googlemock", - "googlemock/include", - "googletest", - "googletest/include", - ], - linkopts = select({ - ":windows": [], - "//conditions:default": ["-pthread"], - }), - deps = select({ - ":has_absl": [ - "@com_google_absl//absl/debugging:failure_signal_handler", - "@com_google_absl//absl/debugging:stacktrace", - "@com_google_absl//absl/debugging:symbolize", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:optional", - "@com_google_absl//absl/types:variant", - ], - "//conditions:default": [], - }), -) - -cc_library( - name = "gtest_main", - srcs = ["googlemock/src/gmock_main.cc"], - features = select({ - ":windows": ["windows_export_all_symbols"], - "//conditions:default": [], - }), - deps = [":gtest"], -) - -# The following rules build samples of how to use gTest. -cc_library( - name = "gtest_sample_lib", - srcs = [ - "googletest/samples/sample1.cc", - "googletest/samples/sample2.cc", - "googletest/samples/sample4.cc", - ], - hdrs = [ - "googletest/samples/prime_tables.h", - "googletest/samples/sample1.h", - "googletest/samples/sample2.h", - "googletest/samples/sample3-inl.h", - "googletest/samples/sample4.h", - ], - features = select({ - ":windows": ["windows_export_all_symbols"], - "//conditions:default": [], - }), -) - -cc_test( - name = "gtest_samples", - size = "small", - # All Samples except: - # sample9 (main) - # sample10 (main and takes a command line option and needs to be separate) - srcs = [ - "googletest/samples/sample1_unittest.cc", - "googletest/samples/sample2_unittest.cc", - "googletest/samples/sample3_unittest.cc", - "googletest/samples/sample4_unittest.cc", - "googletest/samples/sample5_unittest.cc", - "googletest/samples/sample6_unittest.cc", - "googletest/samples/sample7_unittest.cc", - "googletest/samples/sample8_unittest.cc", - ], - linkstatic = 0, - deps = [ - "gtest_sample_lib", - ":gtest_main", - ], -) - -cc_test( - name = "sample9_unittest", - size = "small", - srcs = ["googletest/samples/sample9_unittest.cc"], - deps = [":gtest"], -) - -cc_test( - name = "sample10_unittest", - size = "small", - srcs = ["googletest/samples/sample10_unittest.cc"], - deps = [":gtest"], -) diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/.clang-format mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/.clang-format --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/.clang-format 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/.clang-format 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -# Run manually to reformat a file: -# clang-format -i --style=file -Language: Cpp -BasedOnStyle: Google diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/CMakeLists.txt mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/CMakeLists.txt --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -# Note: CMake support is community-based. The maintainers do not use CMake -# internally. - -cmake_minimum_required(VERSION 2.8.8) - -if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) -endif (POLICY CMP0048) - -project(googletest-distribution) -set(GOOGLETEST_VERSION 1.10.0) - -if (CMAKE_VERSION VERSION_LESS "3.1") - add_definitions(-std=c++11) -else() - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - if(NOT CYGWIN) - set(CMAKE_CXX_EXTENSIONS OFF) - endif() -endif() - -enable_testing() - -include(CMakeDependentOption) -include(GNUInstallDirs) - -#Note that googlemock target already builds googletest -option(BUILD_GMOCK "Builds the googlemock subproject" ON) -option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) - -if(BUILD_GMOCK) - add_subdirectory( googlemock ) -else() - add_subdirectory( googletest ) -endif() diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/CONTRIBUTING.md mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/CONTRIBUTING.md --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/CONTRIBUTING.md 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/CONTRIBUTING.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -# How to become a contributor and submit your own code - -## Contributor License Agreements - -We'd love to accept your patches! Before we can take them, we have to jump a -couple of legal hurdles. - -Please fill out either the individual or corporate Contributor License Agreement -(CLA). - -* If you are an individual writing original source code and you're sure you - own the intellectual property, then you'll need to sign an - [individual CLA](https://developers.google.com/open-source/cla/individual). -* If you work for a company that wants to allow you to contribute your work, - then you'll need to sign a - [corporate CLA](https://developers.google.com/open-source/cla/corporate). - -Follow either of the two links above to access the appropriate CLA and -instructions for how to sign and return it. Once we receive it, we'll be able to -accept your pull requests. - -## Are you a Googler? - -If you are a Googler, please make an attempt to submit an internal change rather -than a GitHub Pull Request. If you are not able to submit an internal change a -PR is acceptable as an alternative. - -## Contributing A Patch - -1. Submit an issue describing your proposed change to the - [issue tracker](https://github.com/google/googletest). -2. Please don't mix more than one logical change per submittal, because it - makes the history hard to follow. If you want to make a change that doesn't - have a corresponding issue in the issue tracker, please create one. -3. Also, coordinate with team members that are listed on the issue in question. - This ensures that work isn't being duplicated and communicating your plan - early also generally leads to better patches. -4. If your proposed change is accepted, and you haven't already done so, sign a - Contributor License Agreement (see details above). -5. Fork the desired repo, develop and test your code changes. -6. Ensure that your code adheres to the existing style in the sample to which - you are contributing. -7. Ensure that your code has an appropriate set of unit tests which all pass. -8. Submit a pull request. - -## The Google Test and Google Mock Communities - -The Google Test community exists primarily through the -[discussion group](http://groups.google.com/group/googletestframework) and the -GitHub repository. Likewise, the Google Mock community exists primarily through -their own [discussion group](http://groups.google.com/group/googlemock). You are -definitely encouraged to contribute to the discussion and you can also help us -to keep the effectiveness of the group high by following and promoting the -guidelines listed here. - -### Please Be Friendly - -Showing courtesy and respect to others is a vital part of the Google culture, -and we strongly encourage everyone participating in Google Test development to -join us in accepting nothing less. Of course, being courteous is not the same as -failing to constructively disagree with each other, but it does mean that we -should be respectful of each other when enumerating the 42 technical reasons -that a particular proposal may not be the best choice. There's never a reason to -be antagonistic or dismissive toward anyone who is sincerely trying to -contribute to a discussion. - -Sure, C++ testing is serious business and all that, but it's also a lot of fun. -Let's keep it that way. Let's strive to be one of the friendliest communities in -all of open source. - -As always, discuss Google Test in the official GoogleTest discussion group. You -don't have to actually submit code in order to sign up. Your participation -itself is a valuable contribution. - -## Style - -To keep the source consistent, readable, diffable and easy to merge, we use a -fairly rigid coding style, as defined by the -[google-styleguide](https://github.com/google/styleguide) project. All patches -will be expected to conform to the style outlined -[here](https://google.github.io/styleguide/cppguide.html). Use -[.clang-format](https://github.com/google/googletest/blob/master/.clang-format) -to check your formatting - -## Requirements for Contributors - -If you plan to contribute a patch, you need to build Google Test, Google Mock, -and their own tests from a git checkout, which has further requirements: - -* [Python](https://www.python.org/) v2.3 or newer (for running some of the - tests and re-generating certain source files from templates) -* [CMake](https://cmake.org/) v2.6.4 or newer - -## Developing Google Test and Google Mock - -This section discusses how to make your own changes to the Google Test project. - -### Testing Google Test and Google Mock Themselves - -To make sure your changes work as intended and don't break existing -functionality, you'll want to compile and run Google Test and GoogleMock's own -tests. For that you can use CMake: - - mkdir mybuild - cd mybuild - cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR} - -To choose between building only Google Test or Google Mock, you may modify your -cmake command to be one of each - - cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests - cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests - -Make sure you have Python installed, as some of Google Test's tests are written -in Python. If the cmake command complains about not being able to find Python -(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it -explicitly where your Python executable can be found: - - cmake -DPYTHON_EXECUTABLE=path/to/python ... - -Next, you can build Google Test and / or Google Mock and all desired tests. On -\*nix, this is usually done by - - make - -To run the tests, do - - make test - -All tests should pass. - -### Regenerating Source Files - -Some of Google Test's source files are generated from templates (not in the C++ -sense) using a script. For example, the file -include/gtest/internal/gtest-type-util.h.pump is used to generate -gtest-type-util.h in the same directory. - -You don't need to worry about regenerating the source files unless you need to -modify them. You would then modify the corresponding `.pump` files and run the -'[pump.py](googletest/scripts/pump.py)' generator script. See the -[Pump Manual](googletest/docs/pump_manual.md). diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/CMakeLists.txt mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/CMakeLists.txt --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/CMakeLists.txt 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,233 +0,0 @@ -######################################################################## -# Note: CMake support is community-based. The maintainers do not use CMake -# internally. -# -# CMake build script for Google Mock. -# -# To run the tests for Google Mock itself on Linux, use 'make test' or -# ctest. You can select which tests to run using 'ctest -R regex'. -# For more options, run 'ctest --help'. - -option(gmock_build_tests "Build all of Google Mock's own tests." OFF) - -# A directory to find Google Test sources. -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt") - set(gtest_dir gtest) -else() - set(gtest_dir ../googletest) -endif() - -# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build(). -include("${gtest_dir}/cmake/hermetic_build.cmake" OPTIONAL) - -if (COMMAND pre_project_set_up_hermetic_build) - # Google Test also calls hermetic setup functions from add_subdirectory, - # although its changes will not affect things at the current scope. - pre_project_set_up_hermetic_build() -endif() - -######################################################################## -# -# Project-wide settings - -# Name of the project. -# -# CMake files in this project can refer to the root source directory -# as ${gmock_SOURCE_DIR} and to the root binary directory as -# ${gmock_BINARY_DIR}. -# Language "C" is required for find_package(Threads). -if (CMAKE_VERSION VERSION_LESS 3.0) - project(gmock CXX C) -else() - cmake_policy(SET CMP0048 NEW) - project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C) -endif() -cmake_minimum_required(VERSION 2.6.4) - -if (COMMAND set_up_hermetic_build) - set_up_hermetic_build() -endif() - -# Instructs CMake to process Google Test's CMakeLists.txt and add its -# targets to the current scope. We are placing Google Test's binary -# directory in a subdirectory of our own as VC compilation may break -# if they are the same (the default). -add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/${gtest_dir}") - - -# These commands only run if this is the main project -if(CMAKE_PROJECT_NAME STREQUAL "gmock" OR CMAKE_PROJECT_NAME STREQUAL "googletest-distribution") - # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to - # make it prominent in the GUI. - option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) -else() - mark_as_advanced(gmock_build_tests) -endif() - -# Although Google Test's CMakeLists.txt calls this function, the -# changes there don't affect the current scope. Therefore we have to -# call it again here. -config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake - -# Adds Google Mock's and Google Test's header directories to the search path. -set(gmock_build_include_dirs - "${gmock_SOURCE_DIR}/include" - "${gmock_SOURCE_DIR}" - "${gtest_SOURCE_DIR}/include" - # This directory is needed to build directly from Google Test sources. - "${gtest_SOURCE_DIR}") -include_directories(${gmock_build_include_dirs}) - -######################################################################## -# -# Defines the gmock & gmock_main libraries. User tests should link -# with one of them. - -# Google Mock libraries. We build them using more strict warnings than what -# are used for other targets, to ensure that Google Mock can be compiled by -# a user aggressive about warnings. -if (MSVC) - cxx_library(gmock - "${cxx_strict}" - "${gtest_dir}/src/gtest-all.cc" - src/gmock-all.cc) - - cxx_library(gmock_main - "${cxx_strict}" - "${gtest_dir}/src/gtest-all.cc" - src/gmock-all.cc - src/gmock_main.cc) -else() - cxx_library(gmock "${cxx_strict}" src/gmock-all.cc) - target_link_libraries(gmock PUBLIC gtest) - cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc) - target_link_libraries(gmock_main PUBLIC gmock) -endif() -# If the CMake version supports it, attach header directory information -# to the targets for when we are part of a parent build (ie being pulled -# in via add_subdirectory() rather than being a standalone build). -if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11") - target_include_directories(gmock SYSTEM INTERFACE - "$" - "$/${CMAKE_INSTALL_INCLUDEDIR}>") - target_include_directories(gmock_main SYSTEM INTERFACE - "$" - "$/${CMAKE_INSTALL_INCLUDEDIR}>") -endif() - -######################################################################## -# -# Install rules -install_project(gmock gmock_main) - -######################################################################## -# -# Google Mock's own tests. -# -# You can skip this section if you aren't interested in testing -# Google Mock itself. -# -# The tests are not built by default. To build them, set the -# gmock_build_tests option to ON. You can do it by running ccmake -# or specifying the -Dgmock_build_tests=ON flag when running cmake. - -if (gmock_build_tests) - # This must be set in the root directory for the tests to be run by - # 'make test' or ctest. - enable_testing() - - if (WIN32) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$/RunTest.ps1" - CONTENT -"$project_bin = \"${CMAKE_BINARY_DIR}/bin/$\" -$env:Path = \"$project_bin;$env:Path\" -& $args") - elseif (MINGW OR CYGWIN) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/RunTest.ps1" - CONTENT -"$project_bin = (cygpath --windows ${CMAKE_BINARY_DIR}/bin) -$env:Path = \"$project_bin;$env:Path\" -& $args") - endif() - - if (MINGW OR CYGWIN) - if (CMAKE_VERSION VERSION_LESS "2.8.12") - add_compile_options("-Wa,-mbig-obj") - else() - add_definitions("-Wa,-mbig-obj") - endif() - endif() - - ############################################################ - # C++ tests built with standard compiler flags. - - cxx_test(gmock-actions_test gmock_main) - cxx_test(gmock-cardinalities_test gmock_main) - cxx_test(gmock_ex_test gmock_main) - cxx_test(gmock-function-mocker_test gmock_main) - cxx_test(gmock-generated-actions_test gmock_main) - cxx_test(gmock-generated-function-mockers_test gmock_main) - cxx_test(gmock-generated-matchers_test gmock_main) - cxx_test(gmock-internal-utils_test gmock_main) - cxx_test(gmock-matchers_test gmock_main) - cxx_test(gmock-more-actions_test gmock_main) - cxx_test(gmock-nice-strict_test gmock_main) - cxx_test(gmock-port_test gmock_main) - cxx_test(gmock-spec-builders_test gmock_main) - cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc) - cxx_test(gmock_test gmock_main) - - if (DEFINED GTEST_HAS_PTHREAD) - cxx_test(gmock_stress_test gmock) - endif() - - # gmock_all_test is commented to save time building and running tests. - # Uncomment if necessary. - # cxx_test(gmock_all_test gmock_main) - - ############################################################ - # C++ tests built with non-standard compiler flags. - - if (MSVC) - cxx_library(gmock_main_no_exception "${cxx_no_exception}" - "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) - - cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" - "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) - - else() - cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc) - target_link_libraries(gmock_main_no_exception PUBLIC gmock) - - cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc) - target_link_libraries(gmock_main_no_rtti PUBLIC gmock) - endif() - cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}" - gmock_main_no_exception test/gmock-more-actions_test.cc) - - cxx_test_with_flags(gmock_no_rtti_test "${cxx_no_rtti}" - gmock_main_no_rtti test/gmock-spec-builders_test.cc) - - cxx_shared_library(shared_gmock_main "${cxx_default}" - "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) - - # Tests that a binary can be built with Google Mock as a shared library. On - # some system configurations, it may not possible to run the binary without - # knowing more details about the system configurations. We do not try to run - # this binary. To get a more robust shared library coverage, configure with - # -DBUILD_SHARED_LIBS=ON. - cxx_executable_with_flags(shared_gmock_test_ "${cxx_default}" - shared_gmock_main test/gmock-spec-builders_test.cc) - set_target_properties(shared_gmock_test_ - PROPERTIES - COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") - - ############################################################ - # Python tests. - - cxx_executable(gmock_leak_test_ test gmock_main) - py_test(gmock_leak_test) - - cxx_executable(gmock_output_test_ test gmock) - py_test(gmock_output_test) -endif() diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/CONTRIBUTORS mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/CONTRIBUTORS --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/CONTRIBUTORS 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/CONTRIBUTORS 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -# This file contains a list of people who've made non-trivial -# contribution to the Google C++ Mocking Framework project. People -# who commit code to the project are encouraged to add their names -# here. Please keep the list sorted by first names. - -Benoit Sigoure -Bogdan Piloca -Chandler Carruth -Dave MacLachlan -David Anderson -Dean Sturtevant -Gene Volovich -Hal Burch -Jeffrey Yasskin -Jim Keller -Joe Walnes -Jon Wray -Keir Mierle -Keith Ray -Kostya Serebryany -Lev Makhlis -Manuel Klimek -Mario Tanev -Mark Paskin -Markus Heule -Matthew Simmons -Mike Bland -Neal Norwitz -Nermin Ozkiranartli -Owen Carlsen -Paneendra Ba -Paul Menage -Piotr Kaminski -Russ Rufer -Sverre Sundsdal -Takeshi Yoshino -Vadim Berman -Vlad Losev -Wolfgang Klier -Zhanyong Wan diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-actions.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-actions.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-actions.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-actions.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1142 +0,0 @@ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used actions. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ - -#ifndef _WIN32_WCE -# include -#endif - -#include -#include -#include -#include -#include -#include - -#include "gmock/internal/gmock-internal-utils.h" -#include "gmock/internal/gmock-port.h" - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -#endif - -namespace testing { - -// To implement an action Foo, define: -// 1. a class FooAction that implements the ActionInterface interface, and -// 2. a factory function that creates an Action object from a -// const FooAction*. -// -// The two-level delegation design follows that of Matcher, providing -// consistency for extension developers. It also eases ownership -// management as Action objects can now be copied like plain values. - -namespace internal { - -// BuiltInDefaultValueGetter::Get() returns a -// default-constructed T value. BuiltInDefaultValueGetter::Get() crashes with an error. -// -// This primary template is used when kDefaultConstructible is true. -template -struct BuiltInDefaultValueGetter { - static T Get() { return T(); } -}; -template -struct BuiltInDefaultValueGetter { - static T Get() { - Assert(false, __FILE__, __LINE__, - "Default action undefined for the function return type."); - return internal::Invalid(); - // The above statement will never be reached, but is required in - // order for this function to compile. - } -}; - -// BuiltInDefaultValue::Get() returns the "built-in" default value -// for type T, which is NULL when T is a raw pointer type, 0 when T is -// a numeric type, false when T is bool, or "" when T is string or -// std::string. In addition, in C++11 and above, it turns a -// default-constructed T value if T is default constructible. For any -// other type T, the built-in default T value is undefined, and the -// function will abort the process. -template -class BuiltInDefaultValue { - public: - // This function returns true if and only if type T has a built-in default - // value. - static bool Exists() { - return ::std::is_default_constructible::value; - } - - static T Get() { - return BuiltInDefaultValueGetter< - T, ::std::is_default_constructible::value>::Get(); - } -}; - -// This partial specialization says that we use the same built-in -// default value for T and const T. -template -class BuiltInDefaultValue { - public: - static bool Exists() { return BuiltInDefaultValue::Exists(); } - static T Get() { return BuiltInDefaultValue::Get(); } -}; - -// This partial specialization defines the default values for pointer -// types. -template -class BuiltInDefaultValue { - public: - static bool Exists() { return true; } - static T* Get() { return nullptr; } -}; - -// The following specializations define the default values for -// specific types we care about. -#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \ - template <> \ - class BuiltInDefaultValue { \ - public: \ - static bool Exists() { return true; } \ - static type Get() { return value; } \ - } - -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, ""); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0'); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0'); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\0'); - -// There's no need for a default action for signed wchar_t, as that -// type is the same as wchar_t for gcc, and invalid for MSVC. -// -// There's also no need for a default action for unsigned wchar_t, as -// that type is the same as unsigned int for gcc, and invalid for -// MSVC. -#if GMOCK_WCHAR_T_IS_NATIVE_ -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U); // NOLINT -#endif - -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0); - -#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_ - -} // namespace internal - -// When an unexpected function call is encountered, Google Mock will -// let it return a default value if the user has specified one for its -// return type, or if the return type has a built-in default value; -// otherwise Google Mock won't know what value to return and will have -// to abort the process. -// -// The DefaultValue class allows a user to specify the -// default value for a type T that is both copyable and publicly -// destructible (i.e. anything that can be used as a function return -// type). The usage is: -// -// // Sets the default value for type T to be foo. -// DefaultValue::Set(foo); -template -class DefaultValue { - public: - // Sets the default value for type T; requires T to be - // copy-constructable and have a public destructor. - static void Set(T x) { - delete producer_; - producer_ = new FixedValueProducer(x); - } - - // Provides a factory function to be called to generate the default value. - // This method can be used even if T is only move-constructible, but it is not - // limited to that case. - typedef T (*FactoryFunction)(); - static void SetFactory(FactoryFunction factory) { - delete producer_; - producer_ = new FactoryValueProducer(factory); - } - - // Unsets the default value for type T. - static void Clear() { - delete producer_; - producer_ = nullptr; - } - - // Returns true if and only if the user has set the default value for type T. - static bool IsSet() { return producer_ != nullptr; } - - // Returns true if T has a default return value set by the user or there - // exists a built-in default value. - static bool Exists() { - return IsSet() || internal::BuiltInDefaultValue::Exists(); - } - - // Returns the default value for type T if the user has set one; - // otherwise returns the built-in default value. Requires that Exists() - // is true, which ensures that the return value is well-defined. - static T Get() { - return producer_ == nullptr ? internal::BuiltInDefaultValue::Get() - : producer_->Produce(); - } - - private: - class ValueProducer { - public: - virtual ~ValueProducer() {} - virtual T Produce() = 0; - }; - - class FixedValueProducer : public ValueProducer { - public: - explicit FixedValueProducer(T value) : value_(value) {} - T Produce() override { return value_; } - - private: - const T value_; - GTEST_DISALLOW_COPY_AND_ASSIGN_(FixedValueProducer); - }; - - class FactoryValueProducer : public ValueProducer { - public: - explicit FactoryValueProducer(FactoryFunction factory) - : factory_(factory) {} - T Produce() override { return factory_(); } - - private: - const FactoryFunction factory_; - GTEST_DISALLOW_COPY_AND_ASSIGN_(FactoryValueProducer); - }; - - static ValueProducer* producer_; -}; - -// This partial specialization allows a user to set default values for -// reference types. -template -class DefaultValue { - public: - // Sets the default value for type T&. - static void Set(T& x) { // NOLINT - address_ = &x; - } - - // Unsets the default value for type T&. - static void Clear() { address_ = nullptr; } - - // Returns true if and only if the user has set the default value for type T&. - static bool IsSet() { return address_ != nullptr; } - - // Returns true if T has a default return value set by the user or there - // exists a built-in default value. - static bool Exists() { - return IsSet() || internal::BuiltInDefaultValue::Exists(); - } - - // Returns the default value for type T& if the user has set one; - // otherwise returns the built-in default value if there is one; - // otherwise aborts the process. - static T& Get() { - return address_ == nullptr ? internal::BuiltInDefaultValue::Get() - : *address_; - } - - private: - static T* address_; -}; - -// This specialization allows DefaultValue::Get() to -// compile. -template <> -class DefaultValue { - public: - static bool Exists() { return true; } - static void Get() {} -}; - -// Points to the user-set default value for type T. -template -typename DefaultValue::ValueProducer* DefaultValue::producer_ = nullptr; - -// Points to the user-set default value for type T&. -template -T* DefaultValue::address_ = nullptr; - -// Implement this interface to define an action for function type F. -template -class ActionInterface { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - ActionInterface() {} - virtual ~ActionInterface() {} - - // Performs the action. This method is not const, as in general an - // action can have side effects and be stateful. For example, a - // get-the-next-element-from-the-collection action will need to - // remember the current element. - virtual Result Perform(const ArgumentTuple& args) = 0; - - private: - GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface); -}; - -// An Action is a copyable and IMMUTABLE (except by assignment) -// object that represents an action to be taken when a mock function -// of type F is called. The implementation of Action is just a -// std::shared_ptr to const ActionInterface. Don't inherit from Action! -// You can view an object implementing ActionInterface as a -// concrete action (including its current state), and an Action -// object as a handle to it. -template -class Action { - // Adapter class to allow constructing Action from a legacy ActionInterface. - // New code should create Actions from functors instead. - struct ActionAdapter { - // Adapter must be copyable to satisfy std::function requirements. - ::std::shared_ptr> impl_; - - template - typename internal::Function::Result operator()(Args&&... args) { - return impl_->Perform( - ::std::forward_as_tuple(::std::forward(args)...)); - } - }; - - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - // Constructs a null Action. Needed for storing Action objects in - // STL containers. - Action() {} - - // Construct an Action from a specified callable. - // This cannot take std::function directly, because then Action would not be - // directly constructible from lambda (it would require two conversions). - template , G>::value>::type> - Action(G&& fun) : fun_(::std::forward(fun)) {} // NOLINT - - // Constructs an Action from its implementation. - explicit Action(ActionInterface* impl) - : fun_(ActionAdapter{::std::shared_ptr>(impl)}) {} - - // This constructor allows us to turn an Action object into an - // Action, as long as F's arguments can be implicitly converted - // to Func's and Func's return type can be implicitly converted to F's. - template - explicit Action(const Action& action) : fun_(action.fun_) {} - - // Returns true if and only if this is the DoDefault() action. - bool IsDoDefault() const { return fun_ == nullptr; } - - // Performs the action. Note that this method is const even though - // the corresponding method in ActionInterface is not. The reason - // is that a const Action means that it cannot be re-bound to - // another concrete action, not that the concrete action it binds to - // cannot change state. (Think of the difference between a const - // pointer and a pointer to const.) - Result Perform(ArgumentTuple args) const { - if (IsDoDefault()) { - internal::IllegalDoDefault(__FILE__, __LINE__); - } - return internal::Apply(fun_, ::std::move(args)); - } - - private: - template - friend class Action; - - // fun_ is an empty function if and only if this is the DoDefault() action. - ::std::function fun_; -}; - -// The PolymorphicAction class template makes it easy to implement a -// polymorphic action (i.e. an action that can be used in mock -// functions of than one type, e.g. Return()). -// -// To define a polymorphic action, a user first provides a COPYABLE -// implementation class that has a Perform() method template: -// -// class FooAction { -// public: -// template -// Result Perform(const ArgumentTuple& args) const { -// // Processes the arguments and returns a result, using -// // std::get(args) to get the N-th (0-based) argument in the tuple. -// } -// ... -// }; -// -// Then the user creates the polymorphic action using -// MakePolymorphicAction(object) where object has type FooAction. See -// the definition of Return(void) and SetArgumentPointee(value) for -// complete examples. -template -class PolymorphicAction { - public: - explicit PolymorphicAction(const Impl& impl) : impl_(impl) {} - - template - operator Action() const { - return Action(new MonomorphicImpl(impl_)); - } - - private: - template - class MonomorphicImpl : public ActionInterface { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} - - Result Perform(const ArgumentTuple& args) override { - return impl_.template Perform(args); - } - - private: - Impl impl_; - - GTEST_DISALLOW_ASSIGN_(MonomorphicImpl); - }; - - Impl impl_; - - GTEST_DISALLOW_ASSIGN_(PolymorphicAction); -}; - -// Creates an Action from its implementation and returns it. The -// created Action object owns the implementation. -template -Action MakeAction(ActionInterface* impl) { - return Action(impl); -} - -// Creates a polymorphic action from its implementation. This is -// easier to use than the PolymorphicAction constructor as it -// doesn't require you to explicitly write the template argument, e.g. -// -// MakePolymorphicAction(foo); -// vs -// PolymorphicAction(foo); -template -inline PolymorphicAction MakePolymorphicAction(const Impl& impl) { - return PolymorphicAction(impl); -} - -namespace internal { - -// Helper struct to specialize ReturnAction to execute a move instead of a copy -// on return. Useful for move-only types, but could be used on any type. -template -struct ByMoveWrapper { - explicit ByMoveWrapper(T value) : payload(std::move(value)) {} - T payload; -}; - -// Implements the polymorphic Return(x) action, which can be used in -// any function that returns the type of x, regardless of the argument -// types. -// -// Note: The value passed into Return must be converted into -// Function::Result when this action is cast to Action rather than -// when that action is performed. This is important in scenarios like -// -// MOCK_METHOD1(Method, T(U)); -// ... -// { -// Foo foo; -// X x(&foo); -// EXPECT_CALL(mock, Method(_)).WillOnce(Return(x)); -// } -// -// In the example above the variable x holds reference to foo which leaves -// scope and gets destroyed. If copying X just copies a reference to foo, -// that copy will be left with a hanging reference. If conversion to T -// makes a copy of foo, the above code is safe. To support that scenario, we -// need to make sure that the type conversion happens inside the EXPECT_CALL -// statement, and conversion of the result of Return to Action is a -// good place for that. -// -// The real life example of the above scenario happens when an invocation -// of gtl::Container() is passed into Return. -// -template -class ReturnAction { - public: - // Constructs a ReturnAction object from the value to be returned. - // 'value' is passed by value instead of by const reference in order - // to allow Return("string literal") to compile. - explicit ReturnAction(R value) : value_(new R(std::move(value))) {} - - // This template type conversion operator allows Return(x) to be - // used in ANY function that returns x's type. - template - operator Action() const { // NOLINT - // Assert statement belongs here because this is the best place to verify - // conditions on F. It produces the clearest error messages - // in most compilers. - // Impl really belongs in this scope as a local class but can't - // because MSVC produces duplicate symbols in different translation units - // in this case. Until MS fixes that bug we put Impl into the class scope - // and put the typedef both here (for use in assert statement) and - // in the Impl class. But both definitions must be the same. - typedef typename Function::Result Result; - GTEST_COMPILE_ASSERT_( - !std::is_reference::value, - use_ReturnRef_instead_of_Return_to_return_a_reference); - static_assert(!std::is_void::value, - "Can't use Return() on an action expected to return `void`."); - return Action(new Impl(value_)); - } - - private: - // Implements the Return(x) action for a particular function type F. - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - // The implicit cast is necessary when Result has more than one - // single-argument constructor (e.g. Result is std::vector) and R - // has a type conversion operator template. In that case, value_(value) - // won't compile as the compiler doesn't known which constructor of - // Result to call. ImplicitCast_ forces the compiler to convert R to - // Result without considering explicit constructors, thus resolving the - // ambiguity. value_ is then initialized using its copy constructor. - explicit Impl(const std::shared_ptr& value) - : value_before_cast_(*value), - value_(ImplicitCast_(value_before_cast_)) {} - - Result Perform(const ArgumentTuple&) override { return value_; } - - private: - GTEST_COMPILE_ASSERT_(!std::is_reference::value, - Result_cannot_be_a_reference_type); - // We save the value before casting just in case it is being cast to a - // wrapper type. - R value_before_cast_; - Result value_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl); - }; - - // Partially specialize for ByMoveWrapper. This version of ReturnAction will - // move its contents instead. - template - class Impl, F> : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - explicit Impl(const std::shared_ptr& wrapper) - : performed_(false), wrapper_(wrapper) {} - - Result Perform(const ArgumentTuple&) override { - GTEST_CHECK_(!performed_) - << "A ByMove() action should only be performed once."; - performed_ = true; - return std::move(wrapper_->payload); - } - - private: - bool performed_; - const std::shared_ptr wrapper_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - const std::shared_ptr value_; - - GTEST_DISALLOW_ASSIGN_(ReturnAction); -}; - -// Implements the ReturnNull() action. -class ReturnNullAction { - public: - // Allows ReturnNull() to be used in any pointer-returning function. In C++11 - // this is enforced by returning nullptr, and in non-C++11 by asserting a - // pointer type on compile time. - template - static Result Perform(const ArgumentTuple&) { - return nullptr; - } -}; - -// Implements the Return() action. -class ReturnVoidAction { - public: - // Allows Return() to be used in any void-returning function. - template - static void Perform(const ArgumentTuple&) { - static_assert(std::is_void::value, "Result should be void."); - } -}; - -// Implements the polymorphic ReturnRef(x) action, which can be used -// in any function that returns a reference to the type of x, -// regardless of the argument types. -template -class ReturnRefAction { - public: - // Constructs a ReturnRefAction object from the reference to be returned. - explicit ReturnRefAction(T& ref) : ref_(ref) {} // NOLINT - - // This template type conversion operator allows ReturnRef(x) to be - // used in ANY function that returns a reference to x's type. - template - operator Action() const { - typedef typename Function::Result Result; - // Asserts that the function return type is a reference. This - // catches the user error of using ReturnRef(x) when Return(x) - // should be used, and generates some helpful error message. - GTEST_COMPILE_ASSERT_(std::is_reference::value, - use_Return_instead_of_ReturnRef_to_return_a_value); - return Action(new Impl(ref_)); - } - - private: - // Implements the ReturnRef(x) action for a particular function type F. - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - explicit Impl(T& ref) : ref_(ref) {} // NOLINT - - Result Perform(const ArgumentTuple&) override { return ref_; } - - private: - T& ref_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - T& ref_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefAction); -}; - -// Implements the polymorphic ReturnRefOfCopy(x) action, which can be -// used in any function that returns a reference to the type of x, -// regardless of the argument types. -template -class ReturnRefOfCopyAction { - public: - // Constructs a ReturnRefOfCopyAction object from the reference to - // be returned. - explicit ReturnRefOfCopyAction(const T& value) : value_(value) {} // NOLINT - - // This template type conversion operator allows ReturnRefOfCopy(x) to be - // used in ANY function that returns a reference to x's type. - template - operator Action() const { - typedef typename Function::Result Result; - // Asserts that the function return type is a reference. This - // catches the user error of using ReturnRefOfCopy(x) when Return(x) - // should be used, and generates some helpful error message. - GTEST_COMPILE_ASSERT_( - std::is_reference::value, - use_Return_instead_of_ReturnRefOfCopy_to_return_a_value); - return Action(new Impl(value_)); - } - - private: - // Implements the ReturnRefOfCopy(x) action for a particular function type F. - template - class Impl : public ActionInterface { - public: - typedef typename Function::Result Result; - typedef typename Function::ArgumentTuple ArgumentTuple; - - explicit Impl(const T& value) : value_(value) {} // NOLINT - - Result Perform(const ArgumentTuple&) override { return value_; } - - private: - T value_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - const T value_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction); -}; - -// Implements the polymorphic DoDefault() action. -class DoDefaultAction { - public: - // This template type conversion operator allows DoDefault() to be - // used in any function. - template - operator Action() const { return Action(); } // NOLINT -}; - -// Implements the Assign action to set a given pointer referent to a -// particular value. -template -class AssignAction { - public: - AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {} - - template - void Perform(const ArgumentTuple& /* args */) const { - *ptr_ = value_; - } - - private: - T1* const ptr_; - const T2 value_; - - GTEST_DISALLOW_ASSIGN_(AssignAction); -}; - -#if !GTEST_OS_WINDOWS_MOBILE - -// Implements the SetErrnoAndReturn action to simulate return from -// various system calls and libc functions. -template -class SetErrnoAndReturnAction { - public: - SetErrnoAndReturnAction(int errno_value, T result) - : errno_(errno_value), - result_(result) {} - template - Result Perform(const ArgumentTuple& /* args */) const { - errno = errno_; - return result_; - } - - private: - const int errno_; - const T result_; - - GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction); -}; - -#endif // !GTEST_OS_WINDOWS_MOBILE - -// Implements the SetArgumentPointee(x) action for any function -// whose N-th argument (0-based) is a pointer to x's type. -template -struct SetArgumentPointeeAction { - A value; - - template - void operator()(const Args&... args) const { - *::std::get(std::tie(args...)) = value; - } -}; - -// Implements the Invoke(object_ptr, &Class::Method) action. -template -struct InvokeMethodAction { - Class* const obj_ptr; - const MethodPtr method_ptr; - - template - auto operator()(Args&&... args) const - -> decltype((obj_ptr->*method_ptr)(std::forward(args)...)) { - return (obj_ptr->*method_ptr)(std::forward(args)...); - } -}; - -// Implements the InvokeWithoutArgs(f) action. The template argument -// FunctionImpl is the implementation type of f, which can be either a -// function pointer or a functor. InvokeWithoutArgs(f) can be used as an -// Action as long as f's type is compatible with F. -template -struct InvokeWithoutArgsAction { - FunctionImpl function_impl; - - // Allows InvokeWithoutArgs(f) to be used as any action whose type is - // compatible with f. - template - auto operator()(const Args&...) -> decltype(function_impl()) { - return function_impl(); - } -}; - -// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action. -template -struct InvokeMethodWithoutArgsAction { - Class* const obj_ptr; - const MethodPtr method_ptr; - - using ReturnType = typename std::result_of::type; - - template - ReturnType operator()(const Args&...) const { - return (obj_ptr->*method_ptr)(); - } -}; - -// Implements the IgnoreResult(action) action. -template -class IgnoreResultAction { - public: - explicit IgnoreResultAction(const A& action) : action_(action) {} - - template - operator Action() const { - // Assert statement belongs here because this is the best place to verify - // conditions on F. It produces the clearest error messages - // in most compilers. - // Impl really belongs in this scope as a local class but can't - // because MSVC produces duplicate symbols in different translation units - // in this case. Until MS fixes that bug we put Impl into the class scope - // and put the typedef both here (for use in assert statement) and - // in the Impl class. But both definitions must be the same. - typedef typename internal::Function::Result Result; - - // Asserts at compile time that F returns void. - static_assert(std::is_void::value, "Result type should be void."); - - return Action(new Impl(action_)); - } - - private: - template - class Impl : public ActionInterface { - public: - typedef typename internal::Function::Result Result; - typedef typename internal::Function::ArgumentTuple ArgumentTuple; - - explicit Impl(const A& action) : action_(action) {} - - void Perform(const ArgumentTuple& args) override { - // Performs the action and ignores its result. - action_.Perform(args); - } - - private: - // Type OriginalFunction is the same as F except that its return - // type is IgnoredValue. - typedef typename internal::Function::MakeResultIgnoredValue - OriginalFunction; - - const Action action_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - const A action_; - - GTEST_DISALLOW_ASSIGN_(IgnoreResultAction); -}; - -template -struct WithArgsAction { - InnerAction action; - - // The inner action could be anything convertible to Action. - // We use the conversion operator to detect the signature of the inner Action. - template - operator Action() const { // NOLINT - Action>::type...)> - converted(action); - - return [converted](Args... args) -> R { - return converted.Perform(std::forward_as_tuple( - std::get(std::forward_as_tuple(std::forward(args)...))...)); - }; - } -}; - -template -struct DoAllAction { - private: - template - std::vector> Convert(IndexSequence) const { - return {std::get(actions)...}; - } - - public: - std::tuple actions; - - template - operator Action() const { // NOLINT - struct Op { - std::vector> converted; - Action last; - R operator()(Args... args) const { - auto tuple_args = std::forward_as_tuple(std::forward(args)...); - for (auto& a : converted) { - a.Perform(tuple_args); - } - return last.Perform(tuple_args); - } - }; - return Op{Convert(MakeIndexSequence()), - std::get(actions)}; - } -}; - -} // namespace internal - -// An Unused object can be implicitly constructed from ANY value. -// This is handy when defining actions that ignore some or all of the -// mock function arguments. For example, given -// -// MOCK_METHOD3(Foo, double(const string& label, double x, double y)); -// MOCK_METHOD3(Bar, double(int index, double x, double y)); -// -// instead of -// -// double DistanceToOriginWithLabel(const string& label, double x, double y) { -// return sqrt(x*x + y*y); -// } -// double DistanceToOriginWithIndex(int index, double x, double y) { -// return sqrt(x*x + y*y); -// } -// ... -// EXPECT_CALL(mock, Foo("abc", _, _)) -// .WillOnce(Invoke(DistanceToOriginWithLabel)); -// EXPECT_CALL(mock, Bar(5, _, _)) -// .WillOnce(Invoke(DistanceToOriginWithIndex)); -// -// you could write -// -// // We can declare any uninteresting argument as Unused. -// double DistanceToOrigin(Unused, double x, double y) { -// return sqrt(x*x + y*y); -// } -// ... -// EXPECT_CALL(mock, Foo("abc", _, _)).WillOnce(Invoke(DistanceToOrigin)); -// EXPECT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin)); -typedef internal::IgnoredValue Unused; - -// Creates an action that does actions a1, a2, ..., sequentially in -// each invocation. -template -internal::DoAllAction::type...> DoAll( - Action&&... action) { - return {std::forward_as_tuple(std::forward(action)...)}; -} - -// WithArg(an_action) creates an action that passes the k-th -// (0-based) argument of the mock function to an_action and performs -// it. It adapts an action accepting one argument to one that accepts -// multiple arguments. For convenience, we also provide -// WithArgs(an_action) (defined below) as a synonym. -template -internal::WithArgsAction::type, k> -WithArg(InnerAction&& action) { - return {std::forward(action)}; -} - -// WithArgs(an_action) creates an action that passes -// the selected arguments of the mock function to an_action and -// performs it. It serves as an adaptor between actions with -// different argument lists. -template -internal::WithArgsAction::type, k, ks...> -WithArgs(InnerAction&& action) { - return {std::forward(action)}; -} - -// WithoutArgs(inner_action) can be used in a mock function with a -// non-empty argument list to perform inner_action, which takes no -// argument. In other words, it adapts an action accepting no -// argument to one that accepts (and ignores) arguments. -template -internal::WithArgsAction::type> -WithoutArgs(InnerAction&& action) { - return {std::forward(action)}; -} - -// Creates an action that returns 'value'. 'value' is passed by value -// instead of const reference - otherwise Return("string literal") -// will trigger a compiler error about using array as initializer. -template -internal::ReturnAction Return(R value) { - return internal::ReturnAction(std::move(value)); -} - -// Creates an action that returns NULL. -inline PolymorphicAction ReturnNull() { - return MakePolymorphicAction(internal::ReturnNullAction()); -} - -// Creates an action that returns from a void function. -inline PolymorphicAction Return() { - return MakePolymorphicAction(internal::ReturnVoidAction()); -} - -// Creates an action that returns the reference to a variable. -template -inline internal::ReturnRefAction ReturnRef(R& x) { // NOLINT - return internal::ReturnRefAction(x); -} - -// Creates an action that returns the reference to a copy of the -// argument. The copy is created when the action is constructed and -// lives as long as the action. -template -inline internal::ReturnRefOfCopyAction ReturnRefOfCopy(const R& x) { - return internal::ReturnRefOfCopyAction(x); -} - -// Modifies the parent action (a Return() action) to perform a move of the -// argument instead of a copy. -// Return(ByMove()) actions can only be executed once and will assert this -// invariant. -template -internal::ByMoveWrapper ByMove(R x) { - return internal::ByMoveWrapper(std::move(x)); -} - -// Creates an action that does the default action for the give mock function. -inline internal::DoDefaultAction DoDefault() { - return internal::DoDefaultAction(); -} - -// Creates an action that sets the variable pointed by the N-th -// (0-based) function argument to 'value'. -template -internal::SetArgumentPointeeAction SetArgPointee(T x) { - return {std::move(x)}; -} - -// The following version is DEPRECATED. -template -internal::SetArgumentPointeeAction SetArgumentPointee(T x) { - return {std::move(x)}; -} - -// Creates an action that sets a pointer referent to a given value. -template -PolymorphicAction > Assign(T1* ptr, T2 val) { - return MakePolymorphicAction(internal::AssignAction(ptr, val)); -} - -#if !GTEST_OS_WINDOWS_MOBILE - -// Creates an action that sets errno and returns the appropriate error. -template -PolymorphicAction > -SetErrnoAndReturn(int errval, T result) { - return MakePolymorphicAction( - internal::SetErrnoAndReturnAction(errval, result)); -} - -#endif // !GTEST_OS_WINDOWS_MOBILE - -// Various overloads for Invoke(). - -// Legacy function. -// Actions can now be implicitly constructed from callables. No need to create -// wrapper objects. -// This function exists for backwards compatibility. -template -typename std::decay::type Invoke(FunctionImpl&& function_impl) { - return std::forward(function_impl); -} - -// Creates an action that invokes the given method on the given object -// with the mock function's arguments. -template -internal::InvokeMethodAction Invoke(Class* obj_ptr, - MethodPtr method_ptr) { - return {obj_ptr, method_ptr}; -} - -// Creates an action that invokes 'function_impl' with no argument. -template -internal::InvokeWithoutArgsAction::type> -InvokeWithoutArgs(FunctionImpl function_impl) { - return {std::move(function_impl)}; -} - -// Creates an action that invokes the given method on the given object -// with no argument. -template -internal::InvokeMethodWithoutArgsAction InvokeWithoutArgs( - Class* obj_ptr, MethodPtr method_ptr) { - return {obj_ptr, method_ptr}; -} - -// Creates an action that performs an_action and throws away its -// result. In other words, it changes the return type of an_action to -// void. an_action MUST NOT return void, or the code won't compile. -template -inline internal::IgnoreResultAction IgnoreResult(const A& an_action) { - return internal::IgnoreResultAction(an_action); -} - -// Creates a reference wrapper for the given L-value. If necessary, -// you can explicitly specify the type of the reference. For example, -// suppose 'derived' is an object of type Derived, ByRef(derived) -// would wrap a Derived&. If you want to wrap a const Base& instead, -// where Base is a base class of Derived, just write: -// -// ByRef(derived) -// -// N.B. ByRef is redundant with std::ref, std::cref and std::reference_wrapper. -// However, it may still be used for consistency with ByMove(). -template -inline ::std::reference_wrapper ByRef(T& l_value) { // NOLINT - return ::std::reference_wrapper(l_value); -} - -} // namespace testing - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-cardinalities.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-cardinalities.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-cardinalities.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-cardinalities.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used cardinalities. More -// cardinalities can be defined by the user implementing the -// CardinalityInterface interface if necessary. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ - -#include -#include -#include // NOLINT -#include "gmock/internal/gmock-port.h" -#include "gtest/gtest.h" - -GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ -/* class A needs to have dll-interface to be used by clients of class B */) - -namespace testing { - -// To implement a cardinality Foo, define: -// 1. a class FooCardinality that implements the -// CardinalityInterface interface, and -// 2. a factory function that creates a Cardinality object from a -// const FooCardinality*. -// -// The two-level delegation design follows that of Matcher, providing -// consistency for extension developers. It also eases ownership -// management as Cardinality objects can now be copied like plain values. - -// The implementation of a cardinality. -class CardinalityInterface { - public: - virtual ~CardinalityInterface() {} - - // Conservative estimate on the lower/upper bound of the number of - // calls allowed. - virtual int ConservativeLowerBound() const { return 0; } - virtual int ConservativeUpperBound() const { return INT_MAX; } - - // Returns true if and only if call_count calls will satisfy this - // cardinality. - virtual bool IsSatisfiedByCallCount(int call_count) const = 0; - - // Returns true if and only if call_count calls will saturate this - // cardinality. - virtual bool IsSaturatedByCallCount(int call_count) const = 0; - - // Describes self to an ostream. - virtual void DescribeTo(::std::ostream* os) const = 0; -}; - -// A Cardinality is a copyable and IMMUTABLE (except by assignment) -// object that specifies how many times a mock function is expected to -// be called. The implementation of Cardinality is just a std::shared_ptr -// to const CardinalityInterface. Don't inherit from Cardinality! -class GTEST_API_ Cardinality { - public: - // Constructs a null cardinality. Needed for storing Cardinality - // objects in STL containers. - Cardinality() {} - - // Constructs a Cardinality from its implementation. - explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {} - - // Conservative estimate on the lower/upper bound of the number of - // calls allowed. - int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); } - int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); } - - // Returns true if and only if call_count calls will satisfy this - // cardinality. - bool IsSatisfiedByCallCount(int call_count) const { - return impl_->IsSatisfiedByCallCount(call_count); - } - - // Returns true if and only if call_count calls will saturate this - // cardinality. - bool IsSaturatedByCallCount(int call_count) const { - return impl_->IsSaturatedByCallCount(call_count); - } - - // Returns true if and only if call_count calls will over-saturate this - // cardinality, i.e. exceed the maximum number of allowed calls. - bool IsOverSaturatedByCallCount(int call_count) const { - return impl_->IsSaturatedByCallCount(call_count) && - !impl_->IsSatisfiedByCallCount(call_count); - } - - // Describes self to an ostream - void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } - - // Describes the given actual call count to an ostream. - static void DescribeActualCallCountTo(int actual_call_count, - ::std::ostream* os); - - private: - std::shared_ptr impl_; -}; - -// Creates a cardinality that allows at least n calls. -GTEST_API_ Cardinality AtLeast(int n); - -// Creates a cardinality that allows at most n calls. -GTEST_API_ Cardinality AtMost(int n); - -// Creates a cardinality that allows any number of calls. -GTEST_API_ Cardinality AnyNumber(); - -// Creates a cardinality that allows between min and max calls. -GTEST_API_ Cardinality Between(int min, int max); - -// Creates a cardinality that allows exactly n calls. -GTEST_API_ Cardinality Exactly(int n); - -// Creates a cardinality from its implementation. -inline Cardinality MakeCardinality(const CardinalityInterface* c) { - return Cardinality(c); -} - -} // namespace testing - -GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-function-mocker.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-function-mocker.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-function-mocker.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-function-mocker.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,253 +0,0 @@ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements MOCK_METHOD. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT -#define THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT - -#include "gmock/gmock-generated-function-mockers.h" // NOLINT -#include "gmock/internal/gmock-pp.h" - -#define MOCK_METHOD(...) \ - GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__) - -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_1(...) \ - GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) - -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_2(...) \ - GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) - -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_3(_Ret, _MethodName, _Args) \ - GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, ()) - -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec) \ - GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args); \ - GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec); \ - GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \ - GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)); \ - GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \ - GMOCK_INTERNAL_MOCK_METHOD_IMPL( \ - GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec), \ - GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec), \ - GMOCK_INTERNAL_HAS_NOEXCEPT(_Spec), GMOCK_INTERNAL_GET_CALLTYPE(_Spec), \ - (GMOCK_INTERNAL_SIGNATURE(_Ret, _Args))) - -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_5(...) \ - GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) - -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_6(...) \ - GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) - -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_7(...) \ - GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) - -#define GMOCK_INTERNAL_WRONG_ARITY(...) \ - static_assert( \ - false, \ - "MOCK_METHOD must be called with 3 or 4 arguments. _Ret, " \ - "_MethodName, _Args and optionally _Spec. _Args and _Spec must be " \ - "enclosed in parentheses. If _Ret is a type with unprotected commas, " \ - "it must also be enclosed in parentheses.") - -#define GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Tuple) \ - static_assert( \ - GMOCK_PP_IS_ENCLOSED_PARENS(_Tuple), \ - GMOCK_PP_STRINGIZE(_Tuple) " should be enclosed in parentheses.") - -#define GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(_N, ...) \ - static_assert( \ - std::is_function<__VA_ARGS__>::value, \ - "Signature must be a function type, maybe return type contains " \ - "unprotected comma."); \ - static_assert( \ - ::testing::tuple_size::ArgumentTuple>::value == _N, \ - "This method does not take " GMOCK_PP_STRINGIZE( \ - _N) " arguments. Parenthesize all types with unproctected commas.") - -#define GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \ - GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT, ~, _Spec) - -#define GMOCK_INTERNAL_MOCK_METHOD_IMPL(_N, _MethodName, _Constness, \ - _Override, _Final, _Noexcept, \ - _CallType, _Signature) \ - typename ::testing::internal::Function::Result \ - GMOCK_INTERNAL_EXPAND(_CallType) \ - _MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N)) \ - GMOCK_PP_IF(_Constness, const, ) GMOCK_PP_IF(_Noexcept, noexcept, ) \ - GMOCK_PP_IF(_Override, override, ) \ - GMOCK_PP_IF(_Final, final, ) { \ - GMOCK_MOCKER_(_N, _Constness, _MethodName) \ - .SetOwnerAndName(this, #_MethodName); \ - return GMOCK_MOCKER_(_N, _Constness, _MethodName) \ - .Invoke(GMOCK_PP_REPEAT(GMOCK_INTERNAL_FORWARD_ARG, _Signature, _N)); \ - } \ - ::testing::MockSpec gmock_##_MethodName( \ - GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_PARAMETER, _Signature, _N)) \ - GMOCK_PP_IF(_Constness, const, ) { \ - GMOCK_MOCKER_(_N, _Constness, _MethodName).RegisterOwner(this); \ - return GMOCK_MOCKER_(_N, _Constness, _MethodName) \ - .With(GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_ARGUMENT, , _N)); \ - } \ - ::testing::MockSpec gmock_##_MethodName( \ - const ::testing::internal::WithoutMatchers&, \ - GMOCK_PP_IF(_Constness, const, )::testing::internal::Function< \ - GMOCK_PP_REMOVE_PARENS(_Signature)>*) \ - const GMOCK_PP_IF(_Noexcept, noexcept, ) { \ - return GMOCK_PP_CAT(::testing::internal::AdjustConstness_, \ - GMOCK_PP_IF(_Constness, const, ))(this) \ - ->gmock_##_MethodName(GMOCK_PP_REPEAT( \ - GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N)); \ - } \ - mutable ::testing::FunctionMocker \ - GMOCK_MOCKER_(_N, _Constness, _MethodName) - -#define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__ - -// Five Valid modifiers. -#define GMOCK_INTERNAL_HAS_CONST(_Tuple) \ - GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_CONST, ~, _Tuple)) - -#define GMOCK_INTERNAL_HAS_OVERRIDE(_Tuple) \ - GMOCK_PP_HAS_COMMA( \ - GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_OVERRIDE, ~, _Tuple)) - -#define GMOCK_INTERNAL_HAS_FINAL(_Tuple) \ - GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_FINAL, ~, _Tuple)) - -#define GMOCK_INTERNAL_HAS_NOEXCEPT(_Tuple) \ - GMOCK_PP_HAS_COMMA( \ - GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_NOEXCEPT, ~, _Tuple)) - -#define GMOCK_INTERNAL_GET_CALLTYPE(_Tuple) \ - GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_CALLTYPE_IMPL, ~, _Tuple) - -#define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem) \ - static_assert( \ - (GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)) + \ - GMOCK_INTERNAL_IS_CALLTYPE(_elem)) == 1, \ - GMOCK_PP_STRINGIZE( \ - _elem) " cannot be recognized as a valid specification modifier."); - -// Modifiers implementation. -#define GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem) \ - GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_CONST_I_, _elem) - -#define GMOCK_INTERNAL_DETECT_CONST_I_const , - -#define GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem) \ - GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_OVERRIDE_I_, _elem) - -#define GMOCK_INTERNAL_DETECT_OVERRIDE_I_override , - -#define GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem) \ - GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_FINAL_I_, _elem) - -#define GMOCK_INTERNAL_DETECT_FINAL_I_final , - -// TODO(iserna): Maybe noexcept should accept an argument here as well. -#define GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem) \ - GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_NOEXCEPT_I_, _elem) - -#define GMOCK_INTERNAL_DETECT_NOEXCEPT_I_noexcept , - -#define GMOCK_INTERNAL_GET_CALLTYPE_IMPL(_i, _, _elem) \ - GMOCK_PP_IF(GMOCK_INTERNAL_IS_CALLTYPE(_elem), \ - GMOCK_INTERNAL_GET_VALUE_CALLTYPE, GMOCK_PP_EMPTY) \ - (_elem) - -// TODO(iserna): GMOCK_INTERNAL_IS_CALLTYPE and -// GMOCK_INTERNAL_GET_VALUE_CALLTYPE needed more expansions to work on windows -// maybe they can be simplified somehow. -#define GMOCK_INTERNAL_IS_CALLTYPE(_arg) \ - GMOCK_INTERNAL_IS_CALLTYPE_I( \ - GMOCK_PP_CAT(GMOCK_INTERNAL_IS_CALLTYPE_HELPER_, _arg)) -#define GMOCK_INTERNAL_IS_CALLTYPE_I(_arg) GMOCK_PP_IS_ENCLOSED_PARENS(_arg) - -#define GMOCK_INTERNAL_GET_VALUE_CALLTYPE(_arg) \ - GMOCK_INTERNAL_GET_VALUE_CALLTYPE_I( \ - GMOCK_PP_CAT(GMOCK_INTERNAL_IS_CALLTYPE_HELPER_, _arg)) -#define GMOCK_INTERNAL_GET_VALUE_CALLTYPE_I(_arg) \ - GMOCK_PP_CAT(GMOCK_PP_IDENTITY, _arg) - -#define GMOCK_INTERNAL_IS_CALLTYPE_HELPER_Calltype - -#define GMOCK_INTERNAL_SIGNATURE(_Ret, _Args) \ - GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_Ret), GMOCK_PP_REMOVE_PARENS, \ - GMOCK_PP_IDENTITY) \ - (_Ret)(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_TYPE, _, _Args)) - -#define GMOCK_INTERNAL_GET_TYPE(_i, _, _elem) \ - GMOCK_PP_COMMA_IF(_i) \ - GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_elem), GMOCK_PP_REMOVE_PARENS, \ - GMOCK_PP_IDENTITY) \ - (_elem) - -#define GMOCK_INTERNAL_PARAMETER(_i, _Signature, _) \ - GMOCK_PP_COMMA_IF(_i) \ - GMOCK_INTERNAL_ARG_O(typename, GMOCK_PP_INC(_i), \ - GMOCK_PP_REMOVE_PARENS(_Signature)) \ - gmock_a##_i - -#define GMOCK_INTERNAL_FORWARD_ARG(_i, _Signature, _) \ - GMOCK_PP_COMMA_IF(_i) \ - ::std::forward( \ - gmock_a##_i) - -#define GMOCK_INTERNAL_MATCHER_PARAMETER(_i, _Signature, _) \ - GMOCK_PP_COMMA_IF(_i) \ - GMOCK_INTERNAL_MATCHER_O(typename, GMOCK_PP_INC(_i), \ - GMOCK_PP_REMOVE_PARENS(_Signature)) \ - gmock_a##_i - -#define GMOCK_INTERNAL_MATCHER_ARGUMENT(_i, _1, _2) \ - GMOCK_PP_COMMA_IF(_i) \ - gmock_a##_i - -#define GMOCK_INTERNAL_A_MATCHER_ARGUMENT(_i, _Signature, _) \ - GMOCK_PP_COMMA_IF(_i) \ - ::testing::A() - -#define GMOCK_INTERNAL_ARG_O(_tn, _i, ...) GMOCK_ARG_(_tn, _i, __VA_ARGS__) - -#define GMOCK_INTERNAL_MATCHER_O(_tn, _i, ...) \ - GMOCK_MATCHER_(_tn, _i, __VA_ARGS__) - -#endif // THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1884 +0,0 @@ -// This file was GENERATED by command: -// pump.py gmock-generated-actions.h.pump -// DO NOT EDIT BY HAND!!! - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used variadic actions. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ - -#include -#include - -#include "gmock/gmock-actions.h" -#include "gmock/internal/gmock-port.h" - -namespace testing { -namespace internal { - -// A macro from the ACTION* family (defined later in this file) -// defines an action that can be used in a mock function. Typically, -// these actions only care about a subset of the arguments of the mock -// function. For example, if such an action only uses the second -// argument, it can be used in any mock function that takes >= 2 -// arguments where the type of the second argument is compatible. -// -// Therefore, the action implementation must be prepared to take more -// arguments than it needs. The ExcessiveArg type is used to -// represent those excessive arguments. In order to keep the compiler -// error messages tractable, we define it in the testing namespace -// instead of testing::internal. However, this is an INTERNAL TYPE -// and subject to change without notice, so a user MUST NOT USE THIS -// TYPE DIRECTLY. -struct ExcessiveArg {}; - -// A helper class needed for implementing the ACTION* macros. -template -class ActionHelper { - public: - static Result Perform(Impl* impl, const ::std::tuple<>& args) { - return impl->template gmock_PerformImpl<>(args, ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, std::get<0>(args), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, std::get<0>(args), - std::get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, - std::get<0>(args), std::get<1>(args), std::get<2>(args), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, - std::get<0>(args), std::get<1>(args), std::get<2>(args), - std::get<3>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, - std::get<0>(args), std::get<1>(args), std::get<2>(args), - std::get<3>(args), std::get<4>(args), ExcessiveArg(), ExcessiveArg(), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, - std::get<0>(args), std::get<1>(args), std::get<2>(args), - std::get<3>(args), std::get<4>(args), std::get<5>(args), - ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, - std::get<0>(args), std::get<1>(args), std::get<2>(args), - std::get<3>(args), std::get<4>(args), std::get<5>(args), - std::get<6>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, std::get<0>(args), std::get<1>(args), std::get<2>(args), - std::get<3>(args), std::get<4>(args), std::get<5>(args), - std::get<6>(args), std::get<7>(args), ExcessiveArg(), ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, std::get<0>(args), std::get<1>(args), std::get<2>(args), - std::get<3>(args), std::get<4>(args), std::get<5>(args), - std::get<6>(args), std::get<7>(args), std::get<8>(args), - ExcessiveArg()); - } - - template - static Result Perform(Impl* impl, const ::std::tuple& args) { - return impl->template gmock_PerformImpl(args, std::get<0>(args), std::get<1>(args), std::get<2>(args), - std::get<3>(args), std::get<4>(args), std::get<5>(args), - std::get<6>(args), std::get<7>(args), std::get<8>(args), - std::get<9>(args)); - } -}; - -} // namespace internal -} // namespace testing - -// The ACTION* family of macros can be used in a namespace scope to -// define custom actions easily. The syntax: -// -// ACTION(name) { statements; } -// -// will define an action with the given name that executes the -// statements. The value returned by the statements will be used as -// the return value of the action. Inside the statements, you can -// refer to the K-th (0-based) argument of the mock function by -// 'argK', and refer to its type by 'argK_type'. For example: -// -// ACTION(IncrementArg1) { -// arg1_type temp = arg1; -// return ++(*temp); -// } -// -// allows you to write -// -// ...WillOnce(IncrementArg1()); -// -// You can also refer to the entire argument tuple and its type by -// 'args' and 'args_type', and refer to the mock function type and its -// return type by 'function_type' and 'return_type'. -// -// Note that you don't need to specify the types of the mock function -// arguments. However rest assured that your code is still type-safe: -// you'll get a compiler error if *arg1 doesn't support the ++ -// operator, or if the type of ++(*arg1) isn't compatible with the -// mock function's return type, for example. -// -// Sometimes you'll want to parameterize the action. For that you can use -// another macro: -// -// ACTION_P(name, param_name) { statements; } -// -// For example: -// -// ACTION_P(Add, n) { return arg0 + n; } -// -// will allow you to write: -// -// ...WillOnce(Add(5)); -// -// Note that you don't need to provide the type of the parameter -// either. If you need to reference the type of a parameter named -// 'foo', you can write 'foo_type'. For example, in the body of -// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type -// of 'n'. -// -// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support -// multi-parameter actions. -// -// For the purpose of typing, you can view -// -// ACTION_Pk(Foo, p1, ..., pk) { ... } -// -// as shorthand for -// -// template -// FooActionPk Foo(p1_type p1, ..., pk_type pk) { ... } -// -// In particular, you can provide the template type arguments -// explicitly when invoking Foo(), as in Foo(5, false); -// although usually you can rely on the compiler to infer the types -// for you automatically. You can assign the result of expression -// Foo(p1, ..., pk) to a variable of type FooActionPk. This can be useful when composing actions. -// -// You can also overload actions with different numbers of parameters: -// -// ACTION_P(Plus, a) { ... } -// ACTION_P2(Plus, a, b) { ... } -// -// While it's tempting to always use the ACTION* macros when defining -// a new action, you should also consider implementing ActionInterface -// or using MakePolymorphicAction() instead, especially if you need to -// use the action a lot. While these approaches require more work, -// they give you more control on the types of the mock function -// arguments and the action parameters, which in general leads to -// better compiler error messages that pay off in the long run. They -// also allow overloading actions based on parameter types (as opposed -// to just based on the number of parameters). -// -// CAVEAT: -// -// ACTION*() can only be used in a namespace scope as templates cannot be -// declared inside of a local class. -// Users can, however, define any local functors (e.g. a lambda) that -// can be used as actions. -// -// MORE INFORMATION: -// -// To learn more about using these macros, please search for 'ACTION' on -// https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md - -// An internal macro needed for implementing ACTION*(). -#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\ - const args_type& args GTEST_ATTRIBUTE_UNUSED_, \ - const arg0_type& arg0 GTEST_ATTRIBUTE_UNUSED_, \ - const arg1_type& arg1 GTEST_ATTRIBUTE_UNUSED_, \ - const arg2_type& arg2 GTEST_ATTRIBUTE_UNUSED_, \ - const arg3_type& arg3 GTEST_ATTRIBUTE_UNUSED_, \ - const arg4_type& arg4 GTEST_ATTRIBUTE_UNUSED_, \ - const arg5_type& arg5 GTEST_ATTRIBUTE_UNUSED_, \ - const arg6_type& arg6 GTEST_ATTRIBUTE_UNUSED_, \ - const arg7_type& arg7 GTEST_ATTRIBUTE_UNUSED_, \ - const arg8_type& arg8 GTEST_ATTRIBUTE_UNUSED_, \ - const arg9_type& arg9 GTEST_ATTRIBUTE_UNUSED_ - -// Sometimes you want to give an action explicit template parameters -// that cannot be inferred from its value parameters. ACTION() and -// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that -// and can be viewed as an extension to ACTION() and ACTION_P*(). -// -// The syntax: -// -// ACTION_TEMPLATE(ActionName, -// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m), -// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; } -// -// defines an action template that takes m explicit template -// parameters and n value parameters. name_i is the name of the i-th -// template parameter, and kind_i specifies whether it's a typename, -// an integral constant, or a template. p_i is the name of the i-th -// value parameter. -// -// Example: -// -// // DuplicateArg(output) converts the k-th argument of the mock -// // function to type T and copies it to *output. -// ACTION_TEMPLATE(DuplicateArg, -// HAS_2_TEMPLATE_PARAMS(int, k, typename, T), -// AND_1_VALUE_PARAMS(output)) { -// *output = T(::std::get(args)); -// } -// ... -// int n; -// EXPECT_CALL(mock, Foo(_, _)) -// .WillOnce(DuplicateArg<1, unsigned char>(&n)); -// -// To create an instance of an action template, write: -// -// ActionName(v1, ..., v_n) -// -// where the ts are the template arguments and the vs are the value -// arguments. The value argument types are inferred by the compiler. -// If you want to explicitly specify the value argument types, you can -// provide additional template arguments: -// -// ActionName(v1, ..., v_n) -// -// where u_i is the desired type of v_i. -// -// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the -// number of value parameters, but not on the number of template -// parameters. Without the restriction, the meaning of the following -// is unclear: -// -// OverloadedAction(x); -// -// Are we using a single-template-parameter action where 'bool' refers -// to the type of x, or are we using a two-template-parameter action -// where the compiler is asked to infer the type of x? -// -// Implementation notes: -// -// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and -// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for -// implementing ACTION_TEMPLATE. The main trick we use is to create -// new macro invocations when expanding a macro. For example, we have -// -// #define ACTION_TEMPLATE(name, template_params, value_params) -// ... GMOCK_INTERNAL_DECL_##template_params ... -// -// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...) -// to expand to -// -// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ... -// -// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the -// preprocessor will continue to expand it to -// -// ... typename T ... -// -// This technique conforms to the C++ standard and is portable. It -// allows us to implement action templates using O(N) code, where N is -// the maximum number of template/value parameters supported. Without -// using it, we'd have to devote O(N^2) amount of code to implement all -// combinations of m and n. - -// Declares the template parameters. -#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0 -#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1) kind0 name0, kind1 name1 -#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2) kind0 name0, kind1 name1, kind2 name2 -#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \ - kind3 name3 -#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \ - kind2 name2, kind3 name3, kind4 name4 -#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \ - kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5 -#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ - kind5 name5, kind6 name6 -#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \ - kind4 name4, kind5 name5, kind6 name6, kind7 name7 -#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \ - kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \ - kind8 name8 -#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \ - kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \ - kind6 name6, kind7 name7, kind8 name8, kind9 name9 - -// Lists the template parameters. -#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0 -#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1) name0, name1 -#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2) name0, name1, name2 -#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3) name0, name1, name2, name3 -#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \ - name4 -#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \ - name2, name3, name4, name5 -#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6) name0, name1, name2, name3, name4, name5, name6 -#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7 -#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \ - name6, name7, name8 -#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \ - name3, name4, name5, name6, name7, name8, name9 - -// Declares the types of value parameters. -#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \ - typename p0##_type, typename p1##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \ - typename p0##_type, typename p1##_type, typename p2##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type, typename p7##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type, typename p7##_type, typename p8##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \ - typename p2##_type, typename p3##_type, typename p4##_type, \ - typename p5##_type, typename p6##_type, typename p7##_type, \ - typename p8##_type, typename p9##_type - -// Initializes the value parameters. -#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\ - () -#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\ - (p0##_type gmock_p0) : p0(::std::move(gmock_p0)) -#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\ - (p0##_type gmock_p0, p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)) -#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\ - (p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)) -#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)) -#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)) -#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)) -#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)) -#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)) -#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)) -#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ - p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \ - p9(::std::move(gmock_p9)) - -// Declares the fields for storing the value parameters. -#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0; -#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \ - p1##_type p1; -#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \ - p1##_type p1; p2##_type p2; -#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \ - p1##_type p1; p2##_type p2; p3##_type p3; -#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ - p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; -#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ - p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; -#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; p6##_type p6; -#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; p6##_type p6; p7##_type p7; -#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ - p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; -#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ - p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \ - p9##_type p9; - -// Lists the value parameters. -#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0 -#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1 -#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2 -#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3 -#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \ - p2, p3, p4 -#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \ - p1, p2, p3, p4, p5 -#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0, p1, p2, p3, p4, p5, p6 -#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0, p1, p2, p3, p4, p5, p6, p7 -#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8 -#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 - -// Lists the value parameter types. -#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \ - p1##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \ - p1##_type, p2##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ - p0##_type, p1##_type, p2##_type, p3##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ - p0##_type, p1##_type, p2##_type, p3##_type, p4##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ - p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ - p6##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type, p8##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type, p8##_type, p9##_type - -// Declares the value parameters. -#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0 -#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \ - p1##_type p1 -#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \ - p1##_type p1, p2##_type p2 -#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \ - p1##_type p1, p2##_type p2, p3##_type p3 -#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ - p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4 -#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ - p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5 -#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5, p6##_type p6 -#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5, p6##_type p6, p7##_type p7 -#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8 -#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ - p9##_type p9 - -// The suffix of the class template implementing the action template. -#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS() -#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P -#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2 -#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3 -#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4 -#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5 -#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6 -#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7 -#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) P8 -#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) P9 -#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) P10 - -// The name of the class template implementing the action template. -#define GMOCK_ACTION_CLASS_(name, value_params)\ - GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params) - -#define ACTION_TEMPLATE(name, template_params, value_params)\ - template \ - class GMOCK_ACTION_CLASS_(name, value_params) {\ - public:\ - explicit GMOCK_ACTION_CLASS_(name, value_params)\ - GMOCK_INTERNAL_INIT_##value_params {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(\ - new gmock_Impl(GMOCK_INTERNAL_LIST_##value_params));\ - }\ - GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ - };\ - template \ - inline GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ - GMOCK_INTERNAL_DECL_##value_params) {\ - return GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ - GMOCK_INTERNAL_LIST_##value_params);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::\ - gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION(name)\ - class name##Action {\ - public:\ - name##Action() {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl() {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl());\ - }\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##Action);\ - };\ - inline name##Action name() {\ - return name##Action();\ - }\ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##Action::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P(name, p0)\ - template \ - class name##ActionP {\ - public:\ - explicit name##ActionP(p0##_type gmock_p0) : \ - p0(::std::forward(gmock_p0)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - explicit gmock_Impl(p0##_type gmock_p0) : \ - p0(::std::forward(gmock_p0)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0));\ - }\ - p0##_type p0;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP);\ - };\ - template \ - inline name##ActionP name(p0##_type p0) {\ - return name##ActionP(p0);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P2(name, p0, p1)\ - template \ - class name##ActionP2 {\ - public:\ - name##ActionP2(p0##_type gmock_p0, \ - p1##_type gmock_p1) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, \ - p1##_type gmock_p1) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP2);\ - };\ - template \ - inline name##ActionP2 name(p0##_type p0, \ - p1##_type p1) {\ - return name##ActionP2(p0, p1);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP2::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P3(name, p0, p1, p2)\ - template \ - class name##ActionP3 {\ - public:\ - name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP3);\ - };\ - template \ - inline name##ActionP3 name(p0##_type p0, \ - p1##_type p1, p2##_type p2) {\ - return name##ActionP3(p0, p1, p2);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP3::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P4(name, p0, p1, p2, p3)\ - template \ - class name##ActionP4 {\ - public:\ - name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, \ - p3##_type gmock_p3) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP4);\ - };\ - template \ - inline name##ActionP4 name(p0##_type p0, p1##_type p1, p2##_type p2, \ - p3##_type p3) {\ - return name##ActionP4(p0, p1, \ - p2, p3);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP4::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P5(name, p0, p1, p2, p3, p4)\ - template \ - class name##ActionP5 {\ - public:\ - name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, \ - p4##_type gmock_p4) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, \ - p4##_type gmock_p4) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP5);\ - };\ - template \ - inline name##ActionP5 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4) {\ - return name##ActionP5(p0, p1, p2, p3, p4);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP5::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\ - template \ - class name##ActionP6 {\ - public:\ - name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP6);\ - };\ - template \ - inline name##ActionP6 name(p0##_type p0, p1##_type p1, p2##_type p2, \ - p3##_type p3, p4##_type p4, p5##_type p5) {\ - return name##ActionP6(p0, p1, p2, p3, p4, p5);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP6::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\ - template \ - class name##ActionP7 {\ - public:\ - name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, \ - p6##_type gmock_p6) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP7);\ - };\ - template \ - inline name##ActionP7 name(p0##_type p0, p1##_type p1, \ - p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ - p6##_type p6) {\ - return name##ActionP7(p0, p1, p2, p3, p4, p5, p6);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP7::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\ - template \ - class name##ActionP8 {\ - public:\ - name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, \ - p7##_type gmock_p7) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)), \ - p7(::std::forward(gmock_p7)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, \ - p7##_type gmock_p7) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)), \ - p7(::std::forward(gmock_p7)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6, p7));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP8);\ - };\ - template \ - inline name##ActionP8 name(p0##_type p0, \ - p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ - p6##_type p6, p7##_type p7) {\ - return name##ActionP8(p0, p1, p2, p3, p4, p5, \ - p6, p7);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP8::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\ - template \ - class name##ActionP9 {\ - public:\ - name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)), \ - p7(::std::forward(gmock_p7)), \ - p8(::std::forward(gmock_p8)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)), \ - p7(::std::forward(gmock_p7)), \ - p8(::std::forward(gmock_p8)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP9);\ - };\ - template \ - inline name##ActionP9 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ - p8##_type p8) {\ - return name##ActionP9(p0, p1, p2, \ - p3, p4, p5, p6, p7, p8);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP9::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -#define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\ - template \ - class name##ActionP10 {\ - public:\ - name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8, \ - p9##_type gmock_p9) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)), \ - p7(::std::forward(gmock_p7)), \ - p8(::std::forward(gmock_p8)), \ - p9(::std::forward(gmock_p9)) {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ - p9##_type gmock_p9) : p0(::std::forward(gmock_p0)), \ - p1(::std::forward(gmock_p1)), \ - p2(::std::forward(gmock_p2)), \ - p3(::std::forward(gmock_p3)), \ - p4(::std::forward(gmock_p4)), \ - p5(::std::forward(gmock_p5)), \ - p6(::std::forward(gmock_p6)), \ - p7(::std::forward(gmock_p7)), \ - p8(::std::forward(gmock_p8)), \ - p9(::std::forward(gmock_p9)) {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(const args_type& args, \ - const arg0_type& arg0, const arg1_type& arg1, \ - const arg2_type& arg2, const arg3_type& arg3, \ - const arg4_type& arg4, const arg5_type& arg5, \ - const arg6_type& arg6, const arg7_type& arg7, \ - const arg8_type& arg8, const arg9_type& arg9) const;\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - p9##_type p9;\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9));\ - }\ - p0##_type p0;\ - p1##_type p1;\ - p2##_type p2;\ - p3##_type p3;\ - p4##_type p4;\ - p5##_type p5;\ - p6##_type p6;\ - p7##_type p7;\ - p8##_type p8;\ - p9##_type p9;\ - private:\ - GTEST_DISALLOW_ASSIGN_(name##ActionP10);\ - };\ - template \ - inline name##ActionP10 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ - p9##_type p9) {\ - return name##ActionP10(p0, \ - p1, p2, p3, p4, p5, p6, p7, p8, p9);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - name##ActionP10::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -namespace testing { - - -// The ACTION*() macros trigger warning C4100 (unreferenced formal -// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in -// the macro definition, as the warnings are generated when the macro -// is expanded and macro expansion cannot contain #pragma. Therefore -// we suppress them here. -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -#endif - -// Various overloads for InvokeArgument(). -// -// The InvokeArgument(a1, a2, ..., a_k) action invokes the N-th -// (0-based) argument, which must be a k-ary callable, of the mock -// function, with arguments a1, a2, ..., a_k. -// -// Notes: -// -// 1. The arguments are passed by value by default. If you need to -// pass an argument by reference, wrap it inside ByRef(). For -// example, -// -// InvokeArgument<1>(5, string("Hello"), ByRef(foo)) -// -// passes 5 and string("Hello") by value, and passes foo by -// reference. -// -// 2. If the callable takes an argument by reference but ByRef() is -// not used, it will receive the reference to a copy of the value, -// instead of the original value. For example, when the 0-th -// argument of the mock function takes a const string&, the action -// -// InvokeArgument<0>(string("Hello")) -// -// makes a copy of the temporary string("Hello") object and passes a -// reference of the copy, instead of the original temporary object, -// to the callable. This makes it easy for a user to define an -// InvokeArgument action from temporary values and have it performed -// later. - -namespace internal { -namespace invoke_argument { - -// 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. -// Overloads for other custom-callables are provided in the -// internal/custom/callback-actions.h header. - -template -R InvokeArgumentAdl(AdlTag, F f) { - return f(); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1) { - return f(a1); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2) { - return f(a1, a2); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3) { - return f(a1, a2, a3); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4) { - return f(a1, a2, a3, a4); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { - return f(a1, a2, a3, a4, a5); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { - return f(a1, a2, a3, a4, a5, a6); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7) { - return f(a1, a2, a3, a4, a5, a6, a7); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7, A8 a8) { - return f(a1, a2, a3, a4, a5, a6, a7, a8); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7, A8 a8, A9 a9) { - return f(a1, a2, a3, a4, a5, a6, a7, a8, a9); -} -template -R InvokeArgumentAdl(AdlTag, F f, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, - A7 a7, A8 a8, A9 a9, A10 a10) { - return f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); -} -} // namespace invoke_argument -} // namespace internal - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_0_VALUE_PARAMS()) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args)); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_1_VALUE_PARAMS(p0)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_2_VALUE_PARAMS(p0, p1)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_3_VALUE_PARAMS(p0, p1, p2)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2, p3); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2, p3, p4); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2, p3, p4, p5); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2, p3, p4, p5, p6); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2, p3, p4, p5, p6, p7); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2, p3, p4, p5, p6, p7, p8); -} - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); -} - -// Various overloads for ReturnNew(). -// -// The ReturnNew(a1, a2, ..., a_k) action returns a pointer to a new -// instance of type T, constructed on the heap with constructor arguments -// a1, a2, ..., and a_k. The caller assumes ownership of the returned value. -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_0_VALUE_PARAMS()) { - return new T(); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_1_VALUE_PARAMS(p0)) { - return new T(p0); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_2_VALUE_PARAMS(p0, p1)) { - return new T(p0, p1); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_3_VALUE_PARAMS(p0, p1, p2)) { - return new T(p0, p1, p2); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { - return new T(p0, p1, p2, p3); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { - return new T(p0, p1, p2, p3, p4); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { - return new T(p0, p1, p2, p3, p4, p5); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { - return new T(p0, p1, p2, p3, p4, p5, p6); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); -} - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -} // 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_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h.pump mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h.pump --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h.pump 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-actions.h.pump 1970-01-01 00:00:00.000000000 +0000 @@ -1,627 +0,0 @@ -$$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert it to -$$ gmock-generated-actions.h. -$$ -$var n = 10 $$ The maximum arity we support. -$$}} This meta comment fixes auto-indentation in editors. -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used variadic actions. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ - -#include -#include - -#include "gmock/gmock-actions.h" -#include "gmock/internal/gmock-port.h" - -namespace testing { -namespace internal { - -// A macro from the ACTION* family (defined later in this file) -// defines an action that can be used in a mock function. Typically, -// these actions only care about a subset of the arguments of the mock -// function. For example, if such an action only uses the second -// argument, it can be used in any mock function that takes >= 2 -// arguments where the type of the second argument is compatible. -// -// Therefore, the action implementation must be prepared to take more -// arguments than it needs. The ExcessiveArg type is used to -// represent those excessive arguments. In order to keep the compiler -// error messages tractable, we define it in the testing namespace -// instead of testing::internal. However, this is an INTERNAL TYPE -// and subject to change without notice, so a user MUST NOT USE THIS -// TYPE DIRECTLY. -struct ExcessiveArg {}; - -// A helper class needed for implementing the ACTION* macros. -template -class ActionHelper { - public: -$range i 0..n -$for i - -[[ -$var template = [[$if i==0 [[]] $else [[ -$range j 0..i-1 - template <$for j, [[typename A$j]]> -]]]] -$range j 0..i-1 -$var As = [[$for j, [[A$j]]]] -$var as = [[$for j, [[std::get<$j>(args)]]]] -$range k 1..n-i -$var eas = [[$for k, [[ExcessiveArg()]]]] -$var arg_list = [[$if (i==0) | (i==n) [[$as$eas]] $else [[$as, $eas]]]] -$template - static Result Perform(Impl* impl, const ::std::tuple<$As>& args) { - return impl->template gmock_PerformImpl<$As>(args, $arg_list); - } - -]] -}; - -} // namespace internal -} // namespace testing - -// The ACTION* family of macros can be used in a namespace scope to -// define custom actions easily. The syntax: -// -// ACTION(name) { statements; } -// -// will define an action with the given name that executes the -// statements. The value returned by the statements will be used as -// the return value of the action. Inside the statements, you can -// refer to the K-th (0-based) argument of the mock function by -// 'argK', and refer to its type by 'argK_type'. For example: -// -// ACTION(IncrementArg1) { -// arg1_type temp = arg1; -// return ++(*temp); -// } -// -// allows you to write -// -// ...WillOnce(IncrementArg1()); -// -// You can also refer to the entire argument tuple and its type by -// 'args' and 'args_type', and refer to the mock function type and its -// return type by 'function_type' and 'return_type'. -// -// Note that you don't need to specify the types of the mock function -// arguments. However rest assured that your code is still type-safe: -// you'll get a compiler error if *arg1 doesn't support the ++ -// operator, or if the type of ++(*arg1) isn't compatible with the -// mock function's return type, for example. -// -// Sometimes you'll want to parameterize the action. For that you can use -// another macro: -// -// ACTION_P(name, param_name) { statements; } -// -// For example: -// -// ACTION_P(Add, n) { return arg0 + n; } -// -// will allow you to write: -// -// ...WillOnce(Add(5)); -// -// Note that you don't need to provide the type of the parameter -// either. If you need to reference the type of a parameter named -// 'foo', you can write 'foo_type'. For example, in the body of -// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type -// of 'n'. -// -// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P$n to support -// multi-parameter actions. -// -// For the purpose of typing, you can view -// -// ACTION_Pk(Foo, p1, ..., pk) { ... } -// -// as shorthand for -// -// template -// FooActionPk Foo(p1_type p1, ..., pk_type pk) { ... } -// -// In particular, you can provide the template type arguments -// explicitly when invoking Foo(), as in Foo(5, false); -// although usually you can rely on the compiler to infer the types -// for you automatically. You can assign the result of expression -// Foo(p1, ..., pk) to a variable of type FooActionPk. This can be useful when composing actions. -// -// You can also overload actions with different numbers of parameters: -// -// ACTION_P(Plus, a) { ... } -// ACTION_P2(Plus, a, b) { ... } -// -// While it's tempting to always use the ACTION* macros when defining -// a new action, you should also consider implementing ActionInterface -// or using MakePolymorphicAction() instead, especially if you need to -// use the action a lot. While these approaches require more work, -// they give you more control on the types of the mock function -// arguments and the action parameters, which in general leads to -// better compiler error messages that pay off in the long run. They -// also allow overloading actions based on parameter types (as opposed -// to just based on the number of parameters). -// -// CAVEAT: -// -// ACTION*() can only be used in a namespace scope as templates cannot be -// declared inside of a local class. -// Users can, however, define any local functors (e.g. a lambda) that -// can be used as actions. -// -// MORE INFORMATION: -// -// To learn more about using these macros, please search for 'ACTION' on -// https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md - -$range i 0..n -$range k 0..n-1 - -// An internal macro needed for implementing ACTION*(). -#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\ - const args_type& args GTEST_ATTRIBUTE_UNUSED_ -$for k [[, \ - const arg$k[[]]_type& arg$k GTEST_ATTRIBUTE_UNUSED_]] - - -// Sometimes you want to give an action explicit template parameters -// that cannot be inferred from its value parameters. ACTION() and -// ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that -// and can be viewed as an extension to ACTION() and ACTION_P*(). -// -// The syntax: -// -// ACTION_TEMPLATE(ActionName, -// HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m), -// AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; } -// -// defines an action template that takes m explicit template -// parameters and n value parameters. name_i is the name of the i-th -// template parameter, and kind_i specifies whether it's a typename, -// an integral constant, or a template. p_i is the name of the i-th -// value parameter. -// -// Example: -// -// // DuplicateArg(output) converts the k-th argument of the mock -// // function to type T and copies it to *output. -// ACTION_TEMPLATE(DuplicateArg, -// HAS_2_TEMPLATE_PARAMS(int, k, typename, T), -// AND_1_VALUE_PARAMS(output)) { -// *output = T(::std::get(args)); -// } -// ... -// int n; -// EXPECT_CALL(mock, Foo(_, _)) -// .WillOnce(DuplicateArg<1, unsigned char>(&n)); -// -// To create an instance of an action template, write: -// -// ActionName(v1, ..., v_n) -// -// where the ts are the template arguments and the vs are the value -// arguments. The value argument types are inferred by the compiler. -// If you want to explicitly specify the value argument types, you can -// provide additional template arguments: -// -// ActionName(v1, ..., v_n) -// -// where u_i is the desired type of v_i. -// -// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the -// number of value parameters, but not on the number of template -// parameters. Without the restriction, the meaning of the following -// is unclear: -// -// OverloadedAction(x); -// -// Are we using a single-template-parameter action where 'bool' refers -// to the type of x, or are we using a two-template-parameter action -// where the compiler is asked to infer the type of x? -// -// Implementation notes: -// -// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and -// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for -// implementing ACTION_TEMPLATE. The main trick we use is to create -// new macro invocations when expanding a macro. For example, we have -// -// #define ACTION_TEMPLATE(name, template_params, value_params) -// ... GMOCK_INTERNAL_DECL_##template_params ... -// -// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...) -// to expand to -// -// ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ... -// -// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the -// preprocessor will continue to expand it to -// -// ... typename T ... -// -// This technique conforms to the C++ standard and is portable. It -// allows us to implement action templates using O(N) code, where N is -// the maximum number of template/value parameters supported. Without -// using it, we'd have to devote O(N^2) amount of code to implement all -// combinations of m and n. - -// Declares the template parameters. - -$range j 1..n -$for j [[ -$range m 0..j-1 -#define GMOCK_INTERNAL_DECL_HAS_$j[[]] -_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[kind$m name$m]] - - -]] - -// Lists the template parameters. - -$for j [[ -$range m 0..j-1 -#define GMOCK_INTERNAL_LIST_HAS_$j[[]] -_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[name$m]] - - -]] - -// Declares the types of value parameters. - -$for i [[ -$range j 0..i-1 -#define GMOCK_INTERNAL_DECL_TYPE_AND_$i[[]] -_VALUE_PARAMS($for j, [[p$j]]) $for j [[, typename p$j##_type]] - - -]] - -// Initializes the value parameters. - -$for i [[ -$range j 0..i-1 -#define GMOCK_INTERNAL_INIT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])\ - ($for j, [[p$j##_type gmock_p$j]])$if i>0 [[ : ]]$for j, [[p$j(::std::move(gmock_p$j))]] - - -]] - -// Declares the fields for storing the value parameters. - -$for i [[ -$range j 0..i-1 -#define GMOCK_INTERNAL_DEFN_AND_$i[[]] -_VALUE_PARAMS($for j, [[p$j]]) $for j [[p$j##_type p$j; ]] - - -]] - -// Lists the value parameters. - -$for i [[ -$range j 0..i-1 -#define GMOCK_INTERNAL_LIST_AND_$i[[]] -_VALUE_PARAMS($for j, [[p$j]]) $for j, [[p$j]] - - -]] - -// Lists the value parameter types. - -$for i [[ -$range j 0..i-1 -#define GMOCK_INTERNAL_LIST_TYPE_AND_$i[[]] -_VALUE_PARAMS($for j, [[p$j]]) $for j [[, p$j##_type]] - - -]] - -// Declares the value parameters. - -$for i [[ -$range j 0..i-1 -#define GMOCK_INTERNAL_DECL_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]] -$for j, [[p$j##_type p$j]] - - -]] - -// The suffix of the class template implementing the action template. -$for i [[ - - -$range j 0..i-1 -#define GMOCK_INTERNAL_COUNT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]] -$if i==1 [[P]] $elif i>=2 [[P$i]] -]] - - -// The name of the class template implementing the action template. -#define GMOCK_ACTION_CLASS_(name, value_params)\ - GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params) - -$range k 0..n-1 - -#define ACTION_TEMPLATE(name, template_params, value_params)\ - template \ - class GMOCK_ACTION_CLASS_(name, value_params) {\ - public:\ - explicit GMOCK_ACTION_CLASS_(name, value_params)\ - GMOCK_INTERNAL_INIT_##value_params {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template <$for k, [[typename arg$k[[]]_type]]>\ - return_type gmock_PerformImpl(const args_type& args[[]] -$for k [[, const arg$k[[]]_type& arg$k]]) const;\ - GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(\ - new gmock_Impl(GMOCK_INTERNAL_LIST_##value_params));\ - }\ - GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ - };\ - template \ - inline GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ - GMOCK_INTERNAL_DECL_##value_params) {\ - return GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ - GMOCK_INTERNAL_LIST_##value_params);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::\ - gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - -$for i - -[[ -$var template = [[$if i==0 [[]] $else [[ -$range j 0..i-1 - - template <$for j, [[typename p$j##_type]]>\ -]]]] -$var class_name = [[name##Action[[$if i==0 [[]] $elif i==1 [[P]] - $else [[P$i]]]]]] -$range j 0..i-1 -$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]] -$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]] -$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::std::forward(gmock_p$j))]]]]]] -$var param_field_decls = [[$for j -[[ - - p$j##_type p$j;\ -]]]] -$var param_field_decls2 = [[$for j -[[ - - p$j##_type p$j;\ -]]]] -$var params = [[$for j, [[p$j]]]] -$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]] -$var typename_arg_types = [[$for k, [[typename arg$k[[]]_type]]]] -$var arg_types_and_names = [[$for k, [[const arg$k[[]]_type& arg$k]]]] -$var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]] - $else [[ACTION_P$i]]]] - -#define $macro_name(name$for j [[, p$j]])\$template - class $class_name {\ - public:\ - [[$if i==1 [[explicit ]]]]$class_name($ctor_param_list)$inits {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - [[$if i==1 [[explicit ]]]]gmock_Impl($ctor_param_list)$inits {}\ - virtual return_type Perform(const args_type& args) {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template <$typename_arg_types>\ - return_type gmock_PerformImpl(const args_type& args, [[]] -$arg_types_and_names) const;\$param_field_decls - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(new gmock_Impl($params));\ - }\$param_field_decls2 - private:\ - GTEST_DISALLOW_ASSIGN_($class_name);\ - };\$template - inline $class_name$param_types name($param_types_and_names) {\ - return $class_name$param_types($params);\ - }\$template - template \ - template <$typename_arg_types>\ - typename ::testing::internal::Function::Result\ - $class_name$param_types::gmock_Impl::gmock_PerformImpl(\ - GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const -]] -$$ } // This meta comment fixes auto-indentation in Emacs. It won't -$$ // show up in the generated code. - - -namespace testing { - - -// The ACTION*() macros trigger warning C4100 (unreferenced formal -// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in -// the macro definition, as the warnings are generated when the macro -// is expanded and macro expansion cannot contain #pragma. Therefore -// we suppress them here. -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -#endif - -// Various overloads for InvokeArgument(). -// -// The InvokeArgument(a1, a2, ..., a_k) action invokes the N-th -// (0-based) argument, which must be a k-ary callable, of the mock -// function, with arguments a1, a2, ..., a_k. -// -// Notes: -// -// 1. The arguments are passed by value by default. If you need to -// pass an argument by reference, wrap it inside ByRef(). For -// example, -// -// InvokeArgument<1>(5, string("Hello"), ByRef(foo)) -// -// passes 5 and string("Hello") by value, and passes foo by -// reference. -// -// 2. If the callable takes an argument by reference but ByRef() is -// not used, it will receive the reference to a copy of the value, -// instead of the original value. For example, when the 0-th -// argument of the mock function takes a const string&, the action -// -// InvokeArgument<0>(string("Hello")) -// -// makes a copy of the temporary string("Hello") object and passes a -// reference of the copy, instead of the original temporary object, -// to the callable. This makes it easy for a user to define an -// InvokeArgument action from temporary values and have it performed -// later. - -namespace internal { -namespace invoke_argument { - -// 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. -// Overloads for other custom-callables are provided in the -// internal/custom/callback-actions.h header. - -$range i 0..n -$for i -[[ -$range j 1..i - -template -R InvokeArgumentAdl(AdlTag, F f[[$for j [[, A$j a$j]]]]) { - return f([[$for j, [[a$j]]]]); -} -]] - -} // namespace invoke_argument -} // namespace internal - -$range i 0..n -$for i [[ -$range j 0..i-1 - -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), - AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) { - using internal::invoke_argument::InvokeArgumentAdl; - return InvokeArgumentAdl( - internal::invoke_argument::AdlTag(), - ::std::get(args)$for j [[, p$j]]); -} - -]] - -// Various overloads for ReturnNew(). -// -// The ReturnNew(a1, a2, ..., a_k) action returns a pointer to a new -// instance of type T, constructed on the heap with constructor arguments -// a1, a2, ..., and a_k. The caller assumes ownership of the returned value. -$range i 0..n -$for i [[ -$range j 0..i-1 -$var ps = [[$for j, [[p$j]]]] - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_$i[[]]_VALUE_PARAMS($ps)) { - return new T($ps); -} - -]] - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -} // 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_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,752 +0,0 @@ -// This file was GENERATED by command: -// pump.py gmock-generated-function-mockers.h.pump -// DO NOT EDIT BY HAND!!! - -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements function mockers of various arities. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ - -#include -#include - -#include "gmock/gmock-spec-builders.h" -#include "gmock/internal/gmock-internal-utils.h" - -namespace testing { -namespace internal { -// Removes the given pointer; this is a helper for the expectation setter method -// for parameterless matchers. -// -// We want to make sure that the user cannot set a parameterless expectation on -// overloaded methods, including methods which are overloaded on const. Example: -// -// class MockClass { -// MOCK_METHOD0(GetName, string&()); -// MOCK_CONST_METHOD0(GetName, const string&()); -// }; -// -// TEST() { -// // This should be an error, as it's not clear which overload is expected. -// EXPECT_CALL(mock, GetName).WillOnce(ReturnRef(value)); -// } -// -// Here are the generated expectation-setter methods: -// -// class MockClass { -// // Overload 1 -// MockSpec gmock_GetName() { ... } -// // Overload 2. Declared const so that the compiler will generate an -// // error when trying to resolve between this and overload 4 in -// // 'gmock_GetName(WithoutMatchers(), nullptr)'. -// MockSpec gmock_GetName( -// const WithoutMatchers&, const Function*) const { -// // Removes const from this, calls overload 1 -// return AdjustConstness_(this)->gmock_GetName(); -// } -// -// // Overload 3 -// const string& gmock_GetName() const { ... } -// // Overload 4 -// MockSpec gmock_GetName( -// const WithoutMatchers&, const Function*) const { -// // Does not remove const, calls overload 3 -// return AdjustConstness_const(this)->gmock_GetName(); -// } -// } -// -template -const MockType* AdjustConstness_const(const MockType* mock) { - return mock; -} - -// Removes const from and returns the given pointer; this is a helper for the -// expectation setter method for parameterless matchers. -template -MockType* AdjustConstness_(const MockType* mock) { - return const_cast(mock); -} - -} // namespace internal - -// The style guide prohibits "using" statements in a namespace scope -// inside a header file. However, the FunctionMocker class template -// is meant to be defined in the ::testing namespace. The following -// line is just a trick for working around a bug in MSVC 8.0, which -// cannot handle it if we define FunctionMocker in ::testing. -using internal::FunctionMocker; - -// GMOCK_RESULT_(tn, F) expands to the result type of function type F. -// We define this as a variadic macro in case F contains unprotected -// commas (the same reason that we use variadic macros in other places -// in this file). -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_RESULT_(tn, ...) \ - tn ::testing::internal::Function<__VA_ARGS__>::Result - -// The type of argument N of the given function type. -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_ARG_(tn, N, ...) \ - tn ::testing::internal::Function<__VA_ARGS__>::template Arg::type - -// The matcher type for argument N of the given function type. -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_MATCHER_(tn, N, ...) \ - const ::testing::Matcher& - -// The variable for mocking the given method. -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_MOCKER_(arity, constness, Method) \ - GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \ - static_assert(0 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - ) constness { \ - GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(0, constness, Method).Invoke(); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method() constness { \ - GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(0, constness, Method).With(); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \ - static_assert(1 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \ - GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(1, constness, \ - Method).Invoke(::std::forward(gmock_a1)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \ - GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \ - static_assert(2 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2) constness { \ - GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(2, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \ - GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \ - static_assert(3 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, \ - __VA_ARGS__) gmock_a3) constness { \ - GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(3, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \ - GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \ - static_assert(4 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \ - GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(4, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3), \ - ::std::forward(gmock_a4)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \ - GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3, gmock_a4); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \ - static_assert(5 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \ - __VA_ARGS__) gmock_a5) constness { \ - GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(5, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3), \ - ::std::forward(gmock_a4), \ - ::std::forward(gmock_a5)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ - GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \ - GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3, gmock_a4, gmock_a5); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \ - static_assert(6 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \ - __VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, \ - __VA_ARGS__) gmock_a6) constness { \ - GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(6, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3), \ - ::std::forward(gmock_a4), \ - ::std::forward(gmock_a5), \ - ::std::forward(gmock_a6)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ - GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ - GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \ - GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3, gmock_a4, gmock_a5, gmock_a6); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \ - static_assert(7 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \ - __VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \ - GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(7, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3), \ - ::std::forward(gmock_a4), \ - ::std::forward(gmock_a5), \ - ::std::forward(gmock_a6), \ - ::std::forward(gmock_a7)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ - GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ - GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \ - GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \ - static_assert(8 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \ - __VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(tn, 8, \ - __VA_ARGS__) gmock_a8) constness { \ - GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(8, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3), \ - ::std::forward(gmock_a4), \ - ::std::forward(gmock_a5), \ - ::std::forward(gmock_a6), \ - ::std::forward(gmock_a7), \ - ::std::forward(gmock_a8)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ - GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ - GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \ - GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \ - GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \ - static_assert(9 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \ - __VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(tn, 8, \ - __VA_ARGS__) gmock_a8, GMOCK_ARG_(tn, 9, \ - __VA_ARGS__) gmock_a9) constness { \ - GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(9, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3), \ - ::std::forward(gmock_a4), \ - ::std::forward(gmock_a5), \ - ::std::forward(gmock_a6), \ - ::std::forward(gmock_a7), \ - ::std::forward(gmock_a8), \ - ::std::forward(gmock_a9)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ - GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ - GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \ - GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \ - GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \ - GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \ - gmock_a9); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \ - Method) - -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \ - static_assert(10 == \ - ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, \ - "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \ - __VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \ - __VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(tn, 8, \ - __VA_ARGS__) gmock_a8, GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \ - GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \ - GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_(10, constness, \ - Method).Invoke(::std::forward(gmock_a1), \ - ::std::forward(gmock_a2), \ - ::std::forward(gmock_a3), \ - ::std::forward(gmock_a4), \ - ::std::forward(gmock_a5), \ - ::std::forward(gmock_a6), \ - ::std::forward(gmock_a7), \ - ::std::forward(gmock_a8), \ - ::std::forward(gmock_a9), \ - ::std::forward(gmock_a10)); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \ - GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \ - GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \ - GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \ - GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \ - GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \ - GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \ - GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \ - GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \ - GMOCK_MATCHER_(tn, 10, \ - __VA_ARGS__) gmock_a10) constness { \ - GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \ - gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \ - gmock_a10); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method(::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A(), \ - ::testing::A()); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \ - Method) - -#define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__) -#define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__) -#define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__) -#define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__) -#define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__) -#define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__) -#define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__) -#define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__) -#define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__) -#define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__) -#define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__) - -#define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__) - -#define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__) -#define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__) - -#define MOCK_CONST_METHOD0_T(m, ...) \ - GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD1_T(m, ...) \ - GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD2_T(m, ...) \ - GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD3_T(m, ...) \ - GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD4_T(m, ...) \ - GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD5_T(m, ...) \ - GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD6_T(m, ...) \ - GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD7_T(m, ...) \ - GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD8_T(m, ...) \ - GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD9_T(m, ...) \ - GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__) -#define MOCK_CONST_METHOD10_T(m, ...) \ - GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__) - -#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD0_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD1_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD2_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD3_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD4_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD5_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD6_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD7_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD8_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD9_(, , ct, m, __VA_ARGS__) -#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD10_(, , ct, m, __VA_ARGS__) - -#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__) - -#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__) -#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__) - -#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__) -#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__) - -} // namespace testing - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h.pump mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h.pump --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h.pump 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-function-mockers.h.pump 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ -$$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert -$$ it to gmock-generated-function-mockers.h. -$$ -$var n = 10 $$ The maximum arity we support. -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements function mockers of various arities. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ - -#include -#include - -#include "gmock/gmock-spec-builders.h" -#include "gmock/internal/gmock-internal-utils.h" - -namespace testing { -namespace internal { - -$range i 0..n -// Removes the given pointer; this is a helper for the expectation setter method -// for parameterless matchers. -// -// We want to make sure that the user cannot set a parameterless expectation on -// overloaded methods, including methods which are overloaded on const. Example: -// -// class MockClass { -// MOCK_METHOD0(GetName, string&()); -// MOCK_CONST_METHOD0(GetName, const string&()); -// }; -// -// TEST() { -// // This should be an error, as it's not clear which overload is expected. -// EXPECT_CALL(mock, GetName).WillOnce(ReturnRef(value)); -// } -// -// Here are the generated expectation-setter methods: -// -// class MockClass { -// // Overload 1 -// MockSpec gmock_GetName() { ... } -// // Overload 2. Declared const so that the compiler will generate an -// // error when trying to resolve between this and overload 4 in -// // 'gmock_GetName(WithoutMatchers(), nullptr)'. -// MockSpec gmock_GetName( -// const WithoutMatchers&, const Function*) const { -// // Removes const from this, calls overload 1 -// return AdjustConstness_(this)->gmock_GetName(); -// } -// -// // Overload 3 -// const string& gmock_GetName() const { ... } -// // Overload 4 -// MockSpec gmock_GetName( -// const WithoutMatchers&, const Function*) const { -// // Does not remove const, calls overload 3 -// return AdjustConstness_const(this)->gmock_GetName(); -// } -// } -// -template -const MockType* AdjustConstness_const(const MockType* mock) { - return mock; -} - -// Removes const from and returns the given pointer; this is a helper for the -// expectation setter method for parameterless matchers. -template -MockType* AdjustConstness_(const MockType* mock) { - return const_cast(mock); -} - -} // namespace internal - -// The style guide prohibits "using" statements in a namespace scope -// inside a header file. However, the FunctionMocker class template -// is meant to be defined in the ::testing namespace. The following -// line is just a trick for working around a bug in MSVC 8.0, which -// cannot handle it if we define FunctionMocker in ::testing. -using internal::FunctionMocker; - -// GMOCK_RESULT_(tn, F) expands to the result type of function type F. -// We define this as a variadic macro in case F contains unprotected -// commas (the same reason that we use variadic macros in other places -// in this file). -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_RESULT_(tn, ...) \ - tn ::testing::internal::Function<__VA_ARGS__>::Result - -// The type of argument N of the given function type. -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_ARG_(tn, N, ...) \ - tn ::testing::internal::Function<__VA_ARGS__>::template Arg::type - -// The matcher type for argument N of the given function type. -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_MATCHER_(tn, N, ...) \ - const ::testing::Matcher& - -// The variable for mocking the given method. -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_MOCKER_(arity, constness, Method) \ - GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__) - - -$for i [[ -$range j 1..i -$var arg_as = [[$for j, [[GMOCK_ARG_(tn, $j, __VA_ARGS__) gmock_a$j]]]] -$var as = [[$for j, \ - [[::std::forward(gmock_a$j)]]]] -$var matcher_arg_as = [[$for j, \ - [[GMOCK_MATCHER_(tn, $j, __VA_ARGS__) gmock_a$j]]]] -$var matcher_as = [[$for j, [[gmock_a$j]]]] -$var anything_matchers = [[$for j, \ - [[::testing::A()]]]] -// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!! -#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \ - static_assert($i == ::testing::internal::Function<__VA_ARGS__>::ArgumentCount, "MOCK_METHOD must match argument count.");\ - GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \ - $arg_as) constness { \ - GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \ - return GMOCK_MOCKER_($i, constness, Method).Invoke($as); \ - } \ - ::testing::MockSpec<__VA_ARGS__> \ - gmock_##Method($matcher_arg_as) constness { \ - GMOCK_MOCKER_($i, constness, Method).RegisterOwner(this); \ - return GMOCK_MOCKER_($i, constness, Method).With($matcher_as); \ - } \ - ::testing::MockSpec<__VA_ARGS__> gmock_##Method( \ - const ::testing::internal::WithoutMatchers&, \ - constness ::testing::internal::Function<__VA_ARGS__>* ) const { \ - return ::testing::internal::AdjustConstness_##constness(this)-> \ - gmock_##Method($anything_matchers); \ - } \ - mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_($i, constness, Method) - - -]] -$for i [[ -#define MOCK_METHOD$i(m, ...) GMOCK_METHOD$i[[]]_(, , , m, __VA_ARGS__) - -]] - - -$for i [[ -#define MOCK_CONST_METHOD$i(m, ...) GMOCK_METHOD$i[[]]_(, const, , m, __VA_ARGS__) - -]] - - -$for i [[ -#define MOCK_METHOD$i[[]]_T(m, ...) GMOCK_METHOD$i[[]]_(typename, , , m, __VA_ARGS__) - -]] - - -$for i [[ -#define MOCK_CONST_METHOD$i[[]]_T(m, ...) \ - GMOCK_METHOD$i[[]]_(typename, const, , m, __VA_ARGS__) - -]] - - -$for i [[ -#define MOCK_METHOD$i[[]]_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD$i[[]]_(, , ct, m, __VA_ARGS__) - -]] - - -$for i [[ -#define MOCK_CONST_METHOD$i[[]]_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD$i[[]]_(, const, ct, m, __VA_ARGS__) - -]] - - -$for i [[ -#define MOCK_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD$i[[]]_(typename, , ct, m, __VA_ARGS__) - -]] - - -$for i [[ -#define MOCK_CONST_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, ...) \ - GMOCK_METHOD$i[[]]_(typename, const, ct, m, __VA_ARGS__) - -]] - -} // namespace testing - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1097 +0,0 @@ -// This file was GENERATED by command: -// pump.py gmock-generated-matchers.h.pump -// DO NOT EDIT BY HAND!!! - -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used variadic matchers. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ - -#include -#include -#include -#include -#include -#include "gmock/gmock-matchers.h" - -// The MATCHER* family of macros can be used in a namespace scope to -// define custom matchers easily. -// -// Basic Usage -// =========== -// -// The syntax -// -// MATCHER(name, description_string) { statements; } -// -// defines a matcher with the given name that executes the statements, -// which must return a bool to indicate if the match succeeds. Inside -// the statements, you can refer to the value being matched by 'arg', -// and refer to its type by 'arg_type'. -// -// The description string documents what the matcher does, and is used -// to generate the failure message when the match fails. Since a -// MATCHER() is usually defined in a header file shared by multiple -// C++ source files, we require the description to be a C-string -// literal to avoid possible side effects. It can be empty, in which -// case we'll use the sequence of words in the matcher name as the -// description. -// -// For example: -// -// MATCHER(IsEven, "") { return (arg % 2) == 0; } -// -// allows you to write -// -// // Expects mock_foo.Bar(n) to be called where n is even. -// EXPECT_CALL(mock_foo, Bar(IsEven())); -// -// or, -// -// // Verifies that the value of some_expression is even. -// EXPECT_THAT(some_expression, IsEven()); -// -// If the above assertion fails, it will print something like: -// -// Value of: some_expression -// Expected: is even -// Actual: 7 -// -// where the description "is even" is automatically calculated from the -// matcher name IsEven. -// -// Argument Type -// ============= -// -// Note that the type of the value being matched (arg_type) is -// determined by the context in which you use the matcher and is -// supplied to you by the compiler, so you don't need to worry about -// declaring it (nor can you). This allows the matcher to be -// polymorphic. For example, IsEven() can be used to match any type -// where the value of "(arg % 2) == 0" can be implicitly converted to -// a bool. In the "Bar(IsEven())" example above, if method Bar() -// takes an int, 'arg_type' will be int; if it takes an unsigned long, -// 'arg_type' will be unsigned long; and so on. -// -// Parameterizing Matchers -// ======================= -// -// Sometimes you'll want to parameterize the matcher. For that you -// can use another macro: -// -// MATCHER_P(name, param_name, description_string) { statements; } -// -// For example: -// -// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; } -// -// will allow you to write: -// -// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n)); -// -// which may lead to this message (assuming n is 10): -// -// Value of: Blah("a") -// Expected: has absolute value 10 -// Actual: -9 -// -// Note that both the matcher description and its parameter are -// printed, making the message human-friendly. -// -// In the matcher definition body, you can write 'foo_type' to -// reference the type of a parameter named 'foo'. For example, in the -// body of MATCHER_P(HasAbsoluteValue, value) above, you can write -// 'value_type' to refer to the type of 'value'. -// -// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to -// support multi-parameter matchers. -// -// Describing Parameterized Matchers -// ================================= -// -// The last argument to MATCHER*() is a string-typed expression. The -// expression can reference all of the matcher's parameters and a -// special bool-typed variable named 'negation'. When 'negation' is -// false, the expression should evaluate to the matcher's description; -// otherwise it should evaluate to the description of the negation of -// the matcher. For example, -// -// using testing::PrintToString; -// -// MATCHER_P2(InClosedRange, low, hi, -// std::string(negation ? "is not" : "is") + " in range [" + -// PrintToString(low) + ", " + PrintToString(hi) + "]") { -// return low <= arg && arg <= hi; -// } -// ... -// EXPECT_THAT(3, InClosedRange(4, 6)); -// EXPECT_THAT(3, Not(InClosedRange(2, 4))); -// -// would generate two failures that contain the text: -// -// Expected: is in range [4, 6] -// ... -// Expected: is not in range [2, 4] -// -// If you specify "" as the description, the failure message will -// contain the sequence of words in the matcher name followed by the -// parameter values printed as a tuple. For example, -// -// MATCHER_P2(InClosedRange, low, hi, "") { ... } -// ... -// EXPECT_THAT(3, InClosedRange(4, 6)); -// EXPECT_THAT(3, Not(InClosedRange(2, 4))); -// -// would generate two failures that contain the text: -// -// Expected: in closed range (4, 6) -// ... -// Expected: not (in closed range (2, 4)) -// -// Types of Matcher Parameters -// =========================== -// -// For the purpose of typing, you can view -// -// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... } -// -// as shorthand for -// -// template -// FooMatcherPk -// Foo(p1_type p1, ..., pk_type pk) { ... } -// -// When you write Foo(v1, ..., vk), the compiler infers the types of -// the parameters v1, ..., and vk for you. If you are not happy with -// the result of the type inference, you can specify the types by -// explicitly instantiating the template, as in Foo(5, -// false). As said earlier, you don't get to (or need to) specify -// 'arg_type' as that's determined by the context in which the matcher -// is used. You can assign the result of expression Foo(p1, ..., pk) -// to a variable of type FooMatcherPk. This -// can be useful when composing matchers. -// -// While you can instantiate a matcher template with reference types, -// passing the parameters by pointer usually makes your code more -// readable. If, however, you still want to pass a parameter by -// reference, be aware that in the failure message generated by the -// matcher you will see the value of the referenced object but not its -// address. -// -// Explaining Match Results -// ======================== -// -// Sometimes the matcher description alone isn't enough to explain why -// the match has failed or succeeded. For example, when expecting a -// long string, it can be very helpful to also print the diff between -// the expected string and the actual one. To achieve that, you can -// optionally stream additional information to a special variable -// named result_listener, whose type is a pointer to class -// MatchResultListener: -// -// MATCHER_P(EqualsLongString, str, "") { -// if (arg == str) return true; -// -// *result_listener << "the difference: " -/// << DiffStrings(str, arg); -// return false; -// } -// -// Overloading Matchers -// ==================== -// -// You can overload matchers with different numbers of parameters: -// -// MATCHER_P(Blah, a, description_string1) { ... } -// MATCHER_P2(Blah, a, b, description_string2) { ... } -// -// Caveats -// ======= -// -// When defining a new matcher, you should also consider implementing -// MatcherInterface or using MakePolymorphicMatcher(). These -// approaches require more work than the MATCHER* macros, but also -// give you more control on the types of the value being matched and -// the matcher parameters, which may leads to better compiler error -// messages when the matcher is used wrong. They also allow -// overloading matchers based on parameter types (as opposed to just -// based on the number of parameters). -// -// MATCHER*() can only be used in a namespace scope as templates cannot be -// declared inside of a local class. -// -// More Information -// ================ -// -// To learn more about using these macros, please search for 'MATCHER' -// on -// https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md - -#define MATCHER(name, description)\ - class name##Matcher {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl()\ - {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple<>()));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl());\ - }\ - name##Matcher() {\ - }\ - private:\ - };\ - inline name##Matcher name() {\ - return name##Matcher();\ - }\ - template \ - bool name##Matcher::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P(name, p0, description)\ - template \ - class name##MatcherP {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - explicit gmock_Impl(p0##_type gmock_p0)\ - : p0(::std::move(gmock_p0)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0));\ - }\ - explicit name##MatcherP(p0##_type gmock_p0) : p0(::std::move(gmock_p0)) {\ - }\ - p0##_type const p0;\ - private:\ - };\ - template \ - inline name##MatcherP name(p0##_type p0) {\ - return name##MatcherP(p0);\ - }\ - template \ - template \ - bool name##MatcherP::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P2(name, p0, p1, description)\ - template \ - class name##MatcherP2 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1));\ - }\ - name##MatcherP2(p0##_type gmock_p0, \ - p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - private:\ - };\ - template \ - inline name##MatcherP2 name(p0##_type p0, \ - p1##_type p1) {\ - return name##MatcherP2(p0, p1);\ - }\ - template \ - template \ - bool name##MatcherP2::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P3(name, p0, p1, p2, description)\ - template \ - class name##MatcherP3 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1, p2)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2));\ - }\ - name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - private:\ - };\ - template \ - inline name##MatcherP3 name(p0##_type p0, \ - p1##_type p1, p2##_type p2) {\ - return name##MatcherP3(p0, p1, p2);\ - }\ - template \ - template \ - bool name##MatcherP3::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P4(name, p0, p1, p2, p3, description)\ - template \ - class name##MatcherP4 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, \ - p1, p2, p3)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2, p3));\ - }\ - name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - private:\ - };\ - template \ - inline name##MatcherP4 name(p0##_type p0, p1##_type p1, p2##_type p2, \ - p3##_type p3) {\ - return name##MatcherP4(p0, \ - p1, p2, p3);\ - }\ - template \ - template \ - bool name##MatcherP4::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\ - template \ - class name##MatcherP5 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \ - p4(::std::move(gmock_p4)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1, p2, p3, p4)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2, p3, p4));\ - }\ - name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, \ - p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - private:\ - };\ - template \ - inline name##MatcherP5 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4) {\ - return name##MatcherP5(p0, p1, p2, p3, p4);\ - }\ - template \ - template \ - bool name##MatcherP5::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\ - template \ - class name##MatcherP6 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \ - p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1, p2, p3, p4, p5)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2, p3, p4, p5));\ - }\ - name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - private:\ - };\ - template \ - inline name##MatcherP6 name(p0##_type p0, p1##_type p1, p2##_type p2, \ - p3##_type p3, p4##_type p4, p5##_type p5) {\ - return name##MatcherP6(p0, p1, p2, p3, p4, p5);\ - }\ - template \ - template \ - bool name##MatcherP6::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\ - template \ - class name##MatcherP7 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \ - p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \ - p6(::std::move(gmock_p6)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1, p2, p3, p4, p5, \ - p6)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2, p3, p4, p5, p6));\ - }\ - name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - private:\ - };\ - template \ - inline name##MatcherP7 name(p0##_type p0, p1##_type p1, \ - p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ - p6##_type p6) {\ - return name##MatcherP7(p0, p1, p2, p3, p4, p5, p6);\ - }\ - template \ - template \ - bool name##MatcherP7::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\ - template \ - class name##MatcherP8 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \ - p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \ - p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - p7##_type const p7;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1, p2, \ - p3, p4, p5, p6, p7)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2, p3, p4, p5, p6, p7));\ - }\ - name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, \ - p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - p7##_type const p7;\ - private:\ - };\ - template \ - inline name##MatcherP8 name(p0##_type p0, \ - p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ - p6##_type p6, p7##_type p7) {\ - return name##MatcherP8(p0, p1, p2, p3, p4, p5, \ - p6, p7);\ - }\ - template \ - template \ - bool name##MatcherP8::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\ - template \ - class name##MatcherP9 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \ - p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \ - p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \ - p8(::std::move(gmock_p8)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - p7##_type const p7;\ - p8##_type const p8;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2, p3, p4, p5, p6, p7, p8));\ - }\ - name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - p7##_type const p7;\ - p8##_type const p8;\ - private:\ - };\ - template \ - inline name##MatcherP9 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ - p8##_type p8) {\ - return name##MatcherP9(p0, p1, p2, \ - p3, p4, p5, p6, p7, p8);\ - }\ - template \ - template \ - bool name##MatcherP9::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\ - template \ - class name##MatcherP10 {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ - p9##_type gmock_p9)\ - : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \ - p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \ - p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \ - p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \ - p8(::std::move(gmock_p8)), p9(::std::move(gmock_p9)) {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - p7##_type const p7;\ - p8##_type const p8;\ - p9##_type const p9;\ - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\ - }\ - name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8, p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \ - p9(::std::move(gmock_p9)) {\ - }\ - p0##_type const p0;\ - p1##_type const p1;\ - p2##_type const p2;\ - p3##_type const p3;\ - p4##_type const p4;\ - p5##_type const p5;\ - p6##_type const p6;\ - p7##_type const p7;\ - p8##_type const p8;\ - p9##_type const p9;\ - private:\ - };\ - template \ - inline name##MatcherP10 name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ - p9##_type p9) {\ - return name##MatcherP10(p0, \ - p1, p2, p3, p4, p5, p6, p7, p8, p9);\ - }\ - template \ - template \ - bool name##MatcherP10::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h.pump mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h.pump --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h.pump 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-generated-matchers.h.pump 1970-01-01 00:00:00.000000000 +0000 @@ -1,346 +0,0 @@ -$$ -*- mode: c++; -*- -$$ This is a Pump source file. Please use Pump to convert -$$ it to gmock-generated-matchers.h. -$$ -$var n = 10 $$ The maximum arity we support. -$$ }} This line fixes auto-indentation of the following code in Emacs. -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used variadic matchers. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ - -#include -#include -#include -#include -#include -#include "gmock/gmock-matchers.h" - -// The MATCHER* family of macros can be used in a namespace scope to -// define custom matchers easily. -// -// Basic Usage -// =========== -// -// The syntax -// -// MATCHER(name, description_string) { statements; } -// -// defines a matcher with the given name that executes the statements, -// which must return a bool to indicate if the match succeeds. Inside -// the statements, you can refer to the value being matched by 'arg', -// and refer to its type by 'arg_type'. -// -// The description string documents what the matcher does, and is used -// to generate the failure message when the match fails. Since a -// MATCHER() is usually defined in a header file shared by multiple -// C++ source files, we require the description to be a C-string -// literal to avoid possible side effects. It can be empty, in which -// case we'll use the sequence of words in the matcher name as the -// description. -// -// For example: -// -// MATCHER(IsEven, "") { return (arg % 2) == 0; } -// -// allows you to write -// -// // Expects mock_foo.Bar(n) to be called where n is even. -// EXPECT_CALL(mock_foo, Bar(IsEven())); -// -// or, -// -// // Verifies that the value of some_expression is even. -// EXPECT_THAT(some_expression, IsEven()); -// -// If the above assertion fails, it will print something like: -// -// Value of: some_expression -// Expected: is even -// Actual: 7 -// -// where the description "is even" is automatically calculated from the -// matcher name IsEven. -// -// Argument Type -// ============= -// -// Note that the type of the value being matched (arg_type) is -// determined by the context in which you use the matcher and is -// supplied to you by the compiler, so you don't need to worry about -// declaring it (nor can you). This allows the matcher to be -// polymorphic. For example, IsEven() can be used to match any type -// where the value of "(arg % 2) == 0" can be implicitly converted to -// a bool. In the "Bar(IsEven())" example above, if method Bar() -// takes an int, 'arg_type' will be int; if it takes an unsigned long, -// 'arg_type' will be unsigned long; and so on. -// -// Parameterizing Matchers -// ======================= -// -// Sometimes you'll want to parameterize the matcher. For that you -// can use another macro: -// -// MATCHER_P(name, param_name, description_string) { statements; } -// -// For example: -// -// MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; } -// -// will allow you to write: -// -// EXPECT_THAT(Blah("a"), HasAbsoluteValue(n)); -// -// which may lead to this message (assuming n is 10): -// -// Value of: Blah("a") -// Expected: has absolute value 10 -// Actual: -9 -// -// Note that both the matcher description and its parameter are -// printed, making the message human-friendly. -// -// In the matcher definition body, you can write 'foo_type' to -// reference the type of a parameter named 'foo'. For example, in the -// body of MATCHER_P(HasAbsoluteValue, value) above, you can write -// 'value_type' to refer to the type of 'value'. -// -// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P$n to -// support multi-parameter matchers. -// -// Describing Parameterized Matchers -// ================================= -// -// The last argument to MATCHER*() is a string-typed expression. The -// expression can reference all of the matcher's parameters and a -// special bool-typed variable named 'negation'. When 'negation' is -// false, the expression should evaluate to the matcher's description; -// otherwise it should evaluate to the description of the negation of -// the matcher. For example, -// -// using testing::PrintToString; -// -// MATCHER_P2(InClosedRange, low, hi, -// std::string(negation ? "is not" : "is") + " in range [" + -// PrintToString(low) + ", " + PrintToString(hi) + "]") { -// return low <= arg && arg <= hi; -// } -// ... -// EXPECT_THAT(3, InClosedRange(4, 6)); -// EXPECT_THAT(3, Not(InClosedRange(2, 4))); -// -// would generate two failures that contain the text: -// -// Expected: is in range [4, 6] -// ... -// Expected: is not in range [2, 4] -// -// If you specify "" as the description, the failure message will -// contain the sequence of words in the matcher name followed by the -// parameter values printed as a tuple. For example, -// -// MATCHER_P2(InClosedRange, low, hi, "") { ... } -// ... -// EXPECT_THAT(3, InClosedRange(4, 6)); -// EXPECT_THAT(3, Not(InClosedRange(2, 4))); -// -// would generate two failures that contain the text: -// -// Expected: in closed range (4, 6) -// ... -// Expected: not (in closed range (2, 4)) -// -// Types of Matcher Parameters -// =========================== -// -// For the purpose of typing, you can view -// -// MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... } -// -// as shorthand for -// -// template -// FooMatcherPk -// Foo(p1_type p1, ..., pk_type pk) { ... } -// -// When you write Foo(v1, ..., vk), the compiler infers the types of -// the parameters v1, ..., and vk for you. If you are not happy with -// the result of the type inference, you can specify the types by -// explicitly instantiating the template, as in Foo(5, -// false). As said earlier, you don't get to (or need to) specify -// 'arg_type' as that's determined by the context in which the matcher -// is used. You can assign the result of expression Foo(p1, ..., pk) -// to a variable of type FooMatcherPk. This -// can be useful when composing matchers. -// -// While you can instantiate a matcher template with reference types, -// passing the parameters by pointer usually makes your code more -// readable. If, however, you still want to pass a parameter by -// reference, be aware that in the failure message generated by the -// matcher you will see the value of the referenced object but not its -// address. -// -// Explaining Match Results -// ======================== -// -// Sometimes the matcher description alone isn't enough to explain why -// the match has failed or succeeded. For example, when expecting a -// long string, it can be very helpful to also print the diff between -// the expected string and the actual one. To achieve that, you can -// optionally stream additional information to a special variable -// named result_listener, whose type is a pointer to class -// MatchResultListener: -// -// MATCHER_P(EqualsLongString, str, "") { -// if (arg == str) return true; -// -// *result_listener << "the difference: " -/// << DiffStrings(str, arg); -// return false; -// } -// -// Overloading Matchers -// ==================== -// -// You can overload matchers with different numbers of parameters: -// -// MATCHER_P(Blah, a, description_string1) { ... } -// MATCHER_P2(Blah, a, b, description_string2) { ... } -// -// Caveats -// ======= -// -// When defining a new matcher, you should also consider implementing -// MatcherInterface or using MakePolymorphicMatcher(). These -// approaches require more work than the MATCHER* macros, but also -// give you more control on the types of the value being matched and -// the matcher parameters, which may leads to better compiler error -// messages when the matcher is used wrong. They also allow -// overloading matchers based on parameter types (as opposed to just -// based on the number of parameters). -// -// MATCHER*() can only be used in a namespace scope as templates cannot be -// declared inside of a local class. -// -// More Information -// ================ -// -// To learn more about using these macros, please search for 'MATCHER' -// on -// https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md - -$range i 0..n -$for i - -[[ -$var macro_name = [[$if i==0 [[MATCHER]] $elif i==1 [[MATCHER_P]] - $else [[MATCHER_P$i]]]] -$var class_name = [[name##Matcher[[$if i==0 [[]] $elif i==1 [[P]] - $else [[P$i]]]]]] -$range j 0..i-1 -$var template = [[$if i==0 [[]] $else [[ - - template <$for j, [[typename p$j##_type]]>\ -]]]] -$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]] -$var impl_ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]] -$var impl_inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::std::move(gmock_p$j))]]]]]] -$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::std::move(gmock_p$j))]]]]]] -$var params = [[$for j, [[p$j]]]] -$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]] -$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]] -$var param_field_decls = [[$for j -[[ - - p$j##_type const p$j;\ -]]]] -$var param_field_decls2 = [[$for j -[[ - - p$j##_type const p$j;\ -]]]] - -#define $macro_name(name$for j [[, p$j]], description)\$template - class $class_name {\ - public:\ - template \ - class gmock_Impl : public ::testing::MatcherInterface<\ - GTEST_REFERENCE_TO_CONST_(arg_type)> {\ - public:\ - [[$if i==1 [[explicit ]]]]gmock_Impl($impl_ctor_param_list)\ - $impl_inits {}\ - virtual bool MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener) const;\ - virtual void DescribeTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(false);\ - }\ - virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\ - *gmock_os << FormatDescription(true);\ - }\$param_field_decls - private:\ - ::std::string FormatDescription(bool negation) const {\ - ::std::string gmock_description = (description);\ - if (!gmock_description.empty()) {\ - return gmock_description;\ - }\ - return ::testing::internal::FormatMatcherDescription(\ - negation, #name, \ - ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ - ::std::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\ - }\ - };\ - template \ - operator ::testing::Matcher() const {\ - return ::testing::Matcher(\ - new gmock_Impl($params));\ - }\ - [[$if i==1 [[explicit ]]]]$class_name($ctor_param_list)$inits {\ - }\$param_field_decls2 - private:\ - };\$template - inline $class_name$param_types name($param_types_and_names) {\ - return $class_name$param_types($params);\ - }\$template - template \ - bool $class_name$param_types::gmock_Impl::MatchAndExplain(\ - GTEST_REFERENCE_TO_CONST_(arg_type) arg,\ - ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\ - const -]] - - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This is the main header file a user should include. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_H_ - -// This file implements the following syntax: -// -// ON_CALL(mock_object, Method(...)) -// .With(...) ? -// .WillByDefault(...); -// -// where With() is optional and WillByDefault() must appear exactly -// once. -// -// EXPECT_CALL(mock_object, Method(...)) -// .With(...) ? -// .Times(...) ? -// .InSequence(...) * -// .WillOnce(...) * -// .WillRepeatedly(...) ? -// .RetiresOnSaturation() ? ; -// -// where all clauses are optional and WillOnce() can be repeated. - -#include "gmock/gmock-actions.h" -#include "gmock/gmock-cardinalities.h" -#include "gmock/gmock-function-mocker.h" -#include "gmock/gmock-generated-actions.h" -#include "gmock/gmock-generated-function-mockers.h" -#include "gmock/gmock-generated-matchers.h" -#include "gmock/gmock-matchers.h" -#include "gmock/gmock-more-actions.h" -#include "gmock/gmock-more-matchers.h" -#include "gmock/gmock-nice-strict.h" -#include "gmock/internal/gmock-internal-utils.h" - -namespace testing { - -// Declares Google Mock flags that we want a user to use programmatically. -GMOCK_DECLARE_bool_(catch_leaked_mocks); -GMOCK_DECLARE_string_(verbose); -GMOCK_DECLARE_int32_(default_mock_behavior); - -// Initializes Google Mock. This must be called before running the -// tests. In particular, it parses the command line for the flags -// that Google Mock recognizes. Whenever a Google Mock flag is seen, -// it is removed from argv, and *argc is decremented. -// -// No value is returned. Instead, the Google Mock flag variables are -// updated. -// -// Since Google Test is needed for Google Mock to work, this function -// also initializes Google Test and parses its flags, if that hasn't -// been done. -GTEST_API_ void InitGoogleMock(int* argc, char** argv); - -// This overloaded version can be used in Windows programs compiled in -// UNICODE mode. -GTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv); - -// This overloaded version can be used on Arduino/embedded platforms where -// there is no argc/argv. -GTEST_API_ void InitGoogleMock(); - -} // namespace testing - -#endif // GMOCK_INCLUDE_GMOCK_GMOCK_H_ diff -Nru mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-matchers.h mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-matchers.h --- mysql-8.0-8.0.26/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-matchers.h 2021-07-01 07:53:49.000000000 +0000 +++ mysql-8.0-8.0.27/extra/googletest/googletest-release-1.10.0/googlemock/include/gmock/gmock-matchers.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,4568 +0,0 @@ -// Copyright 2007, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -// Google Mock - a framework for writing C++ mock classes. -// -// This file implements some commonly used argument matchers. More -// matchers can be defined by the user implementing the -// MatcherInterface interface if necessary. -// -// See googletest/include/gtest/gtest-matchers.h for the definition of class -// Matcher, class MatcherInterface, and others. - -// GOOGLETEST_CM0002 DO NOT DELETE - -#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ -#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ - -#include -#include -#include -#include -#include -#include -#include // NOLINT -#include -#include -#include -#include -#include -#include "gmock/internal/gmock-internal-utils.h" -#include "gmock/internal/gmock-port.h" -#include "gtest/gtest.h" - -// MSVC warning C5046 is new as of VS2017 version 15.8. -#if defined(_MSC_VER) && _MSC_VER >= 1915 -#define GMOCK_MAYBE_5046_ 5046 -#else -#define GMOCK_MAYBE_5046_ -#endif - -GTEST_DISABLE_MSC_WARNINGS_PUSH_( - 4251 GMOCK_MAYBE_5046_ /* class A needs to have dll-interface to be used by - clients of class B */ - /* Symbol involving type with internal linkage not defined */) - -namespace testing { - -// To implement a matcher Foo for type T, define: -// 1. a class FooMatcherImpl that implements the -// MatcherInterface interface, and -// 2. a factory function that creates a Matcher object from a -// FooMatcherImpl*. -// -// The two-level delegation design makes it possible to allow a user -// to write "v" instead of "Eq(v)" where a Matcher is expected, which -// is impossible if we pass matchers by pointers. It also eases -// ownership management as Matcher objects can now be copied like -// plain values. - -// A match result listener that stores the explanation in a string. -class StringMatchResultListener : public MatchResultListener { - public: - StringMatchResultListener() : MatchResultListener(&ss_) {} - - // Returns the explanation accumulated so far. - std::string str() const { return ss_.str(); } - - // Clears the explanation accumulated so far. - void Clear() { ss_.str(""); } - - private: - ::std::stringstream ss_; - - GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener); -}; - -// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION -// and MUST NOT BE USED IN USER CODE!!! -namespace internal { - -// The MatcherCastImpl class template is a helper for implementing -// MatcherCast(). We need this helper in order to partially -// specialize the implementation of MatcherCast() (C++ allows -// class/struct templates to be partially specialized, but not -// function templates.). - -// This general version is used when MatcherCast()'s argument is a -// polymorphic matcher (i.e. something that can be converted to a -// Matcher but is not one yet; for example, Eq(value)) or a value (for -// example, "hello"). -template -class MatcherCastImpl { - public: - static Matcher Cast(const M& polymorphic_matcher_or_value) { - // M can be a polymorphic matcher, in which case we want to use - // its conversion operator to create Matcher. Or it can be a value - // that should be passed to the Matcher's constructor. - // - // We can't call Matcher(polymorphic_matcher_or_value) when M is a - // polymorphic matcher because it'll be ambiguous if T has an implicit - // constructor from M (this usually happens when T has an implicit - // constructor from any type). - // - // It won't work to unconditionally implict_cast - // polymorphic_matcher_or_value to Matcher because it won't trigger - // a user-defined conversion from M to T if one exists (assuming M is - // a value). - return CastImpl(polymorphic_matcher_or_value, - std::is_convertible>{}, - std::is_convertible{}); - } - - private: - template - static Matcher CastImpl(const M& polymorphic_matcher_or_value, - std::true_type /* convertible_to_matcher */, - bool_constant) { - // M is implicitly convertible to Matcher, which means that either - // M is a polymorphic matcher or Matcher has an implicit constructor - // from M. In both cases using the implicit conversion will produce a - // matcher. - // - // Even if T has an implicit constructor from M, it won't be called because - // creating Matcher would require a chain of two user-defined conversions - // (first to create T from M and then to create Matcher from T). - return polymorphic_matcher_or_value; - } - - // M can't be implicitly converted to Matcher, so M isn't a polymorphic - // matcher. It's a value of a type implicitly convertible to T. Use direct - // initialization to create a matcher. - static Matcher CastImpl(const M& value, - std::false_type /* convertible_to_matcher */, - std::true_type /* convertible_to_T */) { - return Matcher(ImplicitCast_(value)); - } - - // M can't be implicitly converted to either Matcher or T. Attempt to use - // polymorphic matcher Eq(value) in this case. - // - // Note that we first attempt to perform an implicit cast on the value and - // only fall back to the polymorphic Eq() matcher afterwards because the - // latter calls bool operator==(const Lhs& lhs, const Rhs& rhs) in the end - // which might be undefined even when Rhs is implicitly convertible to Lhs - // (e.g. std::pair vs. std::pair). - // - // We don't define this method inline as we need the declaration of Eq(). - static Matcher CastImpl(const M& value, - std::false_type /* convertible_to_matcher */, - std::false_type /* convertible_to_T */); -}; - -// This more specialized version is used when MatcherCast()'s argument -// is already a Matcher. This only compiles when type T can be -// statically converted to type U. -template -class MatcherCastImpl > { - public: - static Matcher Cast(const Matcher& source_matcher) { - return Matcher(new Impl(source_matcher)); - } - - private: - class Impl : public MatcherInterface { - public: - explicit Impl(const Matcher& source_matcher) - : source_matcher_(source_matcher) {} - - // We delegate the matching logic to the source matcher. - bool MatchAndExplain(T x, MatchResultListener* listener) const override { - using FromType = typename std::remove_cv::type>::type>::type; - using ToType = typename std::remove_cv::type>::type>::type; - // Do not allow implicitly converting base*/& to derived*/&. - static_assert( - // Do not trigger if only one of them is a pointer. That implies a - // regular conversion and not a down_cast. - (std::is_pointer::type>::value != - std::is_pointer::type>::value) || - std::is_same::value || - !std::is_base_of::value, - "Can't implicitly convert from to "); - - return source_matcher_.MatchAndExplain(static_cast(x), listener); - } - - void DescribeTo(::std::ostream* os) const override { - source_matcher_.DescribeTo(os); - } - - void DescribeNegationTo(::std::ostream* os) const override { - source_matcher_.DescribeNegationTo(os); - } - - private: - const Matcher source_matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; -}; - -// This even more specialized version is used for efficiently casting -// a matcher to its own type. -template -class MatcherCastImpl > { - public: - static Matcher Cast(const Matcher& matcher) { return matcher; } -}; - -} // namespace internal - -// In order to be safe and clear, casting between different matcher -// types is done explicitly via MatcherCast(m), which takes a -// matcher m and returns a Matcher. It compiles only when T can be -// statically converted to the argument type of m. -template -inline Matcher MatcherCast(const M& matcher) { - return internal::MatcherCastImpl::Cast(matcher); -} - -// Implements SafeMatcherCast(). -// -// FIXME: The intermediate SafeMatcherCastImpl class was introduced as a -// workaround for a compiler bug, and can now be removed. -template -class SafeMatcherCastImpl { - public: - // This overload handles polymorphic matchers and values only since - // monomorphic matchers are handled by the next one. - template - static inline Matcher Cast(const M& polymorphic_matcher_or_value) { - return internal::MatcherCastImpl::Cast(polymorphic_matcher_or_value); - } - - // This overload handles monomorphic matchers. - // - // In general, if type T can be implicitly converted to type U, we can - // safely convert a Matcher to a Matcher (i.e. Matcher is - // contravariant): just keep a copy of the original Matcher, convert the - // argument from type T to U, and then pass it to the underlying Matcher. - // The only exception is when U is a reference and T is not, as the - // underlying Matcher may be interested in the argument's address, which - // is not preserved in the conversion from T to U. - template - static inline Matcher Cast(const Matcher& matcher) { - // Enforce that T can be implicitly converted to U. - GTEST_COMPILE_ASSERT_((std::is_convertible::value), - "T must be implicitly convertible to U"); - // Enforce that we are not converting a non-reference type T to a reference - // type U. - GTEST_COMPILE_ASSERT_( - std::is_reference::value || !std::is_reference::value, - cannot_convert_non_reference_arg_to_reference); - // In case both T and U are arithmetic types, enforce that the - // conversion is not lossy. - typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT; - typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU; - const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther; - const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther; - GTEST_COMPILE_ASSERT_( - kTIsOther || kUIsOther || - (internal::LosslessArithmeticConvertible::value), - conversion_of_arithmetic_types_must_be_lossless); - return MatcherCast(matcher); - } -}; - -template -inline Matcher SafeMatcherCast(const M& polymorphic_matcher) { - return SafeMatcherCastImpl::Cast(polymorphic_matcher); -} - -// A() returns a matcher that matches any value of type T. -template -Matcher A(); - -// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION -// and MUST NOT BE USED IN USER CODE!!! -namespace internal { - -// If the explanation is not empty, prints it to the ostream. -inline void PrintIfNotEmpty(const std::string& explanation, - ::std::ostream* os) { - if (explanation != "" && os != nullptr) { - *os << ", " << explanation; - } -} - -// Returns true if the given type name is easy to read by a human. -// This is used to decide whether printing the type of a value might -// be helpful. -inline bool IsReadableTypeName(const std::string& type_name) { - // We consider a type name readable if it's short or doesn't contain - // a template or function type. - return (type_name.length() <= 20 || - type_name.find_first_of("<(") == std::string::npos); -} - -// Matches the value against the given matcher, prints the value and explains -// the match result to the listener. Returns the match result. -// 'listener' must not be NULL. -// Value cannot be passed by const reference, because some matchers take a -// non-const argument. -template -bool MatchPrintAndExplain(Value& value, const Matcher& matcher, - MatchResultListener* listener) { - if (!listener->IsInterested()) { - // If the listener is not interested, we do not need to construct the - // inner explanation. - return matcher.Matches(value); - } - - StringMatchResultListener inner_listener; - const bool match = matcher.MatchAndExplain(value, &inner_listener); - - UniversalPrint(value, listener->stream()); -#if GTEST_HAS_RTTI - const std::string& type_name = GetTypeName(); - if (IsReadableTypeName(type_name)) - *listener->stream() << " (of type " << type_name << ")"; -#endif - PrintIfNotEmpty(inner_listener.str(), listener->stream()); - - return match; -} - -// An internal helper class for doing compile-time loop on a tuple's -// fields. -template -class TuplePrefix { - public: - // TuplePrefix::Matches(matcher_tuple, value_tuple) returns true - // if and only if the first N fields of matcher_tuple matches - // the first N fields of value_tuple, respectively. - template - static bool Matches(const MatcherTuple& matcher_tuple, - const ValueTuple& value_tuple) { - return TuplePrefix::Matches(matcher_tuple, value_tuple) && - std::get(matcher_tuple).Matches(std::get(value_tuple)); - } - - // TuplePrefix::ExplainMatchFailuresTo(matchers, values, os) - // describes failures in matching the first N fields of matchers - // against the first N fields of values. If there is no failure, - // nothing will be streamed to os. - template - static void ExplainMatchFailuresTo(const MatcherTuple& matchers, - const ValueTuple& values, - ::std::ostream* os) { - // First, describes failures in the first N - 1 fields. - TuplePrefix::ExplainMatchFailuresTo(matchers, values, os); - - // Then describes the failure (if any) in the (N - 1)-th (0-based) - // field. - typename std::tuple_element::type matcher = - std::get(matchers); - typedef typename std::tuple_element::type Value; - const Value& value = std::get(values); - StringMatchResultListener listener; - if (!matcher.MatchAndExplain(value, &listener)) { - *os << " Expected arg #" << N - 1 << ": "; - std::get(matchers).DescribeTo(os); - *os << "\n Actual: "; - // We remove the reference in type Value to prevent the - // universal printer from printing the address of value, which - // isn't interesting to the user most of the time. The - // matcher's MatchAndExplain() method handles the case when - // the address is interesting. - internal::UniversalPrint(value, os); - PrintIfNotEmpty(listener.str(), os); - *os << "\n"; - } - } -}; - -// The base case. -template <> -class TuplePrefix<0> { - public: - template - static bool Matches(const MatcherTuple& /* matcher_tuple */, - const ValueTuple& /* value_tuple */) { - return true; - } - - template - static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */, - const ValueTuple& /* values */, - ::std::ostream* /* os */) {} -}; - -// TupleMatches(matcher_tuple, value_tuple) returns true if and only if -// all matchers in matcher_tuple match the corresponding fields in -// value_tuple. It is a compiler error if matcher_tuple and -// value_tuple have different number of fields or incompatible field -// types. -template -bool TupleMatches(const MatcherTuple& matcher_tuple, - const ValueTuple& value_tuple) { - // Makes sure that matcher_tuple and value_tuple have the same - // number of fields. - GTEST_COMPILE_ASSERT_(std::tuple_size::value == - std::tuple_size::value, - matcher_and_value_have_different_numbers_of_fields); - return TuplePrefix::value>::Matches(matcher_tuple, - value_tuple); -} - -// Describes failures in matching matchers against values. If there -// is no failure, nothing will be streamed to os. -template -void ExplainMatchFailureTupleTo(const MatcherTuple& matchers, - const ValueTuple& values, - ::std::ostream* os) { - TuplePrefix::value>::ExplainMatchFailuresTo( - matchers, values, os); -} - -// TransformTupleValues and its helper. -// -// TransformTupleValuesHelper hides the internal machinery that -// TransformTupleValues uses to implement a tuple traversal. -template -class TransformTupleValuesHelper { - private: - typedef ::std::tuple_size TupleSize; - - public: - // For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'. - // Returns the final value of 'out' in case the caller needs it. - static OutIter Run(Func f, const Tuple& t, OutIter out) { - return IterateOverTuple()(f, t, out); - } - - private: - template - struct IterateOverTuple { - OutIter operator() (Func f, const Tup& t, OutIter out) const { - *out++ = f(::std::get(t)); - return IterateOverTuple()(f, t, out); - } - }; - template - struct IterateOverTuple { - OutIter operator() (Func /* f */, const Tup& /* t */, OutIter out) const { - return out; - } - }; -}; - -// Successively invokes 'f(element)' on each element of the tuple 't', -// appending each result to the 'out' iterator. Returns the final value -// of 'out'. -template -OutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) { - return TransformTupleValuesHelper::Run(f, t, out); -} - -// Implements A(). -template -class AnyMatcherImpl : public MatcherInterface { - public: - bool MatchAndExplain(const T& /* x */, - MatchResultListener* /* listener */) const override { - return true; - } - void DescribeTo(::std::ostream* os) const override { *os << "is anything"; } - void DescribeNegationTo(::std::ostream* os) const override { - // This is mostly for completeness' safe, as it's not very useful - // to write Not(A()). However we cannot completely rule out - // such a possibility, and it doesn't hurt to be prepared. - *os << "never matches"; - } -}; - -// Implements _, a matcher that matches any value of any -// type. This is a polymorphic matcher, so we need a template type -// conversion operator to make it appearing as a Matcher for any -// type T. -class AnythingMatcher { - public: - template - operator Matcher() const { return A(); } -}; - -// Implements the polymorphic IsNull() matcher, which matches any raw or smart -// pointer that is NULL. -class IsNullMatcher { - public: - template - bool MatchAndExplain(const Pointer& p, - MatchResultListener* /* listener */) const { - return p == nullptr; - } - - void DescribeTo(::std::ostream* os) const { *os << "is NULL"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "isn't NULL"; - } -}; - -// Implements the polymorphic NotNull() matcher, which matches any raw or smart -// pointer that is not NULL. -class NotNullMatcher { - public: - template - bool MatchAndExplain(const Pointer& p, - MatchResultListener* /* listener */) const { - return p != nullptr; - } - - void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "is NULL"; - } -}; - -// Ref(variable) matches any argument that is a reference to -// 'variable'. This matcher is polymorphic as it can match any -// super type of the type of 'variable'. -// -// The RefMatcher template class implements Ref(variable). It can -// only be instantiated with a reference type. This prevents a user -// from mistakenly using Ref(x) to match a non-reference function -// argument. For example, the following will righteously cause a -// compiler error: -// -// int n; -// Matcher m1 = Ref(n); // This won't compile. -// Matcher m2 = Ref(n); // This will compile. -template -class RefMatcher; - -template -class RefMatcher { - // Google Mock is a generic framework and thus needs to support - // mocking any function types, including those that take non-const - // reference arguments. Therefore the template parameter T (and - // Super below) can be instantiated to either a const type or a - // non-const type. - public: - // RefMatcher() takes a T& instead of const T&, as we want the - // compiler to catch using Ref(const_value) as a matcher for a - // non-const reference. - explicit RefMatcher(T& x) : object_(x) {} // NOLINT - - template - operator Matcher() const { - // By passing object_ (type T&) to Impl(), which expects a Super&, - // we make sure that Super is a super type of T. In particular, - // this catches using Ref(const_value) as a matcher for a - // non-const reference, as you cannot implicitly convert a const - // reference to a non-const reference. - return MakeMatcher(new Impl(object_)); - } - - private: - template - class Impl : public MatcherInterface { - public: - explicit Impl(Super& x) : object_(x) {} // NOLINT - - // MatchAndExplain() takes a Super& (as opposed to const Super&) - // in order to match the interface MatcherInterface. - bool MatchAndExplain(Super& x, - MatchResultListener* listener) const override { - *listener << "which is located @" << static_cast(&x); - return &x == &object_; - } - - void DescribeTo(::std::ostream* os) const override { - *os << "references the variable "; - UniversalPrinter::Print(object_, os); - } - - void DescribeNegationTo(::std::ostream* os) const override { - *os << "does not reference the variable "; - UniversalPrinter::Print(object_, os); - } - - private: - const Super& object_; - - GTEST_DISALLOW_ASSIGN_(Impl); - }; - - T& object_; - - GTEST_DISALLOW_ASSIGN_(RefMatcher); -}; - -// Polymorphic helper functions for narrow and wide string matchers. -inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) { - return String::CaseInsensitiveCStringEquals(lhs, rhs); -} - -inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs, - const wchar_t* rhs) { - return String::CaseInsensitiveWideCStringEquals(lhs, rhs); -} - -// String comparison for narrow or wide strings that can have embedded NUL -// characters. -template -bool CaseInsensitiveStringEquals(const StringType& s1, - const StringType& s2) { - // Are the heads equal? - if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) { - return false; - } - - // Skip the equal heads. - const typename StringType::value_type nul = 0; - const size_t i1 = s1.find(nul), i2 = s2.find(nul); - - // Are we at the end of either s1 or s2? - if (i1 == StringType::npos || i2 == StringType::npos) { - return i1 == i2; - } - - // Are the tails equal? - return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1)); -} - -// String matchers. - -// Implements equality-based string matchers like StrEq, StrCaseNe, and etc. -template -class StrEqualityMatcher { - public: - StrEqualityMatcher(const StringType& str, bool expect_eq, - bool case_sensitive) - : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {} - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = std::string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - if (s == nullptr) { - return !expect_eq_; - } - return MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - const bool eq = case_sensitive_ ? s2 == string_ : - CaseInsensitiveStringEquals(s2, string_); - return expect_eq_ == eq; - } - - void DescribeTo(::std::ostream* os) const { - DescribeToHelper(expect_eq_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - DescribeToHelper(!expect_eq_, os); - } - - private: - void DescribeToHelper(bool expect_eq, ::std::ostream* os) const { - *os << (expect_eq ? "is " : "isn't "); - *os << "equal to "; - if (!case_sensitive_) { - *os << "(ignoring case) "; - } - UniversalPrint(string_, os); - } - - const StringType string_; - const bool expect_eq_; - const bool case_sensitive_; - - GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher); -}; - -// Implements the polymorphic HasSubstr(substring) matcher, which -// can be used as a Matcher as long as T can be converted to a -// string. -template -class HasSubstrMatcher { - public: - explicit HasSubstrMatcher(const StringType& substring) - : substring_(substring) {} - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = std::string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - return s != nullptr && MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - return s2.find(substring_) != StringType::npos; - } - - // Describes what this matcher matches. - void DescribeTo(::std::ostream* os) const { - *os << "has substring "; - UniversalPrint(substring_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "has no substring "; - UniversalPrint(substring_, os); - } - - private: - const StringType substring_; - - GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher); -}; - -// Implements the polymorphic StartsWith(substring) matcher, which -// can be used as a Matcher as long as T can be converted to a -// string. -template -class StartsWithMatcher { - public: - explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) { - } - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = std::string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - return s != nullptr && MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - return s2.length() >= prefix_.length() && - s2.substr(0, prefix_.length()) == prefix_; - } - - void DescribeTo(::std::ostream* os) const { - *os << "starts with "; - UniversalPrint(prefix_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "doesn't start with "; - UniversalPrint(prefix_, os); - } - - private: - const StringType prefix_; - - GTEST_DISALLOW_ASSIGN_(StartsWithMatcher); -}; - -// Implements the polymorphic EndsWith(substring) matcher, which -// can be used as a Matcher as long as T can be converted to a -// string. -template -class EndsWithMatcher { - public: - explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {} - -#if GTEST_HAS_ABSL - bool MatchAndExplain(const absl::string_view& s, - MatchResultListener* listener) const { - // This should fail to compile if absl::string_view is used with wide - // strings. - const StringType& str = std::string(s); - return MatchAndExplain(str, listener); - } -#endif // GTEST_HAS_ABSL - - // Accepts pointer types, particularly: - // const char* - // char* - // const wchar_t* - // wchar_t* - template - bool MatchAndExplain(CharType* s, MatchResultListener* listener) const { - return s != nullptr && MatchAndExplain(StringType(s), listener); - } - - // Matches anything that can convert to StringType. - // - // This is a template, not just a plain function with const StringType&, - // because absl::string_view has some interfering non-explicit constructors. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* /* listener */) const { - const StringType& s2(s); - return s2.length() >= suffix_.length() && - s2.substr(s2.length() - suffix_.length()) == suffix_; - } - - void DescribeTo(::std::ostream* os) const { - *os << "ends with "; - UniversalPrint(suffix_, os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "doesn't end with "; - UniversalPrint(suffix_, os); - } - - private: - const StringType suffix_; - - GTEST_DISALLOW_ASSIGN_(EndsWithMatcher); -}; - -// Implements a matcher that compares the two fields of a 2-tuple -// using one of the ==, <=, <, etc, operators. The two fields being -// compared don't have to have the same type. -// -// The matcher defined here is polymorphic (for example, Eq() can be -// used to match a std::tuple, a std::tuple, -// etc). Therefore we use a template type conversion operator in the -// implementation. -template -class PairMatchBase { - public: - template - operator Matcher<::std::tuple>() const { - return Matcher<::std::tuple>(new Impl&>); - } - template - operator Matcher&>() const { - return MakeMatcher(new Impl&>); - } - - private: - static ::std::ostream& GetDesc(::std::ostream& os) { // NOLINT - return os << D::Desc(); - } - - template - class Impl : public MatcherInterface { - public: - bool MatchAndExplain(Tuple args, - MatchResultListener* /* listener */) const override { - return Op()(::std::get<0>(args), ::std::get<1>(args)); - } - void DescribeTo(::std::ostream* os) const override { - *os << "are " << GetDesc; - } - void DescribeNegationTo(::std::ostream* os) const override { - *os << "aren't " << GetDesc; - } - }; -}; - -class Eq2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "an equal pair"; } -}; -class Ne2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "an unequal pair"; } -}; -class Lt2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first < the second"; } -}; -class Gt2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first > the second"; } -}; -class Le2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first <= the second"; } -}; -class Ge2Matcher : public PairMatchBase { - public: - static const char* Desc() { return "a pair where the first >= the second"; } -}; - -// Implements the Not(...) matcher for a particular argument type T. -// We do not nest it inside the NotMatcher class template, as that -// will prevent different instantiations of NotMatcher from sharing -// the same NotMatcherImpl class. -template -class NotMatcherImpl : public MatcherInterface { - public: - explicit NotMatcherImpl(const Matcher& matcher) - : matcher_(matcher) {} - - bool MatchAndExplain(const T& x, - MatchResultListener* listener) const override { - return !matcher_.MatchAndExplain(x, listener); - } - - void DescribeTo(::std::ostream* os) const override { - matcher_.DescribeNegationTo(os); - } - - void DescribeNegationTo(::std::ostream* os) const override { - matcher_.DescribeTo(os); - } - - private: - const Matcher matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcherImpl); -}; - -// Implements the Not(m) matcher, which matches a value that doesn't -// match matcher m. -template -class NotMatcher { - public: - explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {} - - // This template type conversion operator allows Not(m) to be used - // to match any type m can match. - template - operator Matcher() const { - return Matcher(new NotMatcherImpl(SafeMatcherCast(matcher_))); - } - - private: - InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcher); -}; - -// Implements the AllOf(m1, m2) matcher for a particular argument type -// T. We do not nest it inside the BothOfMatcher class template, as -// that will prevent different instantiations of BothOfMatcher from -// sharing the same BothOfMatcherImpl class. -template -class AllOfMatcherImpl : public MatcherInterface { - public: - explicit AllOfMatcherImpl(std::vector > matchers) - : matchers_(std::move(matchers)) {} - - void DescribeTo(::std::ostream* os) const override { - *os << "("; - for (size_t i = 0; i < matchers_.size(); ++i) { - if (i != 0) *os << ") and ("; - matchers_[i].DescribeTo(os); - } - *os << ")"; - } - - void DescribeNegationTo(::std::ostream* os) const override { - *os << "("; - for (size_t i = 0; i < matchers_.size(); ++i) { - if (i != 0) *os << ") or ("; - matchers_[i].DescribeNegationTo(os); - } - *os << ")"; - } - - bool MatchAndExplain(const T& x, - MatchResultListener* listener) const override { - // If either matcher1_ or matcher2_ doesn't match x, we only need - // to explain why one of them fails. - std::string all_match_result; - - for (size_t i = 0; i < matchers_.size(); ++i) { - StringMatchResultListener slistener; - if (matchers_[i].MatchAndExplain(x, &slistener)) { - if (all_match_result.empty()) { - all_match_result = slistener.str(); - } else { - std::string result = slistener.str(); - if (!result.empty()) { - all_match_result += ", and "; - all_match_result += result; - } - } - } else { - *listener << slistener.str(); - return false; - } - } - - // Otherwise we need to explain why *both* of them match. - *listener << all_match_result; - return true; - } - - private: - const std::vector > matchers_; - - GTEST_DISALLOW_ASSIGN_(AllOfMatcherImpl); -}; - -// VariadicMatcher is used for the variadic implementation of -// AllOf(m_1, m_2, ...) and AnyOf(m_1, m_2, ...). -// CombiningMatcher is used to recursively combine the provided matchers -// (of type Args...). -template