Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tools: fix cpplint.py header rules
THIS COMMIT SHOULD GO WITH THE NEXT. IT WILL FIND NEW LINT.

PR-URL: #26306
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
refack committed Mar 12, 2019
commit 902998190a55d6915b881936f6dd5b6e9cca6ad8
25 changes: 13 additions & 12 deletions tools/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,10 @@ def GetNonHeaderExtensions():
'build/forward_decl',
'build/header_guard',
'build/include',
'build/include_subdir',
'build/include_alpha',
'build/include_inline',
'build/include_order',
'build/include_subdir',
'build/include_what_you_use',
'build/namespaces_literals',
'build/namespaces',
Expand Down Expand Up @@ -356,8 +357,9 @@ def GetNonHeaderExtensions():
# off by default (i.e., categories that must be enabled by the --filter= flags).
# All entries here should start with a '-' or '+', as in the --filter= flag.
_DEFAULT_FILTERS = [
'-build/include',
'-build/include_alpha',
'-build/include_subdir',
'-build/include_what_you_use',
'-legal/copyright',
]

Expand Down Expand Up @@ -834,9 +836,9 @@ class _IncludeState(object):
# needs to move backwards, CheckNextIncludeOrder will raise an error.
_INITIAL_SECTION = 0
_MY_H_SECTION = 1
_C_SECTION = 2
_CPP_SECTION = 3
_OTHER_H_SECTION = 4
_OTHER_H_SECTION = 2
_C_SECTION = 3
_CPP_SECTION = 4

_TYPE_NAMES = {
_C_SYS_HEADER: 'C system header',
Expand All @@ -848,9 +850,9 @@ class _IncludeState(object):
_SECTION_NAMES = {
_INITIAL_SECTION: "... nothing. (This can't be an error.)",
_MY_H_SECTION: 'a header this file implements',
_OTHER_H_SECTION: 'other header',
_C_SECTION: 'C system header',
_CPP_SECTION: 'C++ system header',
_OTHER_H_SECTION: 'other header',
}

def __init__(self):
Expand Down Expand Up @@ -2130,7 +2132,7 @@ def CheckInlineHeader(filename, include_state, error):
for name in bad_headers:
err = '%s includes both %s and %s-inl.h' % (filename, name, name)
linenum = all_headers[name]
error(filename, linenum, 'build/include', 5, err)
error(filename, linenum, 'build/include_inline', 5, err)


def CheckForNewlineAtEOF(filename, lines, error):
Expand Down Expand Up @@ -4768,11 +4770,10 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
include_state.include_list[-1].append((include, linenum))

# We want to ensure that headers appear in the right order:
# 1) for foo.cc, foo.h (preferred location)
# 2) c system files
# 3) cpp system files
# 4) for foo.cc, foo.h (deprecated location)
# 5) other google headers
# 1) for foo.cc, foo.h
# 2) other project headers
# 3) c system files
# 4) cpp system files
#
# We classify each include statement as one of those 5 types
# using a number of techniques. The include_state object keeps
Expand Down