From 8d3377e923751fff4a4bec5b57f211ed60c3ddaf Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 2 Apr 2020 16:58:05 -0700 Subject: [PATCH] [clang-tidy] Use C++ using instead of typedef Found with modernize-use-using Signed-off-by: Rosen Penev --- .clang-tidy | 2 +- src/builtin_string.cpp | 4 ++-- src/complete.cpp | 5 ++--- src/tinyexpr.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index a3daf4dd2..0b3e1187c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,cert-*,performance-*,portability-*,modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals' +Checks: 'clang-diagnostic-*,clang-analyzer-*,cert-*,performance-*,portability-*,modernize-use-auto,modernize-loop-convert,modernize-use-bool-literals,modernize-use-using' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 525f63e73..bfeac357d 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -133,7 +133,7 @@ class arg_iterator_t { // This is used by the string subcommands to communicate with the option parser which flags are // valid and get the result of parsing the command for flags. -typedef struct { //!OCLINT(too many fields) +using options_t = struct options_t { //!OCLINT(too many fields) bool all_valid = false; bool chars_valid = false; bool count_valid = false; @@ -185,7 +185,7 @@ typedef struct { //!OCLINT(too many fields) const wchar_t *arg2 = nullptr; escape_string_style_t escape_style = STRING_STYLE_SCRIPT; -} options_t; +}; /// This handles the `--style=xxx` flag. static int handle_flag_1(wchar_t **argv, parser_t &parser, io_streams_t &streams, diff --git a/src/complete.cpp b/src/complete.cpp index bbc5a59e1..b65ea3455 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -89,7 +89,7 @@ static const wcstring &C_(const wcstring &s) { return s; } /// If option is non-empty, it specifies a switch for the command. If \c comp is also not empty, it /// contains a list of non-switch arguments that may only follow directly after the specified /// switch. -typedef struct complete_entry_opt { +using complete_entry_opt_t = struct complete_entry_opt { // Text of the option (like 'foo'). wcstring option; // Type of the option: args-oly, short, single_long, or double_long. @@ -119,8 +119,7 @@ typedef struct complete_entry_opt { } DIE("unreachable"); } - -} complete_entry_opt_t; +}; /// Last value used in the order field of completion_entry_t. static std::atomic k_complete_order{0}; diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index dc1206154..e67cc2667 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -74,13 +74,13 @@ typedef struct te_expr { te_expr *parameters[]; } te_expr; -typedef struct te_builtin { +using te_builtin = struct { const char *name; const void *address; int type; -} te_builtin; +}; -typedef struct state { +using state = struct { union { double value; const void *function; @@ -89,7 +89,7 @@ typedef struct state { const char *next; int type; te_error_type_t error; -} state; +}; /* Parses the input expression. */ /* Returns NULL on error. */