diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-01-27 06:15:43 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-01-27 06:15:43 +0000 |
commit | 9ffada97ce7bf4def03a8158064b6c8df274f95a (patch) | |
tree | 2bcb690d78a892fb33fd189c6713195c39df1cc4 | |
parent | 0b5ec2d19970b4889886bfb7c0ac5542083cb74e (diff) | |
download | bcm5719-llvm-9ffada97ce7bf4def03a8158064b6c8df274f95a.tar.gz bcm5719-llvm-9ffada97ce7bf4def03a8158064b6c8df274f95a.zip |
Due to a bug, -Wno-everything works like -Weverything. Fix the bug by having
-Wno-everything remap all warnings to ignored.
We can now use "-Wno-everything -W<warning>" to ignore all warnings except
specific ones.
llvm-svn: 149121
-rw-r--r-- | clang/include/clang/Basic/Diagnostic.h | 6 | ||||
-rw-r--r-- | clang/include/clang/Basic/DiagnosticIDs.h | 3 | ||||
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Basic/DiagnosticIDs.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Frontend/Warnings.cpp | 10 |
5 files changed, 37 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index 4f5fe6501ef..c587a1d6e20 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -476,6 +476,12 @@ public: /// \returns True if the given group is unknown, false otherwise. bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled); + /// \brief Add the specified mapping to all diagnostics. Mainly to be used + /// by -Wno-everything to disable all warnings but allow subsequent -W options + /// to enable specific warnings. + bool setMappingToAllDiagnostics(diag::Mapping Map, + SourceLocation Loc = SourceLocation()); + bool hasErrorOccurred() const { return ErrorOccurred; } bool hasFatalErrorOccurred() const { return FatalErrorOccurred; } diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h index 30fda595383..40fc3a98be3 100644 --- a/clang/include/clang/Basic/DiagnosticIDs.h +++ b/clang/include/clang/Basic/DiagnosticIDs.h @@ -263,6 +263,9 @@ public: bool getDiagnosticsInGroup(StringRef Group, llvm::SmallVectorImpl<diag::kind> &Diags) const; + /// \brief Get the set of all diagnostic IDs. + void getAllDiagnostics(llvm::SmallVectorImpl<diag::kind> &Diags) const; + /// \brief Get the warning option with the closest edit distance to the given /// group name. static StringRef getNearestWarningOption(StringRef Group); diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 67ea056417f..eab79d6442d 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -295,6 +295,20 @@ bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group, return false; } +bool DiagnosticsEngine::setMappingToAllDiagnostics(diag::Mapping Map, + SourceLocation Loc) { + // Get all the diagnostics. + llvm::SmallVector<diag::kind, 64> AllDiags; + Diags->getAllDiagnostics(AllDiags); + + // Set the mapping. + for (unsigned i = 0, e = AllDiags.size(); i != e; ++i) + if (Diags->isBuiltinWarningOrExtension(AllDiags[i])) + setDiagnosticMapping(AllDiags[i], Map, Loc); + + return false; +} + void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) { assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!"); diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp index b3c4d033c28..9f09f72e868 100644 --- a/clang/lib/Basic/DiagnosticIDs.cpp +++ b/clang/lib/Basic/DiagnosticIDs.cpp @@ -682,6 +682,12 @@ bool DiagnosticIDs::getDiagnosticsInGroup( return false; } +void DiagnosticIDs::getAllDiagnostics( + llvm::SmallVectorImpl<diag::kind> &Diags) const { + for (unsigned i = 0; i != StaticDiagInfoSize; ++i) + Diags.push_back(StaticDiagInfo[i].DiagID); +} + StringRef DiagnosticIDs::getNearestWarningOption(StringRef Group) { StringRef Best; unsigned BestDistance = Group.size() + 1; // Sanity threshold. diff --git a/clang/lib/Frontend/Warnings.cpp b/clang/lib/Frontend/Warnings.cpp index 576dd3d4459..f68e03b0d51 100644 --- a/clang/lib/Frontend/Warnings.cpp +++ b/clang/lib/Frontend/Warnings.cpp @@ -110,8 +110,14 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags, // -Weverything is a special case as well. It implicitly enables all // warnings, including ones not explicitly in a warning group. if (Opt == "everything") { - if (SetDiagnostic) - Diags.setEnableAllWarnings(true); + if (SetDiagnostic) { + if (isPositive) { + Diags.setEnableAllWarnings(true); + } else { + Diags.setEnableAllWarnings(false); + Diags.setMappingToAllDiagnostics(diag::MAP_IGNORE); + } + } continue; } |