Skip to content

Commit

Permalink
Bug#36500268 Upgrade to clang-format 15 [8.4]
Browse files Browse the repository at this point in the history
Switch to Latest for Standard: Cpp11 is in fact alias for Latest:
 https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Also remove duplicate specifications for same option, which is error
in clang 18+.

Change-Id: I7649b1bc09ec1eef1925918034e596f188bff867
  • Loading branch information
trosten committed Jun 16, 2024
1 parent c057e37 commit 5bfe4e9
Show file tree
Hide file tree
Showing 309 changed files with 1,572 additions and 1,630 deletions.
11 changes: 1 addition & 10 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

# We currently use clang-format version 10.
# We currently use clang-format version 15.
#
# This is the output of
#
Expand Down Expand Up @@ -98,15 +98,13 @@ ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
#DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
#IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
Expand Down Expand Up @@ -146,7 +144,6 @@ PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
#PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
Expand Down Expand Up @@ -197,7 +194,6 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
#Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
Expand All @@ -210,7 +206,6 @@ UseTab: Never
DerivePointerAlignment: false
PointerAlignment: Right

# MySQL source code is allowed to use the latest c++ features.
Standard: Latest

# MySQL includes frequently are not order-independent (e.g. my_config.h needs
Expand Down Expand Up @@ -277,15 +272,13 @@ ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
Expand Down Expand Up @@ -325,7 +318,6 @@ PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
Expand Down Expand Up @@ -376,7 +368,6 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
Expand Down
3 changes: 2 additions & 1 deletion client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3347,7 +3347,8 @@ void add_syslog(const char *line) {
"CONNECTION_ID:%lu, DB_SERVER:'%s', DB:'%s', QUERY:'%s'",
/* use the cached user/sudo_user value. */
current_os_sudouser ? current_os_sudouser
: current_os_user ? current_os_user : "--",
: current_os_user ? current_os_user
: "--",
current_user ? current_user : "--", mysql_thread_id(&mysql_handle),
current_host ? current_host : "--", current_db ? current_db : "--",
line);
Expand Down
14 changes: 9 additions & 5 deletions client/mysqlbinlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2260,8 +2260,10 @@ extern "C" bool get_one_option(int optid, const struct my_option *opt,
"--read-from-remote-source"));
[[fallthrough]];
case OPT_REMOTE_PROTO:
opt_remote_proto = (enum_remote_proto)(
find_type_or_exit(argument, &remote_proto_typelib, opt->name) - 1);
opt_remote_proto =
(enum_remote_proto)(find_type_or_exit(argument, &remote_proto_typelib,
opt->name) -
1);
break;
case OPT_MYSQL_PROTOCOL:
opt_protocol =
Expand All @@ -2274,9 +2276,11 @@ extern "C" bool get_one_option(int optid, const struct my_option *opt,
stop_datetime = convert_str_to_timestamp(stop_datetime_str);
break;
case OPT_BASE64_OUTPUT_MODE:
opt_base64_output_mode = (enum_base64_output_mode)(
find_type_or_exit(argument, &base64_output_mode_typelib, opt->name) -
1);
opt_base64_output_mode =
(enum_base64_output_mode)(find_type_or_exit(
argument, &base64_output_mode_typelib,
opt->name) -
1);
break;
case 'v':
if (argument == disabled_my_option)
Expand Down
34 changes: 19 additions & 15 deletions client/mysqldump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6060,9 +6060,9 @@ static bool get_view_structure(char *table, char *db) {
search_len =
(ulong)(strxmov(ptr, "WITH ", row[0], " CHECK OPTION", NullS) - ptr);
ptr = replace_buf;
replace_len = (ulong)(
strxmov(ptr, "*/\n/*!50002 WITH ", row[0], " CHECK OPTION", NullS) -
ptr);
replace_len = (ulong)(strxmov(ptr, "*/\n/*!50002 WITH ", row[0],
" CHECK OPTION", NullS) -
ptr);
replace(&ds_view, search_buf, search_len, replace_buf, replace_len);
}

Expand All @@ -6082,19 +6082,23 @@ static bool get_view_structure(char *table, char *db) {
host_name_str, &host_name_len);

ptr = search_buf;
search_len = (ulong)(
strxmov(ptr, "DEFINER=",
quote_name(user_name_str, quoted_user_name_str, false), "@",
quote_name(host_name_str, quoted_host_name_str, false),
" SQL SECURITY ", row[2], NullS) -
ptr);
search_len =
(ulong)(strxmov(
ptr, "DEFINER=",
quote_name(user_name_str, quoted_user_name_str, false),
"@",
quote_name(host_name_str, quoted_host_name_str, false),
" SQL SECURITY ", row[2], NullS) -
ptr);
ptr = replace_buf;
replace_len = (ulong)(
strxmov(ptr, "*/\n/*!50013 DEFINER=",
quote_name(user_name_str, quoted_user_name_str, false), "@",
quote_name(host_name_str, quoted_host_name_str, false),
" SQL SECURITY ", row[2], " */\n/*!50001", NullS) -
ptr);
replace_len =
(ulong)(strxmov(
ptr, "*/\n/*!50013 DEFINER=",
quote_name(user_name_str, quoted_user_name_str, false),
"@",
quote_name(host_name_str, quoted_host_name_str, false),
" SQL SECURITY ", row[2], " */\n/*!50001", NullS) -
ptr);
replace(&ds_view, search_buf, search_len, replace_buf, replace_len);
}

Expand Down
10 changes: 8 additions & 2 deletions client/mysqlshow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,15 @@ static int list_tables(MYSQL *mysql, const char *db, const char *table) {
}

print_trailer(
head_length, (opt_table_type ? 10 : opt_verbose > 0 ? 8 : 0),
head_length,
(opt_table_type ? 10
: opt_verbose > 0 ? 8
: 0),
(opt_table_type ? (opt_verbose > 0 ? 8 : 0) : (opt_verbose > 1 ? 10 : 0)),
!opt_table_type ? 0 : opt_verbose > 1 ? 10 : 0, 0);
!opt_table_type ? 0
: opt_verbose > 1 ? 10
: 0,
0);

if (counter && opt_verbose)
printf("%u row%s in set.\n\n", counter, (counter > 1) ? "s" : "");
Expand Down
4 changes: 2 additions & 2 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,7 @@ static void var_set_escape(struct st_command *command, VAR *dst) {
- the second string,
- a bool that is false if the parsing succeeded; true if it failed.
*/
auto parse_args = [&]() -> auto {
auto parse_args = [&]() -> auto{
// command->first_argument contains '(characters,text)'
char *p = command->first_argument;
// Find (
Expand Down Expand Up @@ -3557,7 +3557,7 @@ static void free_dynamic_strings(T *val) {
/// the function, through recursion, end up being
/// freed by dynstr_free().
template <typename T1, typename... T2>
static void free_dynamic_strings(T1 *first, T2 *... rest) {
static void free_dynamic_strings(T1 *first, T2 *...rest) {
free_dynamic_strings(first);
free_dynamic_strings(rest...);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
namespace pfs_plugin_table_v1_all_empty {

DEFINE_METHOD(int, add_tables,
(PFS_engine_table_share_proxy * */*st_share*/,
(PFS_engine_table_share_proxy * * /*st_share*/,
unsigned int /*share_count*/)) {
return 0;
}

DEFINE_METHOD(int, delete_tables,
(PFS_engine_table_share_proxy * */*st_share*/,
(PFS_engine_table_share_proxy * * /*st_share*/,
unsigned int /*share_count*/)) {
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions components/mysqlbackup/backup_page_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ bool Backup_page_tracker::page_track_get_changed_pages_init(UDF_INIT *,
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 [
[maybe_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;
}
Expand Down
2 changes: 1 addition & 1 deletion components/test/test_status_var_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class udf_list {

private:
udf_list_t set;
} * list;
} *list;

/* actual test material */
namespace udf_impl {
Expand Down
2 changes: 1 addition & 1 deletion components/test/test_udf_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class udf_list {

private:
udf_list_t set;
} * list;
} *list;

/* actual test material */
namespace udf_impl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ static void meter_change_notify_callback(const char *meter,
MeterNotifyType change) {
// just log the notification, real metric component would need to update its
// OTEL object collection
const char *change_type =
(change == MeterNotifyType::METER_ADDED)
? "added"
: (change == MeterNotifyType::METER_REMOVED) ? "removed" : "updated";
const char *change_type = (change == MeterNotifyType::METER_ADDED) ? "added"
: (change == MeterNotifyType::METER_REMOVED)
? "removed"
: "updated";
g_log.write("*** Meter change notification: %s %s\n", meter, change_type);

// to test for possible deadlock, simulate production component
Expand Down
2 changes: 1 addition & 1 deletion include/my_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ using unique_ptr_destroy_only = std::unique_ptr<T, Destroy_only<T>>;

template <typename T, typename... Args>
unique_ptr_destroy_only<T> make_unique_destroy_only(MEM_ROOT *mem_root,
Args &&... args) {
Args &&...args) {
return unique_ptr_destroy_only<T>(new (mem_root)
T(std::forward<Args>(args)...));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Component_malloc_allocator {
void deallocate(pointer p, size_type) { my_free(p); }

template <class U, class... Args>
void construct(U *p, Args &&... args) {
void construct(U *p, Args &&...args) {
assert(p != nullptr);
try {
::new ((void *)p) U(std::forward<Args>(args)...);
Expand Down
7 changes: 4 additions & 3 deletions include/mysql/plugin_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ struct MYSQL;
@return A pointer to plugin-specific, per-connection data if any.
*/

typedef void *(tracing_start_callback)(
struct st_mysql_client_plugin_TRACE *self, MYSQL *connection_handle,
enum protocol_stage stage);
typedef void *(
tracing_start_callback)(struct st_mysql_client_plugin_TRACE *self,
MYSQL *connection_handle,
enum protocol_stage stage);

/**
Trace plugin tracing_stop() method.
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ extern "C" struct command_service_st {
const struct st_command_service_cbs *callbacks,
enum cs_text_or_binary text_or_binary,
void *service_callbacks_ctx);
} * command_service;
} *command_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_locking.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ typedef int (*mysql_release_locks_t)(MYSQL_THD opaque_thd,
extern "C" struct mysql_locking_service_st {
mysql_acquire_locks_t mysql_acquire_locks;
mysql_release_locks_t mysql_release_locks;
} * mysql_locking_service;
} *mysql_locking_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_my_plugin_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C" struct my_plugin_log_service {
int (*my_plugin_log_message)(MYSQL_PLUGIN *, enum plugin_log_level,
const char *, ...)
MY_ATTRIBUTE((format(printf, 3, 4)));
} * my_plugin_log_service;
} *my_plugin_log_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_mysql_keyring.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern "C" struct mysql_keyring_service_st {
@sa my_key_generate, st_mysql_keyring::mysql_key_generate
*/
int (*my_key_generate_func)(const char *, const char *, const char *, size_t);
} * mysql_keyring_service;
} *mysql_keyring_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_mysql_password_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" struct mysql_password_policy_service_st {
st_mysql_validate_password::get_password_strength
*/
int (*my_calculate_password_strength_func)(const char *, unsigned int);
} * mysql_password_policy_service;
} *mysql_password_policy_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_mysql_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" struct mysql_string_service_st {
mysql_string_handle (*mysql_string_to_lowercase_type)(mysql_string_handle);
void (*mysql_string_free_type)(mysql_string_handle);
void (*mysql_string_iterator_free_type)(mysql_string_iterator_handle);
} * mysql_string_service;
} *mysql_string_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ extern "C" struct mysql_parser_service_st {
mysql_free_string_t mysql_free_string;
mysql_get_query_t mysql_get_query;
mysql_get_normalized_query_t mysql_get_normalized_query;
} * mysql_parser_service;
} *mysql_parser_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_plugin_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extern "C" struct plugin_registry_service_st {
*/
int (*mysql_plugin_registry_release_func)(SERVICE_TYPE(registry) *
registry_ptr);
} * plugin_registry_service;
} *plugin_registry_service;

#ifdef MYSQL_DYNAMIC_PLUGIN
#define mysql_plugin_registry_acquire() \
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_rpl_transaction_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct Transaction_termination_ctx {
extern "C" struct rpl_transaction_ctx_service_st {
int (*set_transaction_ctx)(
Transaction_termination_ctx transaction_termination_ctx);
} * rpl_transaction_ctx_service;
} *rpl_transaction_ctx_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_rpl_transaction_write_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extern "C" struct transaction_write_set_service_st {
void (*require_full_write_set)(bool requires_ws);
void (*set_write_set_memory_size_limit)(uint64 size_limit);
void (*update_write_set_memory_size_limit)(uint64 size_limit);
} * transaction_write_set_service;
} *transaction_write_set_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/service_security_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ extern "C" struct security_context_service_st {
*/
my_svc_bool (*security_context_set_option)(MYSQL_SECURITY_CONTEXT,
const char *name, void *pvalue);
} * security_context_service;
} *security_context_service;

#ifdef MYSQL_DYNAMIC_PLUGIN

Expand Down
Loading

0 comments on commit 5bfe4e9

Please sign in to comment.