Skip to content

Commit fc81e80

Browse files
committed
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: #21521 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5842366 commit fc81e80

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tools/cpplint.py

+17
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,21 @@ def CheckForBadCharacters(filename, lines, error):
19001900
error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.')
19011901

19021902

1903+
def CheckInlineHeader(filename, include_state, error):
1904+
"""Logs an error if both a header and its inline variant are included."""
1905+
1906+
all_headers = dict(item for sublist in include_state.include_list
1907+
for item in sublist)
1908+
bad_headers = set('%s.h' % name[:-6] for name in all_headers.keys()
1909+
if name.endswith('-inl.h'))
1910+
bad_headers &= set(all_headers.keys())
1911+
1912+
for name in bad_headers:
1913+
err = '%s includes both %s and %s-inl.h' % (filename, name, name)
1914+
linenum = all_headers[name]
1915+
error(filename, linenum, 'build/include', 5, err)
1916+
1917+
19031918
def CheckForNewlineAtEOF(filename, lines, error):
19041919
"""Logs an error if there is no newline char at the end of the file.
19051920
@@ -5866,6 +5881,8 @@ def ProcessFileData(filename, file_extension, lines, error,
58665881

58675882
CheckForNewlineAtEOF(filename, lines, error)
58685883

5884+
CheckInlineHeader(filename, include_state, error)
5885+
58695886
def ProcessConfigOverrides(filename):
58705887
""" Loads the configuration files and processes the config overrides.
58715888

0 commit comments

Comments
 (0)