mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[frontend] Move options for controlling the behavior of the Clang importer into a new ClangImporterOptions class.
Added a new ClangImporterOptions class which wraps the ModuleCachePath and ExtraArgs for the Clang importer. Added a new ParseClangImporterArgs static function which fills in the passed-in ClangImporterOptions. Updated CompilerInvocation and CompilerInvocation::parseArgs() to use ClangImporterOptions and ParseClangImporterArgs, respectively. Swift SVN r11180
This commit is contained in:
@@ -90,6 +90,22 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
|
||||
DiagnosticEngine &Diags) {
|
||||
using namespace options;
|
||||
|
||||
if (const Arg *A = Args.getLastArg(OPT_module_cache_path)) {
|
||||
Opts.ModuleCachePath = A->getValue();
|
||||
}
|
||||
|
||||
for (const Arg *A : make_range(Args.filtered_begin(OPT_Xcc),
|
||||
Args.filtered_end())) {
|
||||
Opts.ExtraArgs.push_back(A->getValue());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
|
||||
DiagnosticEngine &Diags) {
|
||||
using namespace driver::options;
|
||||
@@ -128,6 +144,10 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ParseClangImporterArgs(ClangImporterOpts, *ParsedArgs, Diags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto InputArg : *ParsedArgs) {
|
||||
switch (InputArg->getOption().getID()) {
|
||||
case OPT_target:
|
||||
@@ -146,10 +166,6 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
|
||||
setSDKPath(InputArg->getValue());
|
||||
break;
|
||||
|
||||
case OPT_module_cache_path:
|
||||
setClangModuleCachePath(InputArg->getValue());
|
||||
break;
|
||||
|
||||
case OPT_parse_as_library:
|
||||
setInputKind(SourceFileKind::Library);
|
||||
break;
|
||||
@@ -158,10 +174,6 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
|
||||
setParseStdlib();
|
||||
break;
|
||||
|
||||
case OPT_Xcc:
|
||||
ExtraClangArgs.push_back(InputArg->getValue());
|
||||
break;
|
||||
|
||||
case OPT_l:
|
||||
addLinkLibrary(InputArg->getValue(), LibraryKind::Library);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user