[iwyu] Turn inclusion presubmit warning into and error.
R=machenbach@chromium.org Change-Id: I9adf50ef62abf310a0722160ff7997b87e1733f6 Reviewed-on: https://chromium-review.googlesource.com/664800 Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#48009}
This commit is contained in:
parent
725c15c794
commit
b45a27373d
11
PRESUBMIT.py
11
PRESUBMIT.py
@ -153,16 +153,17 @@ def _CheckUnwantedDependencies(input_api, output_api):
|
||||
return results
|
||||
|
||||
|
||||
# TODO(mstarzinger): Similar checking should be made available as part of
|
||||
# tools/presubmit.py (note that tools/check-inline-includes.sh exists).
|
||||
def _CheckNoInlineHeaderIncludesInNormalHeaders(input_api, output_api):
|
||||
"""Attempts to prevent inclusion of inline headers into normal header
|
||||
files. This tries to establish a layering where inline headers can be
|
||||
included by other inline headers or compilation units only."""
|
||||
file_inclusion_pattern = r'(?!.+-inl\.h).+\.h'
|
||||
include_directive_pattern = input_api.re.compile(r'#include ".+-inl.h"')
|
||||
include_warning = (
|
||||
'You might be including an inline header (e.g. foo-inl.h) within a\n'
|
||||
'normal header (e.g. bar.h) file. Can you avoid introducing the\n'
|
||||
'#include? The commit queue will not block on this warning.')
|
||||
include_error = (
|
||||
'You are including an inline header (e.g. foo-inl.h) within a normal\n'
|
||||
'header (e.g. bar.h) file. This violates layering of dependencies.')
|
||||
|
||||
def FilterFile(affected_file):
|
||||
black_list = (_EXCLUDED_PATHS +
|
||||
@ -181,7 +182,7 @@ def _CheckNoInlineHeaderIncludesInNormalHeaders(input_api, output_api):
|
||||
'%s:%d\n %s' % (local_path, line_number, line.strip()))
|
||||
|
||||
if problems:
|
||||
return [output_api.PresubmitPromptOrNotify(include_warning, problems)]
|
||||
return [output_api.PresubmitError(include_error, problems)]
|
||||
else:
|
||||
return []
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user