diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-29 20:58:50 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-29 20:58:50 +0000 |
commit | e03245246acbec5c46e93b68ec6942ce42b9e256 (patch) | |
tree | cb4d0ae874c7b690a8d2ee2bf30a7b2ba424719b /lib/Driver/CC1Options.cpp | |
parent | 4cbe3b64be7b1b312e4e555e8c93ef8e5bd3a820 (diff) |
Change CompilerInvocation::CreateFromArgs to report errors using a proper diagnostic engine.
- Clients that care about having the diagnostics output honor the user-controllable diagnostic options can buffer the diagnostics and issue them later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/CC1Options.cpp')
-rw-r--r-- | lib/Driver/CC1Options.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Driver/CC1Options.cpp b/lib/Driver/CC1Options.cpp index 6f0aa26af7..feadae0a90 100644 --- a/lib/Driver/CC1Options.cpp +++ b/lib/Driver/CC1Options.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "clang/Driver/CC1Options.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/Version.h" #include "clang/Driver/ArgList.h" #include "clang/Driver/Arg.h" @@ -662,7 +663,8 @@ void CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, const char **ArgBegin, const char **ArgEnd, const char *Argv0, - void *MainAddr) { + void *MainAddr, + Diagnostic &Diags) { // Parse the arguments. llvm::OwningPtr<OptTable> Opts(createCC1OptTable()); unsigned MissingArgIndex, MissingArgCount; @@ -678,6 +680,14 @@ void CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, << " value )\n"; } + // Issue errors on unknown arguments. + for (arg_iterator it = InputArgs->filtered_begin(OPT_UNKNOWN), + ie = InputArgs->filtered_end(); it != ie; ++it) { + unsigned ID = Diags.getCustomDiagID(Diagnostic::Error, + "unknown argument: '%0'"); + Diags.Report(ID) << it->getAsString(*InputArgs); + } + ParseAnalyzerArgs(Res.getAnalyzerOpts(), *InputArgs); ParseCodeGenArgs(Res.getCodeGenOpts(), *InputArgs); ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), *InputArgs); |