[frontend] Updated CompilerInvocation::parseArgs() so that it emits a diagnostic when it encounters an unknown argument.

Added a test which ensures that the driver invokes the integrated frontend in a way which does not produce any errors, in order to catch mismatches between the options the driver passes to the integrated frontend and the options which the integrated frontend accepts.

Swift SVN r11105
This commit is contained in:
Connor Wakamo
2013-12-11 00:26:06 +00:00
parent 78833dcb39
commit c6d23228db
3 changed files with 16 additions and 1 deletions

View File

@@ -55,6 +55,8 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
return true;
}
bool HasUnknownArgument = false;
for (auto InputArg : *ParsedArgs) {
switch (InputArg->getOption().getID()) {
case OPT_target:
@@ -120,8 +122,14 @@ bool CompilerInvocation::parseArgs(ArrayRef<const char *> Args,
case OPT_INPUT:
addInputFilename(InputArg->getValue());
break;
default:
HasUnknownArgument = true;
Diags.diagnose(SourceLoc(), diag::error_unknown_arg,
InputArg->getAsString(*ParsedArgs));
break;
}
}
return false;
return HasUnknownArgument;
}