From 6f4a9d527c98e8591cf7a2082d5781040f864f17 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 25 Nov 2019 16:56:39 -0800 Subject: [PATCH] [clang-tidy] Use C++ using instead of C typedef Found with modernize-use-using Signed-off-by: Rosen Penev --- src/builtin_string.cpp | 2 +- src/complete.cpp | 4 ++-- src/fish_indent.cpp | 2 +- src/highlight.cpp | 2 +- src/iothread.cpp | 2 +- src/kill.cpp | 2 +- src/pager.cpp | 6 +++--- src/parser_keywords.cpp | 2 +- src/proc.cpp | 2 +- src/tinyexpr.cpp | 6 +++--- src/utf8.cpp | 4 ++-- src/wcstringutil.cpp | 2 +- src/wutil.cpp | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 46944e1e4..7dbf58e58 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -1222,7 +1222,7 @@ static int string_sub(parser_t &parser, io_streams_t &streams, int argc, wchar_t int nsub = 0; arg_iterator_t aiter(argv, optind, streams); while (const wcstring *s = aiter.nextstr()) { - typedef wcstring::size_type size_type; + using size_type = wcstring::size_type; size_type pos = 0; size_type count = wcstring::npos; if (opts.start > 0) { diff --git a/src/complete.cpp b/src/complete.cpp index e014ead62..fe4d67a40 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -124,7 +124,7 @@ typedef struct complete_entry_opt { static std::atomic k_complete_order{0}; /// Struct describing a command completion. -typedef std::list option_list_t; +using option_list_t = std::list; class completion_entry_t { public: /// List of all options. @@ -166,7 +166,7 @@ struct equal_to { } }; } // namespace std -typedef std::unordered_set completion_entry_set_t; +using completion_entry_set_t = std::unordered_set; static owning_lock s_completion_set; /// Completion "wrapper" support. The map goes from wrapping-command to wrapped-command-list. diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index 5a2474f42..8d23f8142 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -47,7 +47,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #define SPACES_PER_INDENT 4 // An indent_t represents an abstract indent depth. 2 means we are in a doubly-nested block, etc. -typedef unsigned int indent_t; +using indent_t = unsigned int; static bool dump_parse_tree = false; static int ret = 0; diff --git a/src/highlight.cpp b/src/highlight.cpp index 3f354f090..a9e0550bd 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -774,7 +774,7 @@ class highlighter_t { // Working directory. const wcstring working_directory; // The resulting colors. - typedef std::vector color_array_t; + using color_array_t = std::vector; color_array_t color_array; // The parse tree of the buff. parse_node_tree_t parse_tree; diff --git a/src/iothread.cpp b/src/iothread.cpp index 4d4211d3a..eb49ac00f 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -41,7 +41,7 @@ static void iothread_service_main_thread_requests(); static void iothread_service_result_queue(); -typedef std::function void_function_t; +using void_function_t = std::function; struct work_request_t { void_function_t handler; diff --git a/src/kill.cpp b/src/kill.cpp index e13626595..f7460cd24 100644 --- a/src/kill.cpp +++ b/src/kill.cpp @@ -15,7 +15,7 @@ #include "fallback.h" // IWYU pragma: keep /** Kill ring */ -typedef std::list kill_list_t; +using kill_list_t = std::list; static kill_list_t kill_list; void kill_add(wcstring str) { diff --git a/src/pager.cpp b/src/pager.cpp index 51e96df39..a26711a41 100644 --- a/src/pager.cpp +++ b/src/pager.cpp @@ -20,9 +20,9 @@ #include "screen.h" #include "wutil.h" // IWYU pragma: keep -typedef pager_t::comp_t comp_t; -typedef std::vector completion_list_t; -typedef std::vector comp_info_list_t; +using comp_t = pager_t::comp_t; +using completion_list_t = std::vector; +using comp_info_list_t = std::vector; /// The minimum width (in characters) the terminal must to show completions at all. #define PAGER_MIN_WIDTH 16 diff --git a/src/parser_keywords.cpp b/src/parser_keywords.cpp index 80003be71..7c0c4065c 100644 --- a/src/parser_keywords.cpp +++ b/src/parser_keywords.cpp @@ -9,7 +9,7 @@ #include "common.h" #include "fallback.h" // IWYU pragma: keep -typedef std::unordered_set string_set_t; +using string_set_t = std::unordered_set; static const wcstring skip_keywords[]{ L"else", diff --git a/src/proc.cpp b/src/proc.cpp index d61c5bed7..f450fbb89 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -290,7 +290,7 @@ io_chain_t job_t::all_io_redirections() const { return result; } -typedef unsigned int process_generation_count_t; +using process_generation_count_t = unsigned int; /// A list of pids/pgids that have been disowned. They are kept around until either they exit or /// we exit. Poll these from time-to-time to prevent zombie processes from happening (#5342). diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index c84c02436..035ea15b9 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -38,9 +38,9 @@ // TODO: It would be nice not to rely on a typedef for this, especially one that can only do // functions with two args. -typedef double (*te_fun2)(double, double); -typedef double (*te_fun1)(double); -typedef double (*te_fun0)(); +using te_fun2 = double (*)(double, double); +using te_fun1 = double (*)(double); +using te_fun0 = double (*)(); enum { TE_CONSTANT = 0, diff --git a/src/utf8.cpp b/src/utf8.cpp index 843492e60..1086fd8f1 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -33,10 +33,10 @@ #define _BOM 0xfeff // We can tweak the following typedef to allow us to simulate Windows-style 16 bit wchar's on Unix. -typedef wchar_t utf8_wchar_t; +using utf8_wchar_t = wchar_t; #define UTF8_WCHAR_MAX (wchar_t) std::numeric_limits::max() -typedef std::basic_string utf8_wstring_t; +using utf8_wstring_t = std::basic_string; static size_t utf8_to_wchar_internal(const char *in, size_t insize, utf8_wstring_t *out_string, int flags); diff --git a/src/wcstringutil.cpp b/src/wcstringutil.cpp index d29c1b8c3..f5a5658ae 100644 --- a/src/wcstringutil.cpp +++ b/src/wcstringutil.cpp @@ -7,7 +7,7 @@ #include "common.h" -typedef wcstring::size_type size_type; +using size_type = wcstring::size_type; wcstring_range wcstring_tok(wcstring &str, const wcstring &needle, wcstring_range last) { size_type pos = last.second == wcstring::npos ? wcstring::npos : last.first; diff --git a/src/wutil.cpp b/src/wutil.cpp index 45b24922d..14365ecf7 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -31,7 +31,7 @@ #include "flog.h" #include "wutil.h" // IWYU pragma: keep -typedef std::string cstring; +using cstring = std::string; const file_id_t kInvalidFileID = {static_cast(-1LL), static_cast(-1LL),