summaryrefslogtreecommitdiff
path: root/tools/cpplint.py
diff options
context:
space:
mode:
authorUjjwal Sharma <usharma1998@gmail.com>2018-06-25 17:02:22 +0530
committerUjjwal Sharma <usharma1998@gmail.com>2018-07-29 19:13:00 +0530
commitfc81e801913de3e3f3c0c8e26c105f983a74e539 (patch)
tree12c666d1b0dbabf537b4df3bb4f89365a67c939c /tools/cpplint.py
parent5842366ae83a36065d626e3937ad8fc327efab30 (diff)
downloadandroid-node-v8-fc81e801913de3e3f3c0c8e26c105f983a74e539.tar.gz
android-node-v8-fc81e801913de3e3f3c0c8e26c105f983a74e539.tar.bz2
android-node-v8-fc81e801913de3e3f3c0c8e26c105f983a74e539.zip
tools: update cpplint to check for inline headers
Update cpplint.py to check for inline headers when the corresponding header is already included. PR-URL: https://github.com/nodejs/node/pull/21521 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'tools/cpplint.py')
-rw-r--r--tools/cpplint.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/cpplint.py b/tools/cpplint.py
index a0f67a4ca8..d96713aa80 100644
--- a/tools/cpplint.py
+++ b/tools/cpplint.py
@@ -1900,6 +1900,21 @@ def CheckForBadCharacters(filename, lines, error):
error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.')
+def CheckInlineHeader(filename, include_state, error):
+ """Logs an error if both a header and its inline variant are included."""
+
+ all_headers = dict(item for sublist in include_state.include_list
+ for item in sublist)
+ bad_headers = set('%s.h' % name[:-6] for name in all_headers.keys()
+ if name.endswith('-inl.h'))
+ bad_headers &= set(all_headers.keys())
+
+ for name in bad_headers:
+ err = '%s includes both %s and %s-inl.h' % (filename, name, name)
+ linenum = all_headers[name]
+ error(filename, linenum, 'build/include', 5, err)
+
+
def CheckForNewlineAtEOF(filename, lines, error):
"""Logs an error if there is no newline char at the end of the file.
@@ -5866,6 +5881,8 @@ def ProcessFileData(filename, file_extension, lines, error,
CheckForNewlineAtEOF(filename, lines, error)
+ CheckInlineHeader(filename, include_state, error)
+
def ProcessConfigOverrides(filename):
""" Loads the configuration files and processes the config overrides.