コード例 #1
0
ファイル: MSVCToolChain.cpp プロジェクト: OpenKimono/clang
static void TranslateOptArg(Arg *A, llvm::opt::DerivedArgList &DAL,
                            bool SupportsForcingFramePointer,
                            const char *ExpandChar, const OptTable &Opts) {
    assert(A->getOption().matches(options::OPT__SLASH_O));

    StringRef OptStr = A->getValue();
    for (size_t I = 0, E = OptStr.size(); I != E; ++I) {
        const char &OptChar = *(OptStr.data() + I);
        switch (OptChar) {
        default:
            break;
        case '1':
        case '2':
        case 'x':
        case 'd':
            if (&OptChar == ExpandChar) {
                if (OptChar == 'd') {
                    DAL.AddFlagArg(A, Opts.getOption(options::OPT_O0));
                } else {
                    if (OptChar == '1') {
                        DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s");
                    } else if (OptChar == '2' || OptChar == 'x') {
                        DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin));
                        DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2");
                    }
                    if (SupportsForcingFramePointer &&
                            !DAL.hasArgNoClaim(options::OPT_fno_omit_frame_pointer))
                        DAL.AddFlagArg(A,
                                       Opts.getOption(options::OPT_fomit_frame_pointer));
                    if (OptChar == '1' || OptChar == '2')
                        DAL.AddFlagArg(A,
                                       Opts.getOption(options::OPT_ffunction_sections));
                }
            }
            break;
        case 'b':
            if (I + 1 != E && isdigit(OptStr[I + 1])) {
                switch (OptStr[I + 1]) {
                case '0':
                    DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_inline));
                    break;
                case '1':
                    // TODO: Inline calls to 'inline functions' only.
                    break;
                case '2':
                    DAL.AddFlagArg(A, Opts.getOption(options::OPT_finline_functions));
                    break;
                }
                ++I;
            }
            break;
        case 'g':
            break;
        case 'i':
            if (I + 1 != E && OptStr[I + 1] == '-') {
                ++I;
                DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_builtin));
            } else {
                DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin));
            }
            break;
        case 's':
            DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s");
            break;
        case 't':
            DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2");
            break;
        case 'y': {
            bool OmitFramePointer = true;
            if (I + 1 != E && OptStr[I + 1] == '-') {
                OmitFramePointer = false;
                ++I;
            }
            if (SupportsForcingFramePointer) {
                if (OmitFramePointer)
                    DAL.AddFlagArg(A,
                                   Opts.getOption(options::OPT_fomit_frame_pointer));
                else
                    DAL.AddFlagArg(
                        A, Opts.getOption(options::OPT_fno_omit_frame_pointer));
            } else {
                // Don't warn about /Oy- in 64-bit builds (where
                // SupportsForcingFramePointer is false).  The flag having no effect
                // there is a compiler-internal optimization, and people shouldn't have
                // to special-case their build files for 64-bit clang-cl.
                A->claim();
            }
            break;
        }
        }
    }
}
コード例 #2
0
ファイル: MSVCToolChain.cpp プロジェクト: mirams/opencor
static void TranslateOptArg(Arg *A, llvm::opt::DerivedArgList &DAL,
                            bool SupportsForcingFramePointer,
                            const char *ExpandChar, const OptTable &Opts) {
  assert(A->getOption().matches(options::OPT__SLASH_O));

  StringRef OptStr = A->getValue();
  for (size_t I = 0, E = OptStr.size(); I != E; ++I) {
    const char &OptChar = *(OptStr.data() + I);
    switch (OptChar) {
    default:
      break;
    case '1':
    case '2':
    case 'x':
    case 'd':
      if (&OptChar == ExpandChar) {
        if (OptChar == 'd') {
          DAL.AddFlagArg(A, Opts.getOption(options::OPT_O0));
        } else {
          if (OptChar == '1') {
            DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s");
          } else if (OptChar == '2' || OptChar == 'x') {
            DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin));
            DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2");
          }
          if (SupportsForcingFramePointer)
            DAL.AddFlagArg(A,
                           Opts.getOption(options::OPT_fomit_frame_pointer));
          if (OptChar == '1' || OptChar == '2')
            DAL.AddFlagArg(A,
                           Opts.getOption(options::OPT_ffunction_sections));
        }
      }
      break;
    case 'b':
      if (I + 1 != E && isdigit(OptStr[I + 1]))
        ++I;
      break;
    case 'g':
      break;
    case 'i':
      if (I + 1 != E && OptStr[I + 1] == '-') {
        ++I;
        DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_builtin));
      } else {
        DAL.AddFlagArg(A, Opts.getOption(options::OPT_fbuiltin));
      }
      break;
    case 's':
      DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "s");
      break;
    case 't':
      DAL.AddJoinedArg(A, Opts.getOption(options::OPT_O), "2");
      break;
    case 'y': {
      bool OmitFramePointer = true;
      if (I + 1 != E && OptStr[I + 1] == '-') {
        OmitFramePointer = false;
        ++I;
      }
      if (SupportsForcingFramePointer) {
        if (OmitFramePointer)
          DAL.AddFlagArg(A,
                         Opts.getOption(options::OPT_fomit_frame_pointer));
        else
          DAL.AddFlagArg(
              A, Opts.getOption(options::OPT_fno_omit_frame_pointer));
      }
      break;
    }
    }
  }
}