Skip to content

Commit 482a2b8

Browse files
geoffviolatkruse
authored andcommitted
handle other header files for build include subdir
build/include_subdir should handle arbitrarily header file extensions. Tests include "test.hh" // now emits warning with defaults include "test.h" // same warning with defaults include "test.aa" // can emit warning if .aa set as header
1 parent 35f2836 commit 482a2b8

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

cpplint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5074,10 +5074,12 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
50745074
#
50755075
# We also make an exception for Lua headers, which follow google
50765076
# naming convention but not the include convention.
5077-
match = Match(r'#include\s*"([^/]+\.h)"', line)
5078-
if match and not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1)):
5079-
error(filename, linenum, 'build/include_subdir', 4,
5080-
'Include the directory when naming .h files')
5077+
match = Match(r'#include\s*"([^/]+\.(.*))"', line)
5078+
if match:
5079+
if (IsHeaderExtension(match.group(2)) and
5080+
not _THIRD_PARTY_HEADERS_PATTERN.match(match.group(1))):
5081+
error(filename, linenum, 'build/include_subdir', 4,
5082+
'Include the directory when naming header files')
50815083

50825084
# we shouldn't include a file more than once. actually, there are a
50835085
# handful of instances where doing so is okay, but in general it's

cpplint_unittest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4968,8 +4968,13 @@ def testBuildHeaderGuardWithRepository(self):
49684968
def testBuildInclude(self):
49694969
# Test that include statements have slashes in them.
49704970
self.TestLint('#include "foo.h"',
4971-
'Include the directory when naming .h files'
4971+
'Include the directory when naming header files'
49724972
' [build/include_subdir] [4]')
4973+
self.TestLint('#include "bar.hh"',
4974+
'Include the directory when naming header files'
4975+
' [build/include_subdir] [4]')
4976+
self.TestLint('#include "baz.aa"', '')
4977+
self.TestLint('#include "dir/foo.h"', '')
49734978
self.TestLint('#include "Python.h"', '')
49744979
self.TestLint('#include "lua.h"', '')
49754980

0 commit comments

Comments
 (0)