Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 5 additions & 8 deletions cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6019,7 +6019,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
('<memory>', ('allocator', 'make_shared', 'make_unique', 'shared_ptr',
'unique_ptr', 'weak_ptr')),
('<queue>', ('queue', 'priority_queue',)),
('<set>', ('multiset',)),
('<set>', ('set', 'multiset',)),
('<stack>', ('stack',)),
('<string>', ('char_traits', 'basic_string',)),
('<tuple>', ('tuple',)),
Expand Down Expand Up @@ -6072,12 +6072,9 @@ def ExpectingFunctionArgs(clean_lines, linenum):
(re.compile(r'((\bstd::)|[^>.:])\b' + _template + r'(<.*?>)?\([^\)]'),
_template,
_header))
# Match set<type>, but not foo->set<type>, foo.set<type>
_re_pattern_headers_maybe_templates.append(
(re.compile(r'[^>.]\bset\s*\<'),
'set<>',
'<set>'))
# Match 'map<type> var' and 'std::map<type>(...)', but not 'map<type>(...)''

# Map is often overloaded. Only check, if it is fully qualified.
# Match 'std::map<type>(...)', but not 'map<type>(...)''
_re_pattern_headers_maybe_templates.append(
(re.compile(r'(std\b::\bmap\s*\<)|(^(std\b::\b)map\b\(\s*\<)'),
'map<>',
Expand All @@ -6088,7 +6085,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
for _header, _templates in _HEADERS_CONTAINING_TEMPLATES:
for _template in _templates:
_re_pattern_templates.append(
(re.compile(r'(\<|\b)' + _template + r'\s*\<'),
(re.compile(r'((^|(^|\s|((^|\W)::))std::)|[^>.:]\b)' + _template + r'\s*\<'),
_template + '<>',
_header))

Expand Down
6 changes: 6 additions & 0 deletions cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,12 @@ def testIncludeWhatYouUse(self):
auto res = map<Bar>();
""",
'')
# False positive for boost::container::set
self.TestIncludeWhatYouUse(
"""
boost::container::set<int> foo;
""",
'')

def testFilesBelongToSameModule(self):
f = cpplint.FilesBelongToSameModule
Expand Down