def METHOD_NAME(flags, build_root):
  """Expands relative paths in a list of Clang command-line flags.
  Args:
    flags: The list of flags passed to Clang.
    build_root: The current directory when running the Clang compiler. Should be
        an absolute path.
  Returns:
    A list of flags with relative paths replaced by absolute paths.
  """
  new_flags = []
  make_next_absolute = False
  for flag in flags:
    new_flag = flag
    if make_next_absolute:
      make_next_absolute = False
      if not flag.startswith('/'):
        new_flag = os.path.join(build_root, flag)
    for path_flag in PATH_FLAGS:
      if flag == path_flag:
        make_next_absolute = True
        break
      if flag.startswith(path_flag):
        path = flag[len(path_flag):]
        new_flag = path_flag + os.path.join(build_root, path)
        break
    if new_flag:
      new_flags.append(new_flag)
  return new_flags