CC1: Only parse command-line options that have the CC1Option flag.

We already reject flags that don't have the CC1Option flag,
but we would previously do so after parsing the command-line
arguments.

Since the option parser now has a parameter for excluding options,
we should just use that instead.

Differential Revision: http://llvm-reviews.chandlerc.com/D1270

llvm-svn: 187668
This commit is contained in:
Hans Wennborg
2013-08-02 20:16:22 +00:00
parent 7be35cb1bf
commit d1ddb9afd4
2 changed files with 6 additions and 15 deletions

View File

@@ -1554,9 +1554,11 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
// Parse the arguments.
OwningPtr<OptTable> Opts(createDriverOptTable());
const unsigned IncludedFlagsBitmask = options::CC1Option;
unsigned MissingArgIndex, MissingArgCount;
OwningPtr<InputArgList> Args(
Opts->ParseArgs(ArgBegin, ArgEnd,MissingArgIndex, MissingArgCount));
Opts->ParseArgs(ArgBegin, ArgEnd, MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask));
// Check for missing argument error.
if (MissingArgCount) {
@@ -1572,17 +1574,6 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Success = false;
}
// Issue errors on arguments that are not valid for CC1.
for (ArgList::iterator I = Args->begin(), E = Args->end();
I != E; ++I) {
if ((*I)->getOption().matches(options::OPT_INPUT))
continue;
if (!(*I)->getOption().hasFlag(options::CC1Option)) {
Diags.Report(diag::err_drv_unknown_argument) << (*I)->getAsString(*Args);
Success = false;
}
}
Success = ParseAnalyzerArgs(*Res.getAnalyzerOpts(), *Args, Diags) && Success;
Success = ParseMigratorArgs(Res.getMigratorOpts(), *Args) && Success;
ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), *Args);