parameters: (clang_commandline, out_dir,
                                     additional_flags)
return_statement: return clang_flags
docstring: Extracts relevant command line options from |clang_commandline|
  
    Args:
      clang_commandline: (String) Full Clang invocation.
      out_dir: (String) Absolute path to ninja build directory. Relative paths in
          the command line are relative to |out_dir|.
      additional_flags: (List of String) Additional flags to return.
  
    Returns:
      (List of Strings) The list of command line flags for this source file. Can
      be empty.
docstring_summary: Extracts relevant command line options from |clang_commandline|
docstring_tokens: Extracts relevant command line options from |clang_commandline|
function: def GetClangOptionsFromCommandLine(clang_commandline, out_dir,
                                     additional_flags):
    """Extracts relevant command line options from |clang_commandline|
  
    Args:
      clang_commandline: (String) Full Clang invocation.
      out_dir: (String) Absolute path to ninja build directory. Relative paths in
          the command line are relative to |out_dir|.
      additional_flags: (List of String) Additional flags to return.
  
    Returns:
      (List of Strings) The list of command line flags for this source file. Can
      be empty.
    """
    clang_flags = [] + additional_flags
  
    # Parse flags that are important for YCM's purposes.
    clang_tokens = shlex.split(clang_commandline)
    for flag_index, flag in enumerate(clang_tokens):
      if flag.startswith('-I'):
        # Relative paths need to be resolved, because they're relative to the
        # output dir, not the source.
        if flag[2] == '/':
          clang_flags.append(flag)
        else:
          abs_path = os.path.normpath(os.path.join(out_dir, flag[2:]))
          clang_flags.append('-I' + abs_path)
      elif flag.startswith('-std'):
        clang_flags.append(flag)
      elif flag.startswith('-') and flag[1] in 'DWFfmO':
        if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard':
          # These flags causes libclang (3.3) to crash. Remove it until things
          # are fixed.
          continue
        clang_flags.append(flag)
      elif flag == '-isysroot':
        # On Mac -isysroot <path> is used to find the system headers.
        # Copy over both flags.
        if flag_index + 1 < len(clang_tokens):
          clang_flags.append(flag)
          clang_flags.append(clang_tokens[flag_index + 1])
      elif flag.startswith('--sysroot='):
        # On Linux we use a sysroot image.
        sysroot_path = flag.lstrip('--sysroot=')
        if sysroot_path.startswith('/'):
          clang_flags.append(flag)
        else:
          abs_path = os.path.normpath(os.path.join(out_dir, sysroot_path))
          clang_flags.append('--sysroot=' + abs_path)
    return clang_flags
function_tokens: def GetClangOptionsFromCommandLine ( clang_commandline , out_dir , additional_flags ) : clang_flags = [ ] + additional_flags # Parse flags that are important for YCM's purposes. clang_tokens = shlex . split ( clang_commandline ) for flag_index , flag in enumerate ( clang_tokens ) : if flag . startswith ( '-I' ) : # Relative paths need to be resolved, because they're relative to the # output dir, not the source. if flag [ 2 ] == '/' : clang_flags . append ( flag ) else : abs_path = os . path . normpath ( os . path . join ( out_dir , flag [ 2 : ] ) ) clang_flags . append ( '-I' + abs_path ) elif flag . startswith ( '-std' ) : clang_flags . append ( flag ) elif flag . startswith ( '-' ) and flag [ 1 ] in 'DWFfmO' : if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard' : # These flags causes libclang (3.3) to crash. Remove it until things # are fixed. continue clang_flags . append ( flag ) elif flag == '-isysroot' : # On Mac -isysroot <path> is used to find the system headers. # Copy over both flags. if flag_index + 1 < len ( clang_tokens ) : clang_flags . append ( flag ) clang_flags . append ( clang_tokens [ flag_index + 1 ] ) elif flag . startswith ( '--sysroot=' ) : # On Linux we use a sysroot image. sysroot_path = flag . lstrip ( '--sysroot=' ) if sysroot_path . startswith ( '/' ) : clang_flags . append ( flag ) else : abs_path = os . path . normpath ( os . path . join ( out_dir , sysroot_path ) ) clang_flags . append ( '--sysroot=' + abs_path ) return clang_flags