Commit b625dc1f authored by Bill Wendling's avatar Bill Wendling
Browse files

Merging r215046:

------------------------------------------------------------------------
r215046 | rsmith | 2014-08-06 17:24:21 -0700 (Wed, 06 Aug 2014) | 19 lines

Use -Rblah, not -Wblah, to control remark diagnostics. This was always the
intent when we added remark support, but was never implemented in the general
case, because the first -R flags didn't need it. (-Rpass= had special handling
to accomodate its argument.)

-Rno-foo, -Reverything, and -Rno-everything can be used to turn off a remark,
or to turn on or off all remarks. Per discussion on cfe-commits, -Weverything
does not affect remarks, and -Reverything does not affect warnings or errors.

The only "real" -R flag we have right now is -Rmodule-build; that flag is
effectively renamed from -Wmodule-build to -Rmodule-build by this change.

-Wpass and -Wno-pass (and their friends) are also renamed to -Rpass and
-Rno-pass by this change; it's not completely clear whether we intended to have
a -Rpass (with no =pattern), but that is unchanged by this commit, other than
the flag name. The default pattern is effectively one which matches no passes.
In future, we may want to make the default pattern be .*, so that -Reverything
works for -Rpass properly.

------------------------------------------------------------------------

llvm-svn: 215057
parent ca6c6b95
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -542,9 +542,13 @@ public:
  /// \returns true (and ignores the request) if "Group" was unknown, false
  /// otherwise.
  ///
  /// \param Flavor The flavor of group to affect. -Rfoo does not affect the
  /// state of the -Wfoo group and vice versa.
  ///
  /// \param Loc The source location that this change of diagnostic state should
  /// take affect. It can be null if we are setting the state from command-line.
  bool setSeverityForGroup(StringRef Group, diag::Severity Map,
  bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group,
                           diag::Severity Map,
                           SourceLocation Loc = SourceLocation());

  /// \brief Set the warning-as-error flag for the given diagnostic group.
@@ -561,11 +565,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.
  /// \brief Add the specified mapping to all diagnostics of the specified
  /// flavor.
  ///
  /// Mainly to be used by -Wno-everything to disable all warnings but allow
  /// subsequent -W options to enable specific warnings.
  void setSeverityForAll(diag::Severity Map,
  void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map,
                         SourceLocation Loc = SourceLocation());

  bool hasErrorOccurred() const { return ErrorOccurred; }
+6 −15
Original line number Diff line number Diff line
@@ -36,11 +36,11 @@ def remark_fe_backend_plugin: Remark<"%0">, BackendInfo, InGroup<RemarkBackendPl
def note_fe_backend_plugin: Note<"%0">, BackendInfo;

def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo,
    InGroup<BackendOptimizationRemark>, DefaultRemark;
    InGroup<BackendOptimizationRemark>;
def remark_fe_backend_optimization_remark_missed : Remark<"%0">, BackendInfo,
    InGroup<BackendOptimizationRemarkMissed>, DefaultRemark;
    InGroup<BackendOptimizationRemarkMissed>;
def remark_fe_backend_optimization_remark_analysis : Remark<"%0">, BackendInfo,
    InGroup<BackendOptimizationRemarkAnalysis>, DefaultRemark;
    InGroup<BackendOptimizationRemarkAnalysis>;
def warn_fe_backend_optimization_failure : Warning<"%0">, BackendInfo,
    InGroup<BackendOptimizationFailure>, DefaultWarn;
def note_fe_backend_optimization_remark_invalid_loc : Note<"could "
@@ -126,17 +126,8 @@ def err_relocatable_without_isysroot : Error<
    "must specify system root with -isysroot when building a relocatable "
    "PCH file">;

def warn_unknown_warning_option : Warning<
    "unknown warning option '%0'">,
    InGroup<UnknownWarningOption>;
def warn_unknown_negative_warning_option : Warning<
    "unknown warning option '%0'">,
    InGroup<UnknownWarningOption>;
def warn_unknown_warning_option_suggest : Warning<
    "unknown warning option '%0'; did you mean '%1'?">,
    InGroup<UnknownWarningOption>;
def warn_unknown_negative_warning_option_suggest : Warning<
    "unknown warning option '%0'; did you mean '%1'?">,
def warn_unknown_diag_option : Warning<
    "unknown %select{warning|remark}0 option '%1'%select{|; did you mean '%3'?}2">,
    InGroup<UnknownWarningOption>;
def warn_unknown_warning_specifier : Warning<
    "unknown %0 warning specifier: '%1'">,
@@ -176,7 +167,7 @@ def warn_module_config_macro_undef : Warning<
def note_module_def_undef_here : Note<
  "macro was %select{defined|#undef'd}0 here">;
def remark_module_build : Remark<"building module '%0' as '%1'">,
  InGroup<DiagGroup<"module-build">>, DefaultIgnore;
  InGroup<DiagGroup<"module-build">>;

def err_missing_vfs_overlay_file : Error<
  "virtual filesystem overlay file '%0' not found">, DefaultFatal;
+15 −5
Original line number Diff line number Diff line
@@ -67,6 +67,15 @@ namespace clang {
      Error = 4,   ///< Present this diagnostic as an error.
      Fatal = 5    ///< Present this diagnostic as a fatal error.
    };

    /// Flavors of diagnostics we can emit. Used to filter for a particular
    /// kind of diagnostic (for instance, for -W/-R flags).
    enum class Flavor {
      WarningOrError, ///< A diagnostic that indicates a problem or potential
                      ///< problem. Can be made fatal by -Werror.
      Remark          ///< A diagnostic that indicates normal progress through
                      ///< compilation.
    };
  }

class DiagnosticMapping {
@@ -228,15 +237,16 @@ public:
  ///
  /// \param[out] Diags - On return, the diagnostics in the group.
  /// \returns \c true if the given group is unknown, \c false otherwise.
  bool getDiagnosticsInGroup(StringRef Group,
  bool getDiagnosticsInGroup(diag::Flavor Flavor, StringRef Group,
                             SmallVectorImpl<diag::kind> &Diags) const;

  /// \brief Get the set of all diagnostic IDs.
  void getAllDiagnostics(SmallVectorImpl<diag::kind> &Diags) const;
  void getAllDiagnostics(diag::Flavor Flavor,
                         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);
  /// \brief Get the diagnostic option with the closest edit distance to the
  /// given group name.
  static StringRef getNearestOption(diag::Flavor Flavor, StringRef Group);

private:
  /// \brief Classify the specified diagnostic ID into a Level, consumable by
+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@ public:
  /// prefixes removed.
  std::vector<std::string> Warnings;

  /// The list of -R... options used to alter the diagnostic mappings, with the
  /// prefixes removed.
  std::vector<std::string> Remarks;

public:
  // Define accessors/mutators for diagnostic options of enumeration type.
#define DIAGOPT(Name, Bits, Default)
+8 −3
Original line number Diff line number Diff line
@@ -64,7 +64,9 @@ def M_Group : OptionGroup<"<M group>">, Group<CompileOnly_Group>;
def T_Group               : OptionGroup<"<T group>">;
def O_Group               : OptionGroup<"<O group>">, Group<CompileOnly_Group>;
def R_Group               : OptionGroup<"<R group>">, Group<CompileOnly_Group>;
def R_value_Group         : OptionGroup<"<R (with value) group>">, Group<R_Group>;
def W_Group               : OptionGroup<"<W group>">, Group<CompileOnly_Group>;
def W_value_Group         : OptionGroup<"<W (with value) group>">, Group<W_Group>;
def d_Group               : OptionGroup<"<d group>">;
def f_Group               : OptionGroup<"<f group>">, Group<CompileOnly_Group>;
def f_clang_Group         : OptionGroup<"<f (clang-only) group>">, Group<CompileOnly_Group>;
@@ -261,17 +263,19 @@ def Qn : Flag<["-"], "Qn">;
def Qunused_arguments : Flag<["-"], "Qunused-arguments">, Flags<[DriverOption, CoreOption]>,
  HelpText<"Don't emit warning for unused driver arguments">;
def Q : Flag<["-"], "Q">;
def Rpass_EQ : Joined<["-"], "Rpass=">, Group<R_Group>, Flags<[CC1Option]>,
def Rpass_EQ : Joined<["-"], "Rpass=">, Group<R_value_Group>, Flags<[CC1Option]>,
  HelpText<"Report transformations performed by optimization passes whose "
           "name matches the given POSIX regular expression">;
def Rpass_missed_EQ : Joined<["-"], "Rpass-missed=">, Group<R_Group>,
def Rpass_missed_EQ : Joined<["-"], "Rpass-missed=">, Group<R_value_Group>,
  Flags<[CC1Option]>,
  HelpText<"Report missed transformations by optimization passes whose "
           "name matches the given POSIX regular expression">;
def Rpass_analysis_EQ : Joined<["-"], "Rpass-analysis=">, Group<R_Group>,
def Rpass_analysis_EQ : Joined<["-"], "Rpass-analysis=">, Group<R_value_Group>,
  Flags<[CC1Option]>,
  HelpText<"Report transformation analysis from optimization passes whose "
           "name matches the given POSIX regular expression">;
def R_Joined : Joined<["-"], "R">, Group<R_Group>, Flags<[CC1Option, CoreOption]>,
  MetaVarName<"<remark>">, HelpText<"Enable the specified remark">;
def S : Flag<["-"], "S">, Flags<[DriverOption,CC1Option]>, Group<Action_Group>,
  HelpText<"Only run preprocess and compilation steps">;
def Tbss : JoinedOrSeparate<["-"], "Tbss">, Group<T_Group>;
@@ -290,6 +294,7 @@ def Wextra : Flag<["-"], "Wextra">, Group<W_Group>, Flags<[CC1Option]>;
def Wl_COMMA : CommaJoined<["-"], "Wl,">, Flags<[LinkerInput, RenderAsInput]>,
  HelpText<"Pass the comma separated arguments in <arg> to the linker">,
  MetaVarName<"<arg>">;
// FIXME: This is broken; these should not be Joined arguments.
def Wno_nonportable_cfstrings : Joined<["-"], "Wno-nonportable-cfstrings">, Group<W_Group>,
  Flags<[CC1Option]>;
def Wnonportable_cfstrings : Joined<["-"], "Wnonportable-cfstrings">, Group<W_Group>,
Loading