
import os

# Given an iterable object that produces strings (flags for Clang), removes the
# '-c' and '-o' options that Clang does not like to see when it's producing
# completions for a file.
def PrepareClangFlags( flags, filename ):
  new_flags = []
  skip = True
  for flag in flags:
    if skip:
      skip = False
      continue

    if flag == '-c':
      skip = True;
      continue

    if flag == '-o':
      skip = True;
      continue

    if flag == filename or os.path.realpath(flag) == filename:
      continue

    new_flags.append( flag )
  return new_flags


import os

# Given an iterable object that produces strings (flags for Clang), removes the
# '-c' and '-o' options that Clang does not like to see when it's producing
# completions for a file.
def PrepareClangFlags( flags, filename ):
  new_flags = []
  skip = True
  for flag in flags:
    if skip:
      skip = False
      continue

    if flag == '-c':
      continue

    if flag == '-o':
      skip = True;
      continue

    if flag == filename or os.path.realpath(flag) == filename:
      continue

    new_flags.append( flag )
  return new_flags

Fix bug with removing flag after "-c"
Fix bug with removing flag after "-c"

-c does not take an argument. Why did I think it did?

  
  import os
  
  # Given an iterable object that produces strings (flags for Clang), removes the
  # '-c' and '-o' options that Clang does not like to see when it's producing
  # completions for a file.
  def PrepareClangFlags( flags, filename ):
    new_flags = []
    skip = True
    for flag in flags:
      if skip:
        skip = False
        continue
  
      if flag == '-c':
-       skip = True;
        continue
  
      if flag == '-o':
        skip = True;
        continue
  
      if flag == filename or os.path.realpath(flag) == filename:
        continue
  
      new_flags.append( flag )
    return new_flags
  
Fix bug with removing flag after "-c"
## Code Before:

import os

# Given an iterable object that produces strings (flags for Clang), removes the
# '-c' and '-o' options that Clang does not like to see when it's producing
# completions for a file.
def PrepareClangFlags( flags, filename ):
  new_flags = []
  skip = True
  for flag in flags:
    if skip:
      skip = False
      continue

    if flag == '-c':
      skip = True;
      continue

    if flag == '-o':
      skip = True;
      continue

    if flag == filename or os.path.realpath(flag) == filename:
      continue

    new_flags.append( flag )
  return new_flags

## Instruction:
Fix bug with removing flag after "-c"
## Code After:

import os

# Given an iterable object that produces strings (flags for Clang), removes the
# '-c' and '-o' options that Clang does not like to see when it's producing
# completions for a file.
def PrepareClangFlags( flags, filename ):
  new_flags = []
  skip = True
  for flag in flags:
    if skip:
      skip = False
      continue

    if flag == '-c':
      continue

    if flag == '-o':
      skip = True;
      continue

    if flag == filename or os.path.realpath(flag) == filename:
      continue

    new_flags.append( flag )
  return new_flags
