[cfe-commits] r149121 - in /cfe/trunk: include/clang/Basic/Diagnostic.h include/clang/Basic/DiagnosticIDs.h lib/Basic/Diagnostic.cpp lib/Basic/DiagnosticIDs.cpp lib/Frontend/Warnings.cpp

David Blaikie dblaikie at gmail.com
Thu Jan 26 22:25:58 PST 2012


On Thu, Jan 26, 2012 at 10:15 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
> Author: akirtzidis
> Date: Fri Jan 27 00:15:43 2012
> New Revision: 149121
>
> URL: http://llvm.org/viewvc/llvm-project?rev=149121&view=rev
> Log:
> Due to a bug, -Wno-everything works like -Weverything. Fix the bug by having
> -Wno-everything remap all warnings to ignored.

Simple test case for this?

- David

>
> We can now use "-Wno-everything -W<warning>" to ignore all warnings except
> specific ones.
>
> Modified:
>    cfe/trunk/include/clang/Basic/Diagnostic.h
>    cfe/trunk/include/clang/Basic/DiagnosticIDs.h
>    cfe/trunk/lib/Basic/Diagnostic.cpp
>    cfe/trunk/lib/Basic/DiagnosticIDs.cpp
>    cfe/trunk/lib/Frontend/Warnings.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=149121&r1=149120&r2=149121&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
> +++ cfe/trunk/include/clang/Basic/Diagnostic.h Fri Jan 27 00:15:43 2012
> @@ -476,6 +476,12 @@
>   /// \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; }
>
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=149121&r1=149120&r2=149121&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Fri Jan 27 00:15:43 2012
> @@ -263,6 +263,9 @@
>   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);
>
> Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=149121&r1=149120&r2=149121&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
> +++ cfe/trunk/lib/Basic/Diagnostic.cpp Fri Jan 27 00:15:43 2012
> @@ -295,6 +295,20 @@
>   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!");
>
>
> Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=149121&r1=149120&r2=149121&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
> +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Fri Jan 27 00:15:43 2012
> @@ -682,6 +682,12 @@
>   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.
>
> Modified: cfe/trunk/lib/Frontend/Warnings.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Warnings.cpp?rev=149121&r1=149120&r2=149121&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/Warnings.cpp (original)
> +++ cfe/trunk/lib/Frontend/Warnings.cpp Fri Jan 27 00:15:43 2012
> @@ -110,8 +110,14 @@
>       // -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;
>       }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list