mirror of
https://github.com/google/styleguide.git
synced 2024-03-22 13:11:43 +08:00
Remove presubmit check for DISALLOW_* macros
Before C++11, we were using a hack to disable copy constructors or copy assignment by declaring the methods private and not implementing them. This hack required the respective macros to be placed in the private: declarations of a class. The macros have switched to use the C++11 "= delete" syntax some time ago in both v8 and chromium: https://codereview.chromium.org/1123723003/ https://codereview.chromium.org/2017213002 Also the comments are now updated, since the macros do not need to be in the private: declarations any more: https://chromium-review.googlesource.com/c/577687 https://chromium-review.googlesource.com/c/578027 This change also removes the presubmit check that checked that the macros are only used in the private declarations.
This commit is contained in:
parent
d75bd35c8f
commit
9883c51578
31
cpplint/cpplint.py
vendored
31
cpplint/cpplint.py
vendored
|
@ -3072,36 +3072,6 @@ def CheckComment(line, filename, linenum, next_line_start, error):
|
||||||
'Should have a space between // and comment')
|
'Should have a space between // and comment')
|
||||||
|
|
||||||
|
|
||||||
def CheckAccess(filename, clean_lines, linenum, nesting_state, error):
|
|
||||||
"""Checks for improper use of DISALLOW* macros.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
filename: The name of the current file.
|
|
||||||
clean_lines: A CleansedLines instance containing the file.
|
|
||||||
linenum: The number of the line to check.
|
|
||||||
nesting_state: A NestingState instance which maintains information about
|
|
||||||
the current stack of nested blocks being parsed.
|
|
||||||
error: The function to call with any errors found.
|
|
||||||
"""
|
|
||||||
line = clean_lines.elided[linenum] # get rid of comments and strings
|
|
||||||
|
|
||||||
matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|'
|
|
||||||
r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line)
|
|
||||||
if not matched:
|
|
||||||
return
|
|
||||||
if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo):
|
|
||||||
if nesting_state.stack[-1].access != 'private':
|
|
||||||
error(filename, linenum, 'readability/constructors', 3,
|
|
||||||
'%s must be in the private: section' % matched.group(1))
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Found DISALLOW* macro outside a class declaration, or perhaps it
|
|
||||||
# was used inside a function when it should have been part of the
|
|
||||||
# class declaration. We could issue a warning here, but it
|
|
||||||
# probably resulted in a compiler error already.
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
|
def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
|
||||||
"""Checks for the correctness of various spacing issues in the code.
|
"""Checks for the correctness of various spacing issues in the code.
|
||||||
|
|
||||||
|
@ -4338,7 +4308,6 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
|
||||||
CheckBraces(filename, clean_lines, linenum, error)
|
CheckBraces(filename, clean_lines, linenum, error)
|
||||||
CheckTrailingSemicolon(filename, clean_lines, linenum, error)
|
CheckTrailingSemicolon(filename, clean_lines, linenum, error)
|
||||||
CheckEmptyBlockBody(filename, clean_lines, linenum, error)
|
CheckEmptyBlockBody(filename, clean_lines, linenum, error)
|
||||||
CheckAccess(filename, clean_lines, linenum, nesting_state, error)
|
|
||||||
CheckSpacing(filename, clean_lines, linenum, nesting_state, error)
|
CheckSpacing(filename, clean_lines, linenum, nesting_state, error)
|
||||||
CheckOperatorSpacing(filename, clean_lines, linenum, error)
|
CheckOperatorSpacing(filename, clean_lines, linenum, error)
|
||||||
CheckParenthesisSpacing(filename, clean_lines, linenum, error)
|
CheckParenthesisSpacing(filename, clean_lines, linenum, error)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user