Skip to content

Commit e3482c5

Browse files
committed
remove transitive include exemption from IWYU
1 parent 30e502e commit e3482c5

File tree

3 files changed

+4
-92
lines changed

3 files changed

+4
-92
lines changed

cpplint.py

100644100755
Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6040,34 +6040,6 @@ def FilesBelongToSameModule(filename_cc, filename_h):
60406040
return files_belong_to_same_module, common_path
60416041

60426042

6043-
def UpdateIncludeState(filename, include_dict, io=codecs):
6044-
"""Fill up the include_dict with new includes found from the file.
6045-
6046-
Args:
6047-
filename: the name of the header to read.
6048-
include_dict: a dictionary in which the headers are inserted.
6049-
io: The io factory to use to read the file. Provided for testability.
6050-
6051-
Returns:
6052-
True if a header was successfully added. False otherwise.
6053-
"""
6054-
headerfile = None
6055-
try:
6056-
with io.open(filename, 'r', 'utf8', 'replace') as headerfile:
6057-
linenum = 0
6058-
for line in headerfile:
6059-
linenum += 1
6060-
clean_line = CleanseComments(line)
6061-
match = _RE_PATTERN_INCLUDE.search(clean_line)
6062-
if match:
6063-
include = match.group(2)
6064-
include_dict.setdefault(include, linenum)
6065-
return True
6066-
except IOError:
6067-
return False
6068-
6069-
6070-
60716043
def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
60726044
io=codecs):
60736045
"""Reports for missing stl includes.
@@ -6123,36 +6095,10 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
61236095
if prefix.endswith('std::') or not prefix.endswith('::'):
61246096
required[header] = (linenum, template)
61256097

6126-
# The policy is that if you #include something in foo.h you don't need to
6127-
# include it again in foo.cc. Here, we will look at possible includes.
61286098
# Let's flatten the include_state include_list and copy it into a dictionary.
61296099
include_dict = dict([item for sublist in include_state.include_list
61306100
for item in sublist])
61316101

6132-
# Did we find the header for this file (if any) and successfully load it?
6133-
header_found = False
6134-
6135-
# Use the absolute path so that matching works properly.
6136-
abs_filename = FileInfo(filename).FullName()
6137-
6138-
# For Emacs's flymake.
6139-
# If cpplint is invoked from Emacs's flymake, a temporary file is generated
6140-
# by flymake and that file name might end with '_flymake.cc'. In that case,
6141-
# restore original file name here so that the corresponding header file can be
6142-
# found.
6143-
# e.g. If the file name is 'foo_flymake.cc', we should search for 'foo.h'
6144-
# instead of 'foo_flymake.h'
6145-
abs_filename = re.sub(r'_flymake\.cc$', '.cc', abs_filename)
6146-
6147-
# include_dict is modified during iteration, so we iterate over a copy of
6148-
# the keys.
6149-
header_keys = list(include_dict.keys())
6150-
for header in header_keys:
6151-
(same_module, common_path) = FilesBelongToSameModule(abs_filename, header)
6152-
fullpath = common_path + header
6153-
if same_module and UpdateIncludeState(fullpath, include_dict, io):
6154-
header_found = True
6155-
61566102
# All the lines have been processed, report the errors found.
61576103
for required_header_unstripped in sorted(required, key=required.__getitem__):
61586104
template = required[required_header_unstripped][1]

cpplint_unittest.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,43 +1157,6 @@ def testIncludeWhatYouUse(self):
11571157
""",
11581158
'')
11591159

1160-
# Test the UpdateIncludeState code path.
1161-
mock_header_contents = ['#include "blah/foo.h"', '#include "blah/bar.h"']
1162-
message = self.PerformIncludeWhatYouUse(
1163-
'#include "blah/a.h"',
1164-
filename='blah/a.cc',
1165-
io=MockIo(mock_header_contents))
1166-
self.assertEqual(message, '')
1167-
1168-
mock_header_contents = ['#include <set>']
1169-
message = self.PerformIncludeWhatYouUse(
1170-
"""#include "blah/a.h"
1171-
std::set<int> foo;""",
1172-
filename='blah/a.cc',
1173-
io=MockIo(mock_header_contents))
1174-
self.assertEqual(message, '')
1175-
1176-
# Make sure we can find the correct header file if the cc file seems to be
1177-
# a temporary file generated by Emacs's flymake.
1178-
mock_header_contents = ['']
1179-
message = self.PerformIncludeWhatYouUse(
1180-
"""#include "blah/a.h"
1181-
std::set<int> foo;""",
1182-
filename='blah/a_flymake.cc',
1183-
io=MockIo(mock_header_contents))
1184-
self.assertEqual(message, 'Add #include <set> for set<> '
1185-
'[build/include_what_you_use] [4]')
1186-
1187-
# Make sure we find the headers with relative paths.
1188-
mock_header_contents = ['']
1189-
message = self.PerformIncludeWhatYouUse(
1190-
"""#include "%s/a.h"
1191-
std::set<int> foo;""" % os.path.basename(os.getcwd()),
1192-
filename='a.cc',
1193-
io=MockIo(mock_header_contents))
1194-
self.assertEqual(message, 'Add #include <set> for set<> '
1195-
'[build/include_what_you_use] [4]')
1196-
11971160
def testFilesBelongToSameModule(self):
11981161
f = cpplint.FilesBelongToSameModule
11991162
self.assertEqual((True, ''), f('a.cc', 'a.h'))

samples/codelite-sample/simple.def

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ src/*
33
4
44
Done processing src/pptable.cpp
55
Done processing src/pptable.h
6-
Total errors found: 682
6+
Total errors found: 685
77

88
src/pptable.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
99
src/pptable.cpp:1: Include the directory when naming header files [build/include_subdir] [4]
@@ -605,7 +605,10 @@ src/pptable.cpp:660: Tab found; better to use spaces [whitespace/tab] [1]
605605
src/pptable.cpp:661: Tab found; better to use spaces [whitespace/tab] [1]
606606
src/pptable.cpp:662: Tab found; better to use spaces [whitespace/tab] [1]
607607
src/pptable.cpp:663: Tab found; better to use spaces [whitespace/tab] [1]
608+
src/pptable.cpp:526: Add #include <map> for map<> [build/include_what_you_use] [4]
609+
src/pptable.cpp:592: Add #include <vector> for vector<> [build/include_what_you_use] [4]
608610
src/pptable.cpp:602: Add #include <cstdio> for sprintf [build/include_what_you_use] [4]
611+
src/pptable.cpp:648: Add #include <string> for string [build/include_what_you_use] [4]
609612
src/pptable.h:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
610613
src/pptable.h:1: #ifndef header guard has wrong style, please use: SAMPLES_CODELITE_SAMPLE_SRC_PPTABLE_H_ [build/header_guard] [5]
611614
src/pptable.h:131: #endif line should be "#endif // SAMPLES_CODELITE_SAMPLE_SRC_PPTABLE_H_" [build/header_guard] [5]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy