third_party/blink/tools/blinkpy/style/checkers/cpp.py
def check_for_header_guard(filename, clean_lines, error):
    """Checks that the file contains a header guard.

    Logs an error if no #ifndef header guard is present.  For other
    headers, checks that the full pathname is used.

    Args:
      filename: The name of the C++ header file.
      lines: An array of strings, each representing a line of the file.
      error: The function to call with any errors found.
    """
    raw_lines = clean_lines.lines_without_raw_strings

    cpp_var = get_header_guard_cpp_variable(filename)

    ifndef = None
    ifndef_line_number = 0
    define = None
    for line_number, line in enumerate(raw_lines):
        line_split = line.split()
        if len(line_split) >= 2:
            # find the first occurrence of #ifndef and #define, save arg
            if not ifndef and line_split[0] == '#ifndef':
                # set ifndef to the header guard presented on the #ifndef line.
                ifndef = line_split[1]
                ifndef_line_number = line_number
            if not define and line_split[0] == '#define':
                define = line_split[1]
            if define and ifndef:
                break

    if not ifndef or not define or ifndef != define:
        error(
            0, 'build/header_guard', 5,
            'No #ifndef header guard found, suggested CPP variable is: %s' %
            cpp_var)
        return

    # The guard should be File_h or, for Chromium style, BLINK_PATH_TO_FILE_H_.
    if ifndef != cpp_var:
        error(ifndef_line_number, 'build/header_guard', 5,
              '#ifndef header guard has wrong style, please use: %s' % cpp_var)
Checks that the file contains a header guard.

    Logs an error if no #ifndef header guard is present.  For other
    headers, checks that the full pathname is used.

    Args:
      filename: The name of the C++ header file.
      lines: An array of strings, each representing a line of the file.
      error: The function to call with any errors found.
    
Checks that the file contains a header guard.
Logs an error if no #ifndef header guard is present.  For other
headers, checks that the full pathname is used.
Checks that the file contains a header guard . Logs an error if no #ifndef header guard is present . For other headers checks that the full pathname is used .
def check_for_header_guard(filename, clean_lines, error):
    raw_lines = clean_lines.lines_without_raw_strings
    cpp_var = get_header_guard_cpp_variable(filename)
    ifndef = None
    ifndef_line_number = 0
    define = None
    for line_number, line in enumerate(raw_lines):
        line_split = line.split()
        if len(line_split) >= 2:
            if not ifndef and line_split[0] == '#ifndef':
                ifndef = line_split[1]
                ifndef_line_number = line_number
            if not define and line_split[0] == '#define':
                define = line_split[1]
            if define and ifndef:
                break
    if not ifndef or not define or ifndef != define:
        error(
            0, 'build/header_guard', 5,
            'No #ifndef header guard found, suggested CPP variable is: %s' %
            cpp_var)
        return
    if ifndef != cpp_var:
        error(ifndef_line_number, 'build/header_guard', 5,
              '#ifndef header guard has wrong style, please use: %s' % cpp_var)
def check_for_header_guard ( filename , clean_lines , error ) : raw_lines = clean_lines . lines_without_raw_strings cpp_var = get_header_guard_cpp_variable ( filename ) ifndef = None ifndef_line_number = 0 define = None for line_number , line in enumerate ( raw_lines ) : line_split = line . split ( ) if len ( line_split ) >= 2 : if not ifndef and line_split [ 0 ] == '#ifndef' : ifndef = line_split [ 1 ] ifndef_line_number = line_number if not define and line_split [ 0 ] == '#define' : define = line_split [ 1 ] if define and ifndef : break if not ifndef or not define or ifndef != define : error ( 0 , 'build/header_guard' , 5 , 'No #ifndef header guard found, suggested CPP variable is: %s' % cpp_var ) return if ifndef != cpp_var : error ( ifndef_line_number , 'build/header_guard' , 5 , '#ifndef header guard has wrong style, please use: %s' % cpp_var )
Checks that the file contains a header guard.
Checks that the file contains a header guard .
"""Checks that the file contains a header guard.

    Logs an error if no #ifndef header guard is present.  For other
    headers, checks that the full pathname is used.

    Args:
      filename: The name of the C++ header file.
      lines: An array of strings, each representing a line of the file.
      error: The function to call with any errors found.
    """ # find the first occurrence of #ifndef and #define, save arg # set ifndef to the header guard presented on the #ifndef line. # The guard should be File_h or, for Chromium style, BLINK_PATH_TO_FILE_H_.
filename
The name of the C++ header file.
The name of the C ++ header file .
clean_lines
error
The function to call with any errors found.
The function to call with any errors found .
lines
An array of strings, each representing a line of the file.
An array of strings each representing a line of the file .