Improve error messages on bad warning options.

llvm-svn: 66334
This commit is contained in:
Sebastian Redl 2009-03-07 12:09:25 +00:00
parent 6e1ca84d2c
commit ecc5444a7b
2 changed files with 10 additions and 9 deletions

View File

@ -22,8 +22,7 @@
// warn: Emit a message, but don't fail the compilation // warn: Emit a message, but don't fail the compilation
// error: Emit a message and fail the compilation // error: Emit a message and fail the compilation
// //
// Clang is parsed warning options. Each warning option controls any number of // Each warning option controls any number of actual warnings.
// actual warnings.
// Given a warning option 'foo', the following are valid: // Given a warning option 'foo', the following are valid:
// -Wfoo=ignore -> Ignore the controlled warnings. // -Wfoo=ignore -> Ignore the controlled warnings.
// -Wfoo=warn -> Warn about the controlled warnings. // -Wfoo=warn -> Warn about the controlled warnings.
@ -87,8 +86,11 @@ namespace {
} else { } else {
Val.Name = ArgValue.substr(0, Eq); Val.Name = ArgValue.substr(0, Eq);
Val.Mapping = StrToMapping(ArgValue.substr(Eq+1)); Val.Mapping = StrToMapping(ArgValue.substr(Eq+1));
if (Val.Mapping == diag::MAP_DEFAULT) if (Val.Mapping == diag::MAP_DEFAULT) {
fprintf(stderr, "Illegal warning option value: %s\n",
ArgValue.substr(Eq+1).c_str());
return true; return true;
}
} }
return false; return false;
} }
@ -203,8 +205,10 @@ bool ProcessWarningOptions(Diagnostic &Diags) {
OptionTable + OptionTableSize, OptionTable + OptionTableSize,
Key); Key);
if (Found == OptionTable + OptionTableSize || if (Found == OptionTable + OptionTableSize ||
strcmp(Found->Name, Key.Name) != 0) strcmp(Found->Name, Key.Name) != 0) {
fprintf(stderr, "Unknown warning option: -W%s\n", Key.Name);
return true; return true;
}
// Option exists. // Option exists.
for (size_t i = 0; i < Found->NumMembers; ++i) { for (size_t i = 0; i < Found->NumMembers; ++i) {

View File

@ -1504,11 +1504,8 @@ int main(int argc, char **argv) {
// Configure our handling of diagnostics. // Configure our handling of diagnostics.
llvm::OwningPtr<DiagnosticClient> DiagClient(TextDiagClient); llvm::OwningPtr<DiagnosticClient> DiagClient(TextDiagClient);
Diagnostic Diags(DiagClient.get()); Diagnostic Diags(DiagClient.get());
if (ProcessWarningOptions(Diags)) { if (ProcessWarningOptions(Diags))
fprintf(stderr, "Error in warning options.\n");
return 1; return 1;
}
//InitializeDiagnostics(Diags);
// -I- is a deprecated GCC feature, scan for it and reject it. // -I- is a deprecated GCC feature, scan for it and reject it.
for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) { for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) {
@ -1527,7 +1524,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Sorry, I don't know what target this is: %s\n", fprintf(stderr, "Sorry, I don't know what target this is: %s\n",
Triple.c_str()); Triple.c_str());
fprintf(stderr, "Please use -triple or -arch.\n"); fprintf(stderr, "Please use -triple or -arch.\n");
exit(1); return 1;
} }
if (!InheritanceViewCls.empty()) // C++ visualization? if (!InheritanceViewCls.empty()) // C++ visualization?