diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-03-12 08:55:43 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-12 08:55:43 +0000 |
| commit | c0b3e95a1ad572cb8e27ae027b20898c42a164d1 (patch) | |
| tree | db7d56934152548252ec0326158c096f2a8fee85 /clang/lib | |
| parent | 33699689ed30466edd61f199fd9b49f08af4f52b (diff) | |
| download | bcm5719-llvm-c0b3e95a1ad572cb8e27ae027b20898c42a164d1.tar.gz bcm5719-llvm-c0b3e95a1ad572cb8e27ae027b20898c42a164d1.zip | |
Driver: Use standard Diagnostic interface for diagnostics.
llvm-svn: 66786
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 16 | ||||
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 21 |
2 files changed, 23 insertions, 14 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index fa5ca57dfe6..3e3802ae20a 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -44,6 +44,10 @@ static unsigned char DiagnosticFlagsCommon[] = { #include "clang/Basic/DiagnosticCommonKinds.def" 0 }; +static unsigned char DiagnosticFlagsDriver[] = { +#include "clang/Basic/DiagnosticDriverKinds.def" + 0 +}; static unsigned char DiagnosticFlagsLex[] = { #include "clang/Basic/DiagnosticLexKinds.def" 0 @@ -72,8 +76,10 @@ static unsigned getBuiltinDiagClass(unsigned DiagID) { assert(DiagID < diag::DIAG_UPPER_LIMIT && "Diagnostic ID out of range!"); unsigned res; - if (DiagID < diag::DIAG_START_LEX) + if (DiagID < diag::DIAG_START_DRIVER) res = DiagnosticFlagsCommon[DiagID]; + else if (DiagID < diag::DIAG_START_LEX) + res = DiagnosticFlagsDriver[DiagID - diag::DIAG_START_DRIVER - 1]; else if (DiagID < diag::DIAG_START_PARSE) res = DiagnosticFlagsLex[DiagID - diag::DIAG_START_LEX - 1]; else if (DiagID < diag::DIAG_START_AST) @@ -94,6 +100,10 @@ static const char * const DiagnosticTextCommon[] = { #include "clang/Basic/DiagnosticCommonKinds.def" 0 }; +static const char * const DiagnosticTextDriver[] = { +#include "clang/Basic/DiagnosticDriverKinds.def" + 0 +}; static const char * const DiagnosticTextLex[] = { #include "clang/Basic/DiagnosticLexKinds.def" 0 @@ -237,8 +247,10 @@ bool Diagnostic::isBuiltinNote(unsigned DiagID) { /// getDescription - Given a diagnostic ID, return a description of the /// issue. const char *Diagnostic::getDescription(unsigned DiagID) const { - if (DiagID < diag::DIAG_START_LEX) + if (DiagID < diag::DIAG_START_DRIVER) return DiagnosticTextCommon[DiagID]; + else if (DiagID < diag::DIAG_START_LEX) + return DiagnosticTextDriver[DiagID - diag::DIAG_START_DRIVER - 1]; else if (DiagID < diag::DIAG_START_PARSE) return DiagnosticTextLex[DiagID - diag::DIAG_START_LEX - 1]; else if (DiagID < diag::DIAG_START_AST) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index d9ed37b7de4..90cf6828e0f 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -13,6 +13,7 @@ #include "clang/Driver/Arg.h" #include "clang/Driver/ArgList.h" #include "clang/Driver/Compilation.h" +#include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/HostInfo.h" #include "clang/Driver/Option.h" #include "clang/Driver/Options.h" @@ -23,8 +24,9 @@ using namespace clang::driver; Driver::Driver(const char *_Name, const char *_Dir, - const char *_DefaultHostTriple) - : Opts(new OptTable()), + const char *_DefaultHostTriple, + Diagnostic &_Diags) + : Opts(new OptTable()), Diags(_Diags), Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple), Host(0), CCCIsCXX(false), CCCEcho(false), @@ -46,7 +48,7 @@ ArgList *Driver::ParseArgStrings(const char **ArgBegin, const char **ArgEnd) { Arg *A = getOpts().ParseOneArg(*Args, Index, End); if (A) { if (A->getOption().isUnsupported()) { - Diag("unsupported option: ") << A->getOption().getName() << "\n"; + Diag(clang::diag::driver_unsupported_opt) << A->getOption().getName(); continue; } @@ -189,7 +191,7 @@ void Driver::BuildActions(const ArgList &Args, types::ID Ty = types::TY_INVALID; // Infer the input type if necessary. - if (!InputType) { + if (InputType == types::TY_INVALID) { // stdin must be handled specially. if (memcmp(Value, "-", 2) == 0) { // If running with -E, treat as a C input (this changes the @@ -199,7 +201,7 @@ void Driver::BuildActions(const ArgList &Args, // Otherwise emit an error but still use a valid type to // avoid spurious errors (e.g., no inputs). if (!Args.hasArg(options::OPT_E)) - Diag("-E or -x required when input is from standard input"); + Diag(clang::diag::driver_unknown_stdin_type); Ty = types::TY_C; } else { // Otherwise lookup by extension, and fallback to ObjectType @@ -233,7 +235,7 @@ void Driver::BuildActions(const ArgList &Args, // just adds an extra stat to the equation, but this is gcc // compatible. if (memcmp(Value, "-", 2) != 0 && !llvm::sys::Path(Value).exists()) - Diag("no such file or directory: ") << A->getValue(Args) << "\n"; + Diag(clang::diag::driver_no_such_file) << A->getValue(Args); else Inputs.push_back(std::make_pair(Ty, A)); @@ -251,7 +253,7 @@ void Driver::BuildActions(const ArgList &Args, // unknown; but this isn't very important, we might as well be // bug comatible. if (!InputType) { - Diag("language not recognized: ") << A->getValue(Args) << "\n"; + Diag(clang::diag::driver_unknown_language) << A->getValue(Args); InputType = types::TY_Object; } } @@ -286,8 +288,3 @@ HostInfo *Driver::GetHostInfo(const char *Triple) { return new UnknownHostInfo(Arch.c_str(), Platform.c_str(), OS.c_str()); } - -// FIXME: Migrate to a normal diagnostics client. -llvm::raw_ostream &Driver::Diag(const char *Message) const { - return (llvm::errs() << Message); -} |

