MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / CheckAccess

Function CheckAccess

util/cpplint.py:3072–3099  ·  view source on GitHub ↗

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

(filename, clean_lines, linenum, nesting_state, error)

Source from the content-addressed store, hash-verified

3070
3071
3072def CheckAccess(filename, clean_lines, linenum, nesting_state, error):
3073 """Checks for improper use of DISALLOW* macros.
3074
3075 Args:
3076 filename: The name of the current file.
3077 clean_lines: A CleansedLines instance containing the file.
3078 linenum: The number of the line to check.
3079 nesting_state: A NestingState instance which maintains information about
3080 the current stack of nested blocks being parsed.
3081 error: The function to call with any errors found.
3082 """
3083 line = clean_lines.elided[linenum] # get rid of comments and strings
3084
3085 matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|'
3086 r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line)
3087 if not matched:
3088 return
3089 if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo):
3090 if nesting_state.stack[-1].access != 'private':
3091 error(filename, linenum, 'readability/constructors', 3,
3092 '%s must be in the private: section' % matched.group(1))
3093
3094 else:
3095 # Found DISALLOW* macro outside a class declaration, or perhaps it
3096 # was used inside a function when it should have been part of the
3097 # class declaration. We could issue a warning here, but it
3098 # probably resulted in a compiler error already.
3099 pass
3100
3101
3102def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):

Callers 1

CheckStyleFunction · 0.85

Calls 2

MatchFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected