Skip to content
This repository was archived by the owner on Jul 13, 2019. It is now read-only.

Commit 0291410

Browse files
Fixes #7 Header files ending in hpp aren't system
1 parent 432bdb1 commit 0291410

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

cpplint.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4738,6 +4738,10 @@ def _ClassifyInclude(fileinfo, include, is_system):
47384738
# those already checked for above.
47394739
is_cpp_h = include in _CPP_HEADERS
47404740

4741+
# Headers with C++ extensions shouldn't be considered C system headers
4742+
if is_system and os.path.splitext(include)[1] in ['.hpp', '.hxx', '.h++']:
4743+
is_system = False
4744+
47414745
if is_system:
47424746
if is_cpp_h:
47434747
return _CPP_SYS_HEADER

cpplint_unittest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4320,6 +4320,13 @@ def testBuildInclude(self):
43204320
self.TestLint('#include "Python.h"', '')
43214321
self.TestLint('#include "lua.h"', '')
43224322

4323+
def testHppInclude(self):
4324+
code = '\n'.join([
4325+
'#include <vector>',
4326+
'#include <boost/any.hpp>'
4327+
])
4328+
self.TestLanguageRulesCheck('foo.h', code, '')
4329+
43234330
def testBuildPrintfFormat(self):
43244331
error_collector = ErrorCollector(self.assertTrue)
43254332
cpplint.ProcessFileData(
@@ -4709,6 +4716,18 @@ def testClassifyInclude(self):
47094716
classify_include(file_info('foo/foo.cc'),
47104717
'string',
47114718
False))
4719+
self.assertEqual(cpplint._OTHER_HEADER,
4720+
classify_include(file_info('foo/foo.cc'),
4721+
'boost/any.hpp',
4722+
True))
4723+
self.assertEqual(cpplint._OTHER_HEADER,
4724+
classify_include(file_info('foo/foo.hxx'),
4725+
'boost/any.hpp',
4726+
True))
4727+
self.assertEqual(cpplint._OTHER_HEADER,
4728+
classify_include(file_info('foo/foo.h++'),
4729+
'boost/any.hpp',
4730+
True))
47124731

47134732
self.assertEqual(cpplint._LIKELY_MY_HEADER,
47144733
classify_include(file_info('foo/foo.cc'),

0 commit comments

Comments
 (0)