Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing #include <ostream> #2616

Merged
merged 2 commits into from
Mar 25, 2019
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
2 changes: 2 additions & 0 deletions Firestore/core/src/firebase/firestore/timestamp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "Firestore/core/include/firebase/firestore/timestamp.h"

#include <ostream>

#include "Firestore/core/src/firebase/firestore/util/hard_assert.h"
#include "absl/strings/str_cat.h"

Expand Down
2 changes: 2 additions & 0 deletions Firestore/core/src/firebase/firestore/util/status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "Firestore/core/src/firebase/firestore/util/status.h"

#include <ostream>

#include "Firestore/core/src/firebase/firestore/util/string_format.h"
#include "absl/memory/memory.h"

Expand Down
26 changes: 24 additions & 2 deletions scripts/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@
# This is set by --headers flag.
_hpp_headers = set(['h'])

# Source filename extensions
_cpp_extensions = set(['cc', 'mm'])

# {str, bool}: a map from error categories to booleans which indicate if the
# category should be suppressed for every line.
_global_error_suppressions = {}
Expand All @@ -569,6 +572,15 @@ def ProcessHppHeadersOption(val):
def IsHeaderExtension(file_extension):
return file_extension in _hpp_headers

def IsSourceExtension(file_extension):
return file_extension in _cpp_extensions

def IsSourceFilename(filename):
global _cpp_extensions
ext = os.path.splitext(filename)[-1].lower()
ext = ext[1:] # leading dot
return IsSourceExtension(ext)

def ParseNolintSuppressions(filename, raw_line, linenum, error):
"""Updates the global list of line error-suppressions.

Expand Down Expand Up @@ -4579,7 +4591,7 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
error(filename, linenum, 'build/include', 4,
'"%s" already included at %s:%s' %
(include, filename, duplicate_line))
elif (include.endswith('.cc') and
elif (IsSourceFilename(include) and
os.path.dirname(fileinfo.RepositoryName()) != os.path.dirname(include)):
error(filename, linenum, 'build/include', 4,
'Do not include .cc files from other packages')
Expand Down Expand Up @@ -5390,6 +5402,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
('<map>', ('map', 'multimap',)),
('<memory>', ('allocator', 'make_shared', 'make_unique', 'shared_ptr',
'unique_ptr', 'weak_ptr')),
('<ostream>', ('ostream',)),
('<queue>', ('queue', 'priority_queue',)),
('<set>', ('set', 'multiset',)),
('<stack>', ('stack',)),
Expand All @@ -5415,6 +5428,7 @@ def ExpectingFunctionArgs(clean_lines, linenum):
)

_RE_PATTERN_STRING = re.compile(r'\bstring\b')
_RE_PATTERN_OSTREAM = re.compile(r'\bostream\b')

_re_pattern_headers_maybe_templates = []
for _header, _templates in _HEADERS_MAYBE_TEMPLATES:
Expand Down Expand Up @@ -5553,6 +5567,14 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
if prefix.endswith('std::') or not prefix.endswith('::'):
required['<string>'] = (linenum, 'string')

# Ostream is special too -- also non-templatized
wilhuff marked this conversation as resolved.
Show resolved Hide resolved
matched = _RE_PATTERN_OSTREAM.search(line)
if matched:
if IsSourceFilename(filename):
required['<ostream>'] = (linenum, 'ostream')
else:
required['<iosfwd>'] = (linenum, 'ostream')

for pattern, template, header in _re_pattern_headers_maybe_templates:
if pattern.search(line):
required[header] = (linenum, template)
Expand Down Expand Up @@ -5605,7 +5627,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
# didn't include it in the .h file.
# TODO(unknown): Do a better job of finding .h files so we are confident that
# not having the .h file means there isn't one.
if filename.endswith('.cc') and not header_found:
if IsSourceFilename(filename) and not header_found:
return

# All the lines have been processed, report the errors found.
Expand Down