зеркало из https://github.com/microsoft/clang-1.git
Driver/Frontend: Add support for -mllvm, which forwards options to the LLVM option parser.
- Note that this is a behavior change, previously -mllvm at the driver level forwarded to clang -cc1. The driver does a little magic to make sure that '-mllvm -disable-llvm-optzns' works correctly, but other users will need to be updated to use -Xclang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
2df2569679
Коммит
3f87fb08dd
|
@ -324,6 +324,11 @@ def ftime_report : Flag<"-ftime-report">,
|
|||
def fdump_record_layouts : Flag<"-fdump-record-layouts">,
|
||||
HelpText<"Dump record layout information">;
|
||||
|
||||
// Generic forwarding to LLVM options. This should only be used for debugging
|
||||
// and experimental features.
|
||||
def mllvm : Separate<"-mllvm">,
|
||||
HelpText<"Additional arguments to forward to LLVM's option processing">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Language Options
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -110,6 +110,10 @@ public:
|
|||
/// \brief The list of AST files to merge.
|
||||
std::vector<std::string> ASTMergeFiles;
|
||||
|
||||
/// \brief A list of arguments to forward to LLVM's option processing; this
|
||||
/// should only be used for debugging and experimental features.
|
||||
std::vector<std::string> LLVMArgs;
|
||||
|
||||
public:
|
||||
FrontendOptions() {
|
||||
DebugCodeCompletionPrinter = 1;
|
||||
|
|
|
@ -1325,8 +1325,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
Args.AddLastArg(CmdArgs, options::OPT_dM);
|
||||
Args.AddLastArg(CmdArgs, options::OPT_dD);
|
||||
|
||||
// Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option
|
||||
// parser.
|
||||
Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
|
||||
Args.AddAllArgValues(CmdArgs, options::OPT_mllvm);
|
||||
for (arg_iterator it = Args.filtered_begin(options::OPT_mllvm),
|
||||
ie = Args.filtered_end(); it != ie; ++it) {
|
||||
// We translate this by hand to the -cc1 argument, since nightly test uses
|
||||
// it and developers have been trained to spell it with -mllvm.
|
||||
if (llvm::StringRef(it->getValue(Args, 0)) == "-disable-llvm-optzns")
|
||||
CmdArgs.push_back("-disable-llvm-optzns");
|
||||
else
|
||||
it->render(Args, CmdArgs);
|
||||
}
|
||||
|
||||
if (Output.getType() == types::TY_Dependencies) {
|
||||
// Handled with other dependency code.
|
||||
|
|
|
@ -383,6 +383,10 @@ static void FrontendOptsToArgs(const FrontendOptions &Opts,
|
|||
Res.push_back("-ast-merge");
|
||||
Res.push_back(Opts.ASTMergeFiles[i]);
|
||||
}
|
||||
for (unsigned i = 0, e = Opts.LLVMArgs.size(); i != e; ++i) {
|
||||
Res.push_back("-mllvm");
|
||||
Res.push_back(Opts.LLVMArgs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
|
||||
|
@ -955,6 +959,7 @@ ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, Diagnostic &Diags) {
|
|||
Opts.ShowVersion = Args.hasArg(OPT_version);
|
||||
Opts.ViewClassInheritance = getLastArgValue(Args, OPT_cxx_inheritance_view);
|
||||
Opts.ASTMergeFiles = getAllArgValues(Args, OPT_ast_merge);
|
||||
Opts.LLVMArgs = getAllArgValues(Args, OPT_mllvm);
|
||||
|
||||
FrontendOptions::InputKind DashX = FrontendOptions::IK_None;
|
||||
if (const Arg *A = Args.getLastArg(OPT_x)) {
|
||||
|
|
|
@ -241,6 +241,19 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Honor -mllvm.
|
||||
//
|
||||
// FIXME: Remove this, one day.
|
||||
if (!Clang->getFrontendOpts().LLVMArgs.empty()) {
|
||||
unsigned NumArgs = Clang->getFrontendOpts().LLVMArgs.size();
|
||||
const char **Args = new const char*[NumArgs + 2];
|
||||
Args[0] = "clang (LLVM option parsing)";
|
||||
for (unsigned i = 0; i != NumArgs; ++i)
|
||||
Args[i + 1] = Clang->getFrontendOpts().LLVMArgs[i].c_str();
|
||||
Args[NumArgs + 1] = 0;
|
||||
llvm::cl::ParseCommandLineOptions(NumArgs + 1, (char**) Args);
|
||||
}
|
||||
|
||||
// Create the actual diagnostics engine.
|
||||
Clang->createDiagnostics(ArgEnd - ArgBegin, const_cast<char**>(ArgBegin));
|
||||
if (!Clang->hasDiagnostics())
|
||||
|
|
Загрузка…
Ссылка в новой задаче