MCPcopy Create free account
hub / github.com/BVLC/caffe / CheckAccess

Function CheckAccess

scripts/cpp_lint.py:2490–2518  ·  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

2488 'TODO(my_username) should be followed by a space')
2489
2490def CheckAccess(filename, clean_lines, linenum, nesting_state, error):
2491 """Checks for improper use of DISALLOW* macros.
2492
2493 Args:
2494 filename: The name of the current file.
2495 clean_lines: A CleansedLines instance containing the file.
2496 linenum: The number of the line to check.
2497 nesting_state: A _NestingState instance which maintains information about
2498 the current stack of nested blocks being parsed.
2499 error: The function to call with any errors found.
2500 """
2501 line = clean_lines.elided[linenum] # get rid of comments and strings
2502
2503 matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|'
2504 r'DISALLOW_EVIL_CONSTRUCTORS|'
2505 r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line)
2506 if not matched:
2507 return
2508 if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo):
2509 if nesting_state.stack[-1].access != 'private':
2510 error(filename, linenum, 'readability/constructors', 3,
2511 '%s must be in the private: section' % matched.group(1))
2512
2513 else:
2514 # Found DISALLOW* macro outside a class declaration, or perhaps it
2515 # was used inside a function when it should have been part of the
2516 # class declaration. We could issue a warning here, but it
2517 # probably resulted in a compiler error already.
2518 pass
2519
2520
2521def FindNextMatchingAngleBracket(clean_lines, linenum, init_suffix):

Callers 1

CheckStyleFunction · 0.85

Calls 1

MatchFunction · 0.85

Tested by

no test coverage detected