diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-30 18:41:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 18:41:52 +0800 |
commit | 95dbf1af73a6f73f08f988adb6d6436d680f53c4 (patch) | |
tree | 1c9eb6ba454eaa3b0c5d66a920d0fc53acc6c48f /src/clint.py | |
parent | ce56e0a845d68862118f44cb66c5f080e3c1bbed (diff) | |
download | rneovim-95dbf1af73a6f73f08f988adb6d6436d680f53c4.tar.gz rneovim-95dbf1af73a6f73f08f988adb6d6436d680f53c4.tar.bz2 rneovim-95dbf1af73a6f73f08f988adb6d6436d680f53c4.zip |
refactor: move extern variables out of _defs.h files (#26320)
Diffstat (limited to 'src/clint.py')
-rwxr-xr-x | src/clint.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/clint.py b/src/clint.py index cb43ed59c7..a45969af31 100755 --- a/src/clint.py +++ b/src/clint.py @@ -880,18 +880,21 @@ def CheckForHeaderGuard(filename, lines, error): error(filename, 0, 'build/header_guard', 5, 'No "#pragma once" found in header') + def CheckIncludes(filename, lines, error): - """Checks that headers only include _defs headers + """Checks that headers only include _defs headers. Args: filename: The name of the C++ header file. lines: An array of strings, each representing a line of the file. error: The function to call with any errors found. """ - if filename.endswith('.c.h') or filename.endswith('.in.h') or FileInfo(filename).RelativePath() in { + if (filename.endswith('.c.h') + or filename.endswith('.in.h') + or FileInfo(filename).RelativePath() in { 'func_attr.h', 'os/pty_process.h', - }: + }): return # These should be synced with the ignored headers in the `iwyu` target in @@ -999,6 +1002,21 @@ def CheckIncludes(filename, lines, error): 'Headers should not include non-"_defs" headers') +def CheckNonSymbols(filename, lines, error): + """Checks that a _defs.h header only contains non-symbols. + + Args: + filename: The name of the C++ header file. + lines: An array of strings, each representing a line of the file. + error: The function to call with any errors found. + """ + for i, line in enumerate(lines): + # Only a check against extern variables for now. + if line.startswith('EXTERN ') or line.startswith('extern '): + error(filename, i, 'build/defs_header', 5, + '"_defs" headers should not contain extern variables') + + def CheckForBadCharacters(filename, lines, error): """Logs an error for each line containing bad characters. @@ -2286,6 +2304,8 @@ def ProcessFileData(filename, file_extension, lines, error, if file_extension == 'h': CheckForHeaderGuard(filename, lines, error) CheckIncludes(filename, lines, error) + if filename.endswith('/defs.h') or filename.endswith('_defs.h'): + CheckNonSymbols(filename, lines, error) RemoveMultiLineComments(filename, lines, error) clean_lines = CleansedLines(lines, init_lines) |