From 8a4bee3ed0cb1313d35f35a04341e4a0b2f5ffae Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 9 Nov 2025 21:22:54 +0100 Subject: [PATCH] build: update clang v21, fix warnings - `src/nvim/ex_cmds_defs.h`: use "U" instead of "u" per `readability-uppercase-literal-suffix` --- .clang-tidy | 3 ++ .github/scripts/install_deps.sh | 5 +++- src/nvim/arglist.c | 4 +-- src/nvim/autocmd.c | 2 +- src/nvim/buffer.c | 6 ++-- src/nvim/bufwrite.c | 6 ++-- src/nvim/cmdexpand.c | 4 +-- src/nvim/edit.c | 2 +- src/nvim/eval.c | 2 +- src/nvim/eval/fs.c | 2 +- src/nvim/eval/funcs.c | 4 +-- src/nvim/eval/userfunc.c | 2 +- src/nvim/eval/vars.c | 2 +- src/nvim/event/libuv_proc.c | 2 +- src/nvim/event/loop.c | 4 +-- src/nvim/ex_cmds.c | 10 +++---- src/nvim/ex_cmds_defs.h | 50 ++++++++++++++++----------------- src/nvim/ex_docmd.c | 2 +- src/nvim/ex_session.c | 2 +- src/nvim/file_search.c | 4 +-- src/nvim/fileio.c | 6 ++-- src/nvim/func_attr.h | 2 +- src/nvim/getchar.c | 2 +- src/nvim/highlight_group.c | 2 +- src/nvim/insexpand.c | 2 +- src/nvim/log.h | 2 +- src/nvim/macros_defs.h | 4 +-- src/nvim/map.c | 2 +- src/nvim/map_defs.h | 2 +- src/nvim/mark.c | 2 +- src/nvim/math.c | 2 +- src/nvim/memline.c | 2 +- src/nvim/memory.c | 2 +- src/nvim/ops.c | 2 +- src/nvim/option.c | 4 +-- src/nvim/os/env.c | 16 +++++------ src/nvim/os/fs.c | 2 +- src/nvim/os/lang.c | 4 +-- src/nvim/os/proc.c | 2 +- src/nvim/os/pty_proc_unix.c | 2 +- src/nvim/os/shell.c | 2 +- src/nvim/os/stdpaths.c | 2 +- src/nvim/os/time.h | 2 +- src/nvim/os/unix_defs.h | 2 +- src/nvim/os/users.c | 2 +- src/nvim/path.c | 16 +++++------ src/nvim/quickfix.c | 4 +-- src/nvim/regexp.c | 4 +-- src/nvim/register.c | 2 +- src/nvim/runtime.c | 8 +++--- src/nvim/search.c | 2 +- src/nvim/tag.c | 4 +-- src/nvim/tui/tui.c | 2 +- src/nvim/undo.c | 2 +- src/nvim/window.c | 2 +- 55 files changed, 122 insertions(+), 116 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 0a24460e6b..57d7e39bde 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -38,7 +38,9 @@ Checks: > -hicpp-signed-bitwise, -misc-unused-parameters, -modernize-macro-to-enum, + -readability-avoid-const-params-in-decls, Cosmetic: our generated declarations inherit const from definitions, -readability-avoid-nested-conditional-operator, + -readability-avoid-unconditional-preprocessor-if, False positive in generated config.h, -readability-else-after-return, -readability-enum-initial-value, -readability-function-size, @@ -50,6 +52,7 @@ Checks: > -android-*, -bugprone-easily-swappable-parameters, -bugprone-inc-dec-in-conditions, + -bugprone-reserved-identifier, We use underscore prefix to indicate private names (e.g. "_shada_mark"), -bugprone-swapped-arguments, -clang-analyzer-*, Already covered by the cmake target "clang-analyzer", -cppcoreguidelines-avoid-non-const-global-variables, diff --git a/.github/scripts/install_deps.sh b/.github/scripts/install_deps.sh index 4b4e48acbd..692860c60f 100755 --- a/.github/scripts/install_deps.sh +++ b/.github/scripts/install_deps.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e while (($# > 0)); do case $1 in @@ -17,7 +18,7 @@ if [[ $OS == Linux ]]; then if [[ $CC == clang ]]; then DEFAULT_CLANG_VERSION=$(echo | clang -dM -E - | grep __clang_major | awk '{print $3}') - CLANG_VERSION=19 + CLANG_VERSION=21 if ((DEFAULT_CLANG_VERSION >= CLANG_VERSION)); then echo "Default clang version is $DEFAULT_CLANG_VERSION, which is equal or larger than wanted version $CLANG_VERSION. Aborting!" exit 1 @@ -26,6 +27,8 @@ if [[ $OS == Linux ]]; then wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh $CLANG_VERSION + # Alternatively could use `./llvm.sh … all` above, but that is heavy/slow. + sudo apt-get install -y clang-tidy-$CLANG_VERSION sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$CLANG_VERSION 100 sudo update-alternatives --set clang /usr/bin/clang-$CLANG_VERSION sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$CLANG_VERSION 100 diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 09a8f5dffd..abe81202da 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -124,7 +124,7 @@ void alist_new(void) alist_init(curwin->w_alist); } -#if !defined(UNIX) +#ifndef UNIX /// Expand the file names in the global argument list. /// If "fnum_list" is not NULL, use "fnum_list[fnum_len]" as a list of buffer @@ -230,7 +230,7 @@ void alist_add(alist_T *al, char *fname, int set_fnum) wp->w_locked--; } -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME /// Adjust slashes in file names. Called after 'shellslash' was set. void alist_slash_adjust(void) diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index c394b06610..a5c6be1d06 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -572,7 +572,7 @@ void do_augroup(char *arg, bool del_group) } } -#if defined(EXITFREE) +#ifdef EXITFREE void free_all_autocmds(void) { FOR_ALL_AUEVENTS(event) { diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 300e4c4ce2..84c555b890 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1730,7 +1730,7 @@ static void enter_buffer(buf_T *buf) // Stop Visual mode before changing curbuf. Assumes curbuf and curwin->w_buffer is valid; if not, // buf_freeall() should've done this already! if (VIsual_active -#if defined(EXITFREE) +#ifdef EXITFREE && !entered_free_all_mem #endif ) { @@ -3177,7 +3177,7 @@ int buflist_add(char *fname, int flags) return 0; } -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME /// Adjust slashes in file names. Called after 'shellslash' was set. void buflist_slash_adjust(void) { @@ -3498,7 +3498,7 @@ void resettitle(void) ui_call_set_title(cstr_as_string(lasttitle)); } -#if defined(EXITFREE) +#ifdef EXITFREE void free_titles(void) { xfree(lasttitle); diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index 2f692f77e1..f45d01a289 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -577,7 +577,7 @@ static void emit_err(Error_T *e) } } -#if defined(UNIX) +#ifdef UNIX static int get_fileinfo_os(char *fname, FileInfo *file_info_old, bool overwriting, int *perm, bool *device, bool *newfile, Error_T *err) @@ -1158,7 +1158,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en } } -#if defined(UNIX) +#ifdef UNIX bool made_writable = false; // 'w' bit has been set // When using ":w!" and the file was read-only: make it writable @@ -1665,7 +1665,7 @@ restore_backup: lnum -= start; // compute number of written lines no_wait_return--; // may wait for return now -#if !defined(UNIX) +#ifndef UNIX fname = sfname; // use shortname now, for the messages #endif if (!filtering) { diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 6030197357..59feabc404 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -186,7 +186,7 @@ static void wildescape(expand_T *xp, const char *str, int numfiles, char **files p = vim_strsave_escaped(files[i], pat); xfree(files[i]); files[i] = p; -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME p = vim_strsave_escaped(files[i], " "); xfree(files[i]); files[i] = p; @@ -3624,7 +3624,7 @@ void globpath(char *path, char *file, garray_T *ga, int expand_options, bool dir size_t filelen = strlen(file); -#if defined(MSWIN) +#ifdef MSWIN // Using the platform's path separator (\) makes vim incorrectly // treat it as an escape character, use '/' instead. # define TMP_PATHSEPSTR "/" diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 4a87cd0a50..15c0836cbe 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2356,7 +2356,7 @@ void set_last_insert(int c) last_insert_skip = 0; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_last_insert(void) { API_CLEAR_STRING(last_insert); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 981a99ec48..0173ce0634 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -206,7 +206,7 @@ void eval_init(void) func_init(); } -#if defined(EXITFREE) +#ifdef EXITFREE void eval_clear(void) { evalvars_clear(); diff --git a/src/nvim/eval/fs.c b/src/nvim/eval/fs.c index b4e6671c6e..1235d78783 100644 --- a/src/nvim/eval/fs.c +++ b/src/nvim/eval/fs.c @@ -82,7 +82,7 @@ repeat: // Expand "~/path" for all systems and "~user/path" for Unix if ((*fnamep)[0] == '~' -#if !defined(UNIX) +#ifndef UNIX && ((*fnamep)[1] == '/' # ifdef BACKSLASH_IN_FILENAME || (*fnamep)[1] == '\\' diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 68574dee22..83dac9fc24 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2711,7 +2711,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) "find_in_path", "float", "folding", -#if defined(UNIX) +#ifdef UNIX "fork", #endif "gettext", @@ -2757,7 +2757,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) "statusline", "spell", "syntax", -#if !defined(UNIX) +#ifndef UNIX "system", #endif "tablineat", diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 842abee93c..1ffd404c71 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -1460,7 +1460,7 @@ void set_current_funccal(funccall_T *fc) current_funccal = fc; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_all_functions(void) { hashitem_T *hi; diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index 31f8a03296..fc8eb8c301 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -345,7 +345,7 @@ void evalvars_init(void) set_reg_var(0); // default for v:register is not 0 but '"' } -#if defined(EXITFREE) +#ifdef EXITFREE void evalvars_clear(void) { for (size_t i = 0; i < ARRAY_SIZE(vimvars); i++) { diff --git a/src/nvim/event/libuv_proc.c b/src/nvim/event/libuv_proc.c index 7405892af7..01076670c3 100644 --- a/src/nvim/event/libuv_proc.c +++ b/src/nvim/event/libuv_proc.c @@ -157,7 +157,7 @@ static void close_cb(uv_handle_t *handle) static void exit_cb(uv_process_t *handle, int64_t status, int term_signal) { Proc *proc = handle->data; -#if defined(MSWIN) +#ifdef MSWIN // Use stored/expected signal. term_signal = proc->exit_signal; #endif diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index 319f3701d7..f47b3a334c 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -131,7 +131,7 @@ void loop_on_put(MultiQueue *queue, void *data) } } -#if !defined(EXITFREE) +#ifndef EXITFREE static void loop_walk_cb(uv_handle_t *handle, void *arg) { if (!uv_is_closing(handle)) { @@ -173,7 +173,7 @@ bool loop_close(Loop *loop, bool wait) log_uv_handles(&loop->uv); break; } -#if defined(EXITFREE) +#ifdef EXITFREE (void)didstop; #else if (!didstop) { diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 3757d5be95..6759e10879 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1088,7 +1088,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n) static char *prevcmd = NULL; // the previous command -#if defined(EXITFREE) +#ifdef EXITFREE void free_prev_shellcmd(void) { xfree(prevcmd); @@ -1515,7 +1515,7 @@ void do_shell(char *cmd, int flags) apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, false, curbuf); } -#if !defined(UNIX) +#ifndef UNIX static char *find_pipe(const char *cmd) { bool inquote = false; @@ -1545,7 +1545,7 @@ static char *find_pipe(const char *cmd) char *make_filter_cmd(char *cmd, char *itmp, char *otmp, bool do_in) { bool is_fish_shell = -#if defined(UNIX) +#ifdef UNIX strncmp(invocation_path_tail(p_sh, NULL), "fish", 4) == 0; #else false; @@ -1589,7 +1589,7 @@ char *make_filter_cmd(char *cmd, char *itmp, char *otmp, bool do_in) xstrlcpy(buf, cmd, len); } } else { -#if defined(UNIX) +#ifdef UNIX // Put delimiters around the command (for concatenated commands) when // redirecting input and/or output. if (itmp != NULL || otmp != NULL) { @@ -4799,7 +4799,7 @@ void global_exe(char *cmd) } } -#if defined(EXITFREE) +#ifdef EXITFREE void free_old_sub(void) { sub_set_replacement((SubReplacementString) { NULL, 0, NULL }); diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index adff435317..45b189403e 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -33,34 +33,34 @@ // 3. Add documentation in ../doc/xxx.txt. Add a tag for both the short and // long name of the command. -#define EX_RANGE 0x001u // allow a linespecs -#define EX_BANG 0x002u // allow a ! after the command name -#define EX_EXTRA 0x004u // allow extra args after command name -#define EX_XFILE 0x008u // expand wildcards in extra part -#define EX_NOSPC 0x010u // no spaces allowed in the extra part -#define EX_DFLALL 0x020u // default file range is 1,$ -#define EX_WHOLEFOLD 0x040u // extend range to include whole fold also +#define EX_RANGE 0x001U // allow a linespecs +#define EX_BANG 0x002U // allow a ! after the command name +#define EX_EXTRA 0x004U // allow extra args after command name +#define EX_XFILE 0x008U // expand wildcards in extra part +#define EX_NOSPC 0x010U // no spaces allowed in the extra part +#define EX_DFLALL 0x020U // default file range is 1,$ +#define EX_WHOLEFOLD 0x040U // extend range to include whole fold also // when less than two numbers given -#define EX_NEEDARG 0x080u // argument required -#define EX_TRLBAR 0x100u // check for trailing vertical bar -#define EX_REGSTR 0x200u // allow "x for register designation -#define EX_COUNT 0x400u // allow count in argument, after command -#define EX_NOTRLCOM 0x800u // no trailing comment allowed -#define EX_ZEROR 0x1000u // zero line number allowed -#define EX_CTRLV 0x2000u // do not remove CTRL-V from argument -#define EX_CMDARG 0x4000u // allow "+command" argument -#define EX_BUFNAME 0x8000u // accepts buffer name -#define EX_BUFUNL 0x10000u // accepts unlisted buffer too -#define EX_ARGOPT 0x20000u // allow "++opt=val" argument -#define EX_SBOXOK 0x40000u // allowed in the sandbox -#define EX_CMDWIN 0x80000u // allowed in cmdline window -#define EX_MODIFY 0x100000u // forbidden in non-'modifiable' buffer -#define EX_FLAGS 0x200000u // allow flags after count in argument -#define EX_LOCK_OK 0x1000000u // command can be executed when textlock is +#define EX_NEEDARG 0x080U // argument required +#define EX_TRLBAR 0x100U // check for trailing vertical bar +#define EX_REGSTR 0x200U // allow "x for register designation +#define EX_COUNT 0x400U // allow count in argument, after command +#define EX_NOTRLCOM 0x800U // no trailing comment allowed +#define EX_ZEROR 0x1000U // zero line number allowed +#define EX_CTRLV 0x2000U // do not remove CTRL-V from argument +#define EX_CMDARG 0x4000U // allow "+command" argument +#define EX_BUFNAME 0x8000U // accepts buffer name +#define EX_BUFUNL 0x10000U // accepts unlisted buffer too +#define EX_ARGOPT 0x20000U // allow "++opt=val" argument +#define EX_SBOXOK 0x40000U // allowed in the sandbox +#define EX_CMDWIN 0x80000U // allowed in cmdline window +#define EX_MODIFY 0x100000U // forbidden in non-'modifiable' buffer +#define EX_FLAGS 0x200000U // allow flags after count in argument +#define EX_LOCK_OK 0x1000000U // command can be executed when textlock is // set; when missing disallows editing another // buffer when curbuf->b_ro_locked is set -#define EX_KEEPSCRIPT 0x4000000u // keep sctx of where command was invoked -#define EX_PREVIEW 0x8000000u // allow incremental command preview +#define EX_KEEPSCRIPT 0x4000000U // keep sctx of where command was invoked +#define EX_PREVIEW 0x8000000U // allow incremental command preview #define EX_FILES (EX_XFILE | EX_EXTRA) // multiple extra files allowed #define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file #define EX_WORD1 (EX_EXTRA | EX_NOSPC) // one extra word allowed diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 3971bf998b..3dc9df8ef0 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6353,7 +6353,7 @@ static void ex_read(exarg_T *eap) static char *prev_dir = NULL; -#if defined(EXITFREE) +#ifdef EXITFREE void free_cd_dir(void) { XFREE_CLEAR(prev_dir); diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 7af10d1a87..7f606f7b4f 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -1131,7 +1131,7 @@ static char *get_view_file(char c) *s++ = '='; } else if (vim_ispathsep(*p)) { *s++ = '='; -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME *s++ = (*p == ':') ? '-' : '+'; #else *s++ = '+'; diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 1cd747a08f..6fd22a6722 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1375,7 +1375,7 @@ char *find_file_in_path(char *ptr, size_t len, int options, int first, char *rel file_to_find, search_ctx); } -#if defined(EXITFREE) +#ifdef EXITFREE void free_findfile(void) { API_CLEAR_STRING(ff_expand_buffer); @@ -1463,7 +1463,7 @@ char *find_file_in_path_option(char *ptr, size_t len, int options, int first, ch if (vim_isAbsName(*file_to_find) // "..", "../path", "." and "./path": don't use the path_option || rel_to_curdir -#if defined(MSWIN) +#ifdef MSWIN // handle "\tmp" as absolute path || vim_ispathsep((*file_to_find)[0]) // handle "c:name" as absolute path diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 9f6ed037c7..5b659cb91d 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -279,7 +279,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, if (sfname == NULL) { sfname = fname; } -#if defined(UNIX) +#ifdef UNIX fname = sfname; #endif @@ -3274,7 +3274,7 @@ void write_lnum_adjust(linenr_T offset) } } -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME /// Convert all backslashes in fname to forward slashes in-place, /// unless when it looks like a URL. void forward_slash(char *fname) @@ -3865,7 +3865,7 @@ char *file_pat_to_reg_pat(const char *pat, const char *pat_end, char *allow_dirs return reg_pat; } -#if defined(EINTR) +#ifdef EINTR // Type of buffer size argument of read() and write() is platform-dependent. # ifdef MSWIN diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h index e19a0acd5d..b8fa3d55f6 100644 --- a/src/nvim/func_attr.h +++ b/src/nvim/func_attr.h @@ -230,7 +230,7 @@ # define FUNC_API_DEPRECATED_SINCE(X) #endif -#if defined(DEFINE_FUNC_ATTRIBUTES) +#ifdef DEFINE_FUNC_ATTRIBUTES # define FUNC_ATTR_MALLOC REAL_FATTR_MALLOC # define FUNC_ATTR_ALLOC_SIZE(x) REAL_FATTR_ALLOC_SIZE(x) # define FUNC_ATTR_ALLOC_SIZE_PROD(x, y) REAL_FATTR_ALLOC_SIZE_PROD(x, y) diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index a82c0092d6..28a2977b78 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1455,7 +1455,7 @@ static void closescript(void) curscript--; } -#if defined(EXITFREE) +#ifdef EXITFREE void close_all_scripts(void) { while (curscript >= 0) { diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 20e39304ab..892a5b4c5a 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -1529,7 +1529,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) } } -#if defined(EXITFREE) +#ifdef EXITFREE void free_highlight(void) { ga_clear(&highlight_ga); diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 17d7c9e4be..2057c73e9d 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -6400,7 +6400,7 @@ static unsigned quote_meta(char *dest, char *src, int len) return m; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_insexpand_stuff(void) { API_CLEAR_STRING(compl_orig_text); diff --git a/src/nvim/log.h b/src/nvim/log.h index 06af437ed1..d6b5784c10 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -8,7 +8,7 @@ // USDT probes. Example invocation: // NVIM_PROBE(nvim_foo_bar, 1, string.data); -#if defined(HAVE_SYS_SDT_H) +#ifdef HAVE_SYS_SDT_H # include // IWYU pragma: keep # define NVIM_PROBE(name, n, ...) STAP_PROBE##n(neovim, name, __VA_ARGS__) diff --git a/src/nvim/macros_defs.h b/src/nvim/macros_defs.h index 84417659e9..5e0252bf04 100644 --- a/src/nvim/macros_defs.h +++ b/src/nvim/macros_defs.h @@ -125,14 +125,14 @@ // Type of uv_buf_t.len is platform-dependent. // Related: https://github.com/libuv/libuv/pull/1236 -#if defined(MSWIN) +#ifdef MSWIN # define UV_BUF_LEN(x) (ULONG)(x) #else # define UV_BUF_LEN(x) (x) #endif // Type of read()/write() `count` param is platform-dependent. -#if defined(MSWIN) +#ifdef MSWIN # define IO_COUNT(x) (unsigned)(x) #else # define IO_COUNT(x) (x) diff --git a/src/nvim/map.c b/src/nvim/map.c index ccce0008b5..6e435b3609 100644 --- a/src/nvim/map.c +++ b/src/nvim/map.c @@ -23,7 +23,7 @@ #define hash_int64_t(key) hash_uint64_t((uint64_t)key) #define equal_int64_t equal_simple -#if defined(ARCH_64) +#ifdef ARCH_64 # define hash_ptr_t(key) hash_uint64_t((uint64_t)(key)) # define equal_ptr_t(a, b) equal_uint64_t((uint64_t)(a), (uint64_t)(b)) #elif defined(ARCH_32) diff --git a/src/nvim/map_defs.h b/src/nvim/map_defs.h index 4ece073ca9..dc61024c5d 100644 --- a/src/nvim/map_defs.h +++ b/src/nvim/map_defs.h @@ -9,7 +9,7 @@ #include "nvim/highlight_defs.h" #include "nvim/types_defs.h" -#if defined(__NetBSD__) +#ifdef __NetBSD__ # undef uint64_t # define uint64_t uint64_t #endif diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 200a59b243..9614d4bd74 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1810,7 +1810,7 @@ void set_last_cursor(win_T *win) } } -#if defined(EXITFREE) +#ifdef EXITFREE void free_all_marks(void) { int i; diff --git a/src/nvim/math.c b/src/nvim/math.c index 779be78e95..676610f89d 100644 --- a/src/nvim/math.c +++ b/src/nvim/math.c @@ -79,7 +79,7 @@ int xctz(uint64_t x) unsigned xpopcount(uint64_t x) { // Use compiler builtin if possible. -#if defined(__NetBSD__) +#ifdef __NetBSD__ return popcount64(x); #elif defined(__clang__) || defined(__GNUC__) return (unsigned)__builtin_popcountll(x); diff --git a/src/nvim/memline.c b/src/nvim/memline.c index b89b75d913..a0a9c84d0d 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3211,7 +3211,7 @@ static void ml_lineadd(buf_T *buf, int count) } } -#if defined(HAVE_READLINK) +#ifdef HAVE_READLINK /// Resolve a symlink in the last component of a file name. /// Note that f_resolve() does it for every part of the path, we don't do that diff --git a/src/nvim/memory.c b/src/nvim/memory.c index cc222f4259..4566ff1ad3 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -826,7 +826,7 @@ char *arena_strdup(Arena *arena, const char *str) return arena_memdupz(arena, str, strlen(str)); } -#if defined(EXITFREE) +#ifdef EXITFREE # include "nvim/autocmd.h" # include "nvim/buffer.h" diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 4e436c09f6..5bb73bd6ae 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3133,7 +3133,7 @@ const char *did_set_operatorfunc(optset_T *args FUNC_ATTR_UNUSED) return NULL; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_operatorfunc_option(void) { callback_free(&opfunc_cb); diff --git a/src/nvim/option.c b/src/nvim/option.c index deb3f1d2ba..030702ccaf 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -572,7 +572,7 @@ static const char *find_dup_item(const char *origval, const char *newval, const return NULL; } -#if defined(EXITFREE) +#ifdef EXITFREE /// Free all options. void free_all_options(void) { @@ -5764,7 +5764,7 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags) s--; } if ((*p == ' ' && ((xp->xp_backslash & XP_BS_THREE) && (p - s) < 3)) -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME || (*p == ',' && (flags & kOptFlagComma) && (p - s) < 1) #else || (*p == ',' && (flags & kOptFlagComma) && (p - s) < 2) diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index e2eecf3006..75692feb8e 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -243,7 +243,7 @@ size_t os_get_fullenv_size(void) FreeEnvironmentStringsW(envstrings); #else -# if defined(HAVE__NSGETENVIRON) +# ifdef HAVE__NSGETENVIRON char **environ = *_NSGetEnviron(); # else extern char **environ; @@ -301,7 +301,7 @@ void os_copy_fullenv(char **env, size_t env_size) FreeEnvironmentStringsW(envstrings); #else -# if defined(HAVE__NSGETENVIRON) +# ifdef HAVE__NSGETENVIRON char **environ = *_NSGetEnviron(); # else extern char **environ; @@ -360,7 +360,7 @@ char *os_getenvname_at_index(size_t index) FreeEnvironmentStringsW(envstrings); return name; #else -# if defined(HAVE__NSGETENVIRON) +# ifdef HAVE__NSGETENVIRON char **environ = *_NSGetEnviron(); # else extern char **environ; @@ -573,7 +573,7 @@ static char *os_uv_homedir(void) return NULL; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_homedir(void) { @@ -686,7 +686,7 @@ size_t expand_env_esc(const char *restrict srcp, char *restrict dst, int dstlen, } } -#if defined(UNIX) +#ifdef UNIX // Verify that we have found the end of a Unix ${VAR} style variable if (src[1] == '{' && *tail != '}') { var = NULL; @@ -698,7 +698,7 @@ size_t expand_env_esc(const char *restrict srcp, char *restrict dst, int dstlen, *var = NUL; var = vim_getenv(dst); mustfree = true; -#if defined(UNIX) +#ifdef UNIX } #endif } else if (src[1] == NUL // home directory @@ -707,7 +707,7 @@ size_t expand_env_esc(const char *restrict srcp, char *restrict dst, int dstlen, var = homedir; tail = src + 1; } else { // user directory -#if defined(UNIX) +#ifdef UNIX // Copy ~user to dst[], so we can put a NUL after it. tail = src; var = dst; @@ -775,7 +775,7 @@ size_t expand_env_esc(const char *restrict srcp, char *restrict dst, int dstlen, // if var[] ends in a path separator and tail[] starts // with it, skip a character if (after_pathsep(dst, dst + c) -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME && dst[c - 1] != ':' #endif && vim_ispathsep(*tail)) { diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 8ad75ccc1a..032e4e32f0 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -21,7 +21,7 @@ #include "nvim/os/fs.h" #include "nvim/os/os_defs.h" -#if defined(HAVE_ACL) +#ifdef HAVE_ACL # ifdef HAVE_SYS_ACL_H # include # endif diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c index 7f859a2c75..81efaa7f1a 100644 --- a/src/nvim/os/lang.c +++ b/src/nvim/os/lang.c @@ -55,7 +55,7 @@ char *get_mess_lang(void) { char *p; -#if defined(LC_MESSAGES) +#ifdef LC_MESSAGES p = get_locale_val(LC_MESSAGES); #else // This is necessary for Win32, where LC_MESSAGES is not defined and $LANG @@ -288,7 +288,7 @@ static void init_locales(void) #endif } -#if defined(EXITFREE) +#ifdef EXITFREE void free_locales(void) { if (locales == NULL) { diff --git a/src/nvim/os/proc.c b/src/nvim/os/proc.c index 275a82c41c..9281b000f7 100644 --- a/src/nvim/os/proc.c +++ b/src/nvim/os/proc.c @@ -15,7 +15,7 @@ # include #endif -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ # include # include # include diff --git a/src/nvim/os/pty_proc_unix.c b/src/nvim/os/pty_proc_unix.c index 091e1f1036..55881f4fe7 100644 --- a/src/nvim/os/pty_proc_unix.c +++ b/src/nvim/os/pty_proc_unix.c @@ -296,7 +296,7 @@ void pty_proc_teardown(Loop *loop) static void init_child(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NORETURN { -#if defined(HAVE__NSGETENVIRON) +#ifdef HAVE__NSGETENVIRON # define environ (*_NSGetEnviron()) #else extern char **environ; diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 799ac33d78..4cc9188d16 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -137,7 +137,7 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in "[[ ${BASH_VERSINFO[0]} -ge 4 ]] && shopt -s globstar; "; bool is_fish_shell = -#if defined(UNIX) +#ifdef UNIX strncmp(invocation_path_tail(p_sh, NULL), "fish", 4) == 0; #else false; diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index a05b3c287c..19f541d252 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -207,7 +207,7 @@ char *get_xdg_home(const XDGVarType idx) if (dir) { xmemcpyz(IObuff, appname, appname_len); -#if defined(MSWIN) +#ifdef MSWIN if (idx == kXDGDataHome || idx == kXDGStateHome) { xstrlcat(IObuff, "-data", IOSIZE); } diff --git a/src/nvim/os/time.h b/src/nvim/os/time.h index 7d4745509d..171f9071fc 100644 --- a/src/nvim/os/time.h +++ b/src/nvim/os/time.h @@ -2,7 +2,7 @@ #include #include // IWYU pragma: keep -#include // IWYU pragma: keep +#include // NOLINT(misc-header-include-cycle) IWYU pragma: keep #include "nvim/os/time_defs.h" // IWYU pragma: keep diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h index d2bec7b361..cdd4418e69 100644 --- a/src/nvim/os/unix_defs.h +++ b/src/nvim/os/unix_defs.h @@ -9,7 +9,7 @@ #include #include #include -#if defined(HAVE_TERMIOS_H) +#ifdef HAVE_TERMIOS_H # include #endif // IWYU pragma: end_exports diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index b3be026e33..f863459022 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -176,7 +176,7 @@ char *os_get_userdir(const char *name) return NULL; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_users(void) { diff --git a/src/nvim/path.c b/src/nvim/path.c index 6ac594529c..999194895b 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -58,22 +58,22 @@ FileComparison path_full_compare(char *const s1, char *const s2, const bool chec const bool expandenv) FUNC_ATTR_NONNULL_ALL { - char expanded1[MAXPATHL]; + char expand1[MAXPATHL]; char full1[MAXPATHL]; char full2[MAXPATHL]; FileID file_id_1, file_id_2; if (expandenv) { - expand_env(s1, expanded1, MAXPATHL); + expand_env(s1, expand1, MAXPATHL); } else { - xstrlcpy(expanded1, s1, MAXPATHL); + xstrlcpy(expand1, s1, MAXPATHL); } - bool id_ok_1 = os_fileid(expanded1, &file_id_1); + bool id_ok_1 = os_fileid(expand1, &file_id_1); bool id_ok_2 = os_fileid(s2, &file_id_2); if (!id_ok_1 && !id_ok_2) { // If os_fileid() doesn't work, may compare the names. if (checkname) { - vim_FullName(expanded1, full1, MAXPATHL, false); + vim_FullName(expand1, full1, MAXPATHL, false); vim_FullName(s2, full2, MAXPATHL, false); if (path_fnamecmp(full1, full2) == 0) { return kEqualFileNames; @@ -562,7 +562,7 @@ bool path_has_wildcard(const char *p) FUNC_ATTR_NONNULL_ALL { for (; *p; MB_PTR_ADV(p)) { -#if defined(UNIX) +#ifdef UNIX if (p[0] == '\\' && p[1] != NUL) { p++; continue; @@ -594,7 +594,7 @@ bool path_has_exp_wildcard(const char *p) FUNC_ATTR_NONNULL_ALL { for (; *p != NUL; MB_PTR_ADV(p)) { -#if defined(UNIX) +#ifdef UNIX if (p[0] == '\\' && p[1] != NUL) { p++; continue; @@ -729,7 +729,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in // compile the regexp into a program regmatch_T regmatch; -#if defined(UNIX) +#ifdef UNIX // Ignore case if given 'wildignorecase', else respect 'fileignorecase'. regmatch.rm_ic = (flags & EW_ICASE) || p_fic; #else diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 3fea62e68a..1c332d5885 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1886,7 +1886,7 @@ static void decr_quickfix_busy(void) #endif } -#if defined(EXITFREE) +#ifdef EXITFREE void check_quickfix_busy(void) { if (quickfix_busy != 0) { @@ -7668,7 +7668,7 @@ void ex_helpgrep(exarg_T *eap) } } -#if defined(EXITFREE) +#ifdef EXITFREE void free_quickfix(void) { qf_free_all(NULL); diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index eca906faf0..142777b94a 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2085,7 +2085,7 @@ int vim_regsub_multi(regmmatch_T *rmp, linenr_T lnum, char *source, char *dest, #define MAX_REGSUB_NESTING 4 static char *eval_result[MAX_REGSUB_NESTING] = { NULL, NULL, NULL, NULL }; -#if defined(EXITFREE) +#ifdef EXITFREE void free_resub_eval_result(void) { for (int i = 0; i < MAX_REGSUB_NESTING; i++) { @@ -16117,7 +16117,7 @@ void vim_regfree(regprog_T *prog) } } -#if defined(EXITFREE) +#ifdef EXITFREE void free_regexp_stuff(void) { ga_clear(®stack); diff --git a/src/nvim/register.c b/src/nvim/register.c index c45332556a..0012e4b44c 100644 --- a/src/nvim/register.c +++ b/src/nvim/register.c @@ -944,7 +944,7 @@ void shift_delete_registers(bool y_append) y_regs[1].y_array = NULL; // set register "1 to empty } -#if defined(EXITFREE) +#ifdef EXITFREE void clear_registers(void) { for (int i = 0; i < NUM_REGISTERS; i++) { diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index e1b797c7a0..e8fbda49b9 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -1786,7 +1786,7 @@ static inline char *add_dir(char *dest, const char *const dir, const size_t dir_ size_t appname_len = strlen(appname); assert(appname_len < (IOSIZE - sizeof("-data"))); xmemcpyz(IObuff, appname, appname_len); -#if defined(MSWIN) +#ifdef MSWIN if (type == kXDGDataHome || type == kXDGStateHome) { xstrlcat(IObuff, "-data", IOSIZE); appname_len += 5; @@ -1857,7 +1857,7 @@ char *runtimepath_default(bool clean_arg) if (data_home != NULL) { data_len = strlen(data_home); size_t nvim_data_size = appname_len; -#if defined(MSWIN) +#ifdef MSWIN nvim_data_size += sizeof("-data") - 1; // -1: NULL byte should be ignored #endif if (data_len != 0) { @@ -2559,7 +2559,7 @@ void ex_scriptnames(exarg_T *eap) } } -#if defined(BACKSLASH_IN_FILENAME) +#ifdef BACKSLASH_IN_FILENAME /// Fix slashes in the list of script names for 'shellslash'. void scriptnames_slash_adjust(void) { @@ -2620,7 +2620,7 @@ char *get_scriptname(sctx_T script_ctx, bool *should_free) } } -#if defined(EXITFREE) +#ifdef EXITFREE void free_scriptnames(void) { profile_reset(); diff --git a/src/nvim/search.c b/src/nvim/search.c index cbebfccf6e..555f6e6d94 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -289,7 +289,7 @@ static inline void free_spat(SearchPattern *const spat) xfree(spat->additional_data); } -#if defined(EXITFREE) +#ifdef EXITFREE void free_search_patterns(void) { for (size_t i = 0; i < ARRAY_SIZE(spats); i++) { diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a4ed2f9c48..6a46f0a5fe 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -242,7 +242,7 @@ const char *did_set_tagfunc(optset_T *args) return retval == FAIL ? e_invarg : NULL; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_tagfunc_option(void) { callback_free(&tfu_cb); @@ -2452,7 +2452,7 @@ static bool found_tagfile_cb(int num_fnames, char **fnames, bool all, void *cook return num_fnames > 0; } -#if defined(EXITFREE) +#ifdef EXITFREE void free_tag_stuff(void) { ga_clear_strings(&tag_fnames); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 04ca165081..6d277bd7e5 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2564,7 +2564,7 @@ static void flush_buf(TUIData *tui) static const char *tui_get_stty_erase(TermInput *input) { static char stty_erase[2] = { 0 }; -#if defined(HAVE_TERMIOS_H) +#ifdef HAVE_TERMIOS_H struct termios t; if (tcgetattr(input->in_fd, &t) != -1) { stty_erase[0] = (char)t.c_cc[VERASE]; diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 766346ba1c..86195d5ccd 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -158,7 +158,7 @@ static bool undo_undoes = false; static int lastmark = 0; -#if defined(U_DEBUG) +#ifdef U_DEBUG // Check the undo structures for being valid. Print a warning when something // looks wrong. static int seen_b_u_curhead; diff --git a/src/nvim/window.c b/src/nvim/window.c index f5f69fa88c..0069636148 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3369,7 +3369,7 @@ static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp) return wp; } -#if defined(EXITFREE) +#ifdef EXITFREE void win_free_all(void) { // avoid an error for switching tabpage with the cmdline window open