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

Commit

Permalink
Fixes #7 Header files ending in hpp aren't system
Browse files Browse the repository at this point in the history
  • Loading branch information
theandrewdavis committed Mar 18, 2016
1 parent 432bdb1 commit 0291410
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4738,6 +4738,10 @@ def _ClassifyInclude(fileinfo, include, is_system):
# those already checked for above.
is_cpp_h = include in _CPP_HEADERS

# Headers with C++ extensions shouldn't be considered C system headers
if is_system and os.path.splitext(include)[1] in ['.hpp', '.hxx', '.h++']:
is_system = False

if is_system:
if is_cpp_h:
return _CPP_SYS_HEADER
Expand Down
19 changes: 19 additions & 0 deletions cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4320,6 +4320,13 @@ def testBuildInclude(self):
self.TestLint('#include "Python.h"', '')
self.TestLint('#include "lua.h"', '')

def testHppInclude(self):
code = '\n'.join([
'#include <vector>',
'#include <boost/any.hpp>'
])
self.TestLanguageRulesCheck('foo.h', code, '')

def testBuildPrintfFormat(self):
error_collector = ErrorCollector(self.assertTrue)
cpplint.ProcessFileData(
Expand Down Expand Up @@ -4709,6 +4716,18 @@ def testClassifyInclude(self):
classify_include(file_info('foo/foo.cc'),
'string',
False))
self.assertEqual(cpplint._OTHER_HEADER,
classify_include(file_info('foo/foo.cc'),
'boost/any.hpp',
True))
self.assertEqual(cpplint._OTHER_HEADER,
classify_include(file_info('foo/foo.hxx'),
'boost/any.hpp',
True))
self.assertEqual(cpplint._OTHER_HEADER,
classify_include(file_info('foo/foo.h++'),
'boost/any.hpp',
True))

self.assertEqual(cpplint._LIKELY_MY_HEADER,
classify_include(file_info('foo/foo.cc'),
Expand Down

0 comments on commit 0291410

Please sign in to comment.