tools/vim/chromium.ycm_extra_conf.py
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

  def abspath(path):
    return os.path.normpath(os.path.join(out_dir, path))

  # Parse flags that are important for YCM's purposes.
  clang_tokens = shlex.split(clang_commandline)
  include_pattern = re.compile(r'^(-I|-isystem|-F)(.+)$')
  for flag_index, flag in enumerate(clang_tokens):
    include_match = include_pattern.match(flag)
    if include_match:
      # Relative paths need to be resolved, because they're relative to the
      # output dir, not the source.
      path = abspath(include_match.group(2))
      clang_flags.append(include_match.group(1) + path)
    elif flag.startswith('-std') or flag == '-nostdinc++':
      clang_flags.append(flag)
    elif flag.startswith('-march=arm'):
      # Value armv7-a of this flag causes a parsing error with a message
      # "ClangParseError: Failed to parse the translation unit."
      continue
    elif flag.startswith('-') and flag[1] in 'DWfmO':
      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' or flag == '-isystem' or flag == '-I':
      if flag_index + 1 < len(clang_tokens):
        clang_flags.append(flag)
        clang_flags.append(abspath(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:
        clang_flags.append('--sysroot=' + abspath(sysroot_path))
  return clang_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.
  
Extracts relevant command line options from |clang_commandline|
Extracts relevant command line options from |clang_commandline|
def GetClangOptionsFromCommandLine(clang_commandline, out_dir,
                                   additional_flags):
  clang_flags = [] + additional_flags
  def abspath(path):
    return os.path.normpath(os.path.join(out_dir, path))
  clang_tokens = shlex.split(clang_commandline)
  include_pattern = re.compile(r'^(-I|-isystem|-F)(.+)$')
  for flag_index, flag in enumerate(clang_tokens):
    include_match = include_pattern.match(flag)
    if include_match:
      path = abspath(include_match.group(2))
      clang_flags.append(include_match.group(1) + path)
    elif flag.startswith('-std') or flag == '-nostdinc++':
      clang_flags.append(flag)
    elif flag.startswith('-march=arm'):
      continue
    elif flag.startswith('-') and flag[1] in 'DWfmO':
      if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard':
        continue
      clang_flags.append(flag)
    elif flag == '-isysroot' or flag == '-isystem' or flag == '-I':
      if flag_index + 1 < len(clang_tokens):
        clang_flags.append(flag)
        clang_flags.append(abspath(clang_tokens[flag_index + 1]))
    elif flag.startswith('--sysroot='):
      sysroot_path = flag.lstrip('--sysroot=')
      if sysroot_path.startswith('/'):
        clang_flags.append(flag)
      else:
        clang_flags.append('--sysroot=' + abspath(sysroot_path))
  return clang_flags
def GetClangOptionsFromCommandLine ( clang_commandline , out_dir , additional_flags ) : clang_flags = [ ] + additional_flags def abspath ( path ) : return os . path . normpath ( os . path . join ( out_dir , path ) ) clang_tokens = shlex . split ( clang_commandline ) include_pattern = re . compile ( r'^(-I|-isystem|-F)(.+)$' ) for flag_index , flag in enumerate ( clang_tokens ) : include_match = include_pattern . match ( flag ) if include_match : path = abspath ( include_match . group ( 2 ) ) clang_flags . append ( include_match . group ( 1 ) + path ) elif flag . startswith ( '-std' ) or flag == '-nostdinc++' : clang_flags . append ( flag ) elif flag . startswith ( '-march=arm' ) : continue elif flag . startswith ( '-' ) and flag [ 1 ] in 'DWfmO' : if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard' : continue clang_flags . append ( flag ) elif flag == '-isysroot' or flag == '-isystem' or flag == '-I' : if flag_index + 1 < len ( clang_tokens ) : clang_flags . append ( flag ) clang_flags . append ( abspath ( clang_tokens [ flag_index + 1 ] ) ) elif flag . startswith ( '--sysroot=' ) : sysroot_path = flag . lstrip ( '--sysroot=' ) if sysroot_path . startswith ( '/' ) : clang_flags . append ( flag ) else : clang_flags . append ( '--sysroot=' + abspath ( sysroot_path ) ) return clang_flags
Extracts relevant command line options from |clang_commandline|
Extracts relevant command line options from |clang_commandline|
"""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.
  """ # Parse flags that are important for YCM's purposes. # Relative paths need to be resolved, because they're relative to the # output dir, not the source. # Value armv7-a of this flag causes a parsing error with a message # "ClangParseError: Failed to parse the translation unit." # These flags causes libclang (3.3) to crash. Remove it until things # are fixed. # On Linux we use a sysroot image.
(List of Strings) The list of command line flags for this source file. Can
be empty.
( List of Strings ) The list of command line flags for this source file . Can be empty .
clang_commandline
(String) Full Clang invocation.
( String ) Full Clang invocation .
out_dir
(String) Absolute path to ninja build directory. Relative paths in
the command line are relative to |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.
( List of String ) Additional flags to return .