Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b520216

Browse filesBrowse files
ryzokukentargos
authored andcommitted
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 87ed6e6 commit b520216
Copy full SHA for b520216

File tree

Expand file treeCollapse file tree

1 file changed

+17
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-0
lines changed
Open diff view settings
Collapse file

‎tools/cpplint.py‎

Copy file name to clipboardExpand all lines: tools/cpplint.py
+17Lines changed: 17 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.