]> granicus.if.org Git - clang/commitdiff
Remove -Wspellcheck and replace it with a diagnostic option.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 16 Mar 2013 01:40:35 +0000 (01:40 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 16 Mar 2013 01:40:35 +0000 (01:40 +0000)
Thanks to Richard S. for pointing out that the warning would show up
with -Weverything.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177218 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Diagnostic.h
include/clang/Basic/DiagnosticOptions.def
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Driver/CC1Options.td
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/Warnings.cpp
lib/Sema/SemaLookup.cpp
test/SemaObjC/typo-correction.m

index 0a501cb4cc9a0b91a93232d6fa12e9e242943180..0b7c54ecf5f8f56bd3785e338249fce2907a71c7 100644 (file)
@@ -175,6 +175,7 @@ private:
   bool SuppressAllDiagnostics;   // Suppress all diagnostics.
   bool ElideType;                // Elide common types of templates.
   bool PrintTemplateTree;        // Print a tree when comparing templates.
+  bool WarnOnSpellCheck;         // Emit warning when spellcheck is initiated.
   bool ShowColors;               // Color printing is enabled.
   OverloadsShown ShowOverloads;  // Which overload candidates to show.
   unsigned ErrorLimit;           // Cap of # errors emitted, 0 -> no limit.
@@ -466,6 +467,10 @@ public:
   /// tree format.
   void setPrintTemplateTree(bool Val = false) { PrintTemplateTree = Val; }
   bool getPrintTemplateTree() { return PrintTemplateTree; }
+
+  /// \brief Warn when spellchecking is initated, for testing.
+  void setWarnOnSpellCheck(bool Val = false) { WarnOnSpellCheck = Val; }
+  bool getWarnOnSpellCheck() { return WarnOnSpellCheck; }
  
   /// \brief Set color printing, so the type diffing will inject color markers
   /// into the output.
index 41bbff2edec25b4261a974173951b40659749a2b..8e5562c86305412c848c6ed51788b7118ce8d421 100644 (file)
@@ -72,6 +72,7 @@ DIAGOPT(VerifyDiagnostics, 1, 0) /// Check that diagnostics match the expected
 
 DIAGOPT(ElideType, 1, 0)         /// Elide identical types in template diffing
 DIAGOPT(ShowTemplateTree, 1, 0)  /// Print a template tree when diffing
+DIAGOPT(WarnOnSpellCheck, 1, 0)  /// -fwarn-on-spellcheck
 
 VALUE_DIAGOPT(ErrorLimit, 32, 0)           /// Limit # errors emitted.
 /// Limit depth of macro expansion backtrace.
index 470732ce684c946f1ee3dbf6f8247a4e60a3c34f..bd3d1b4e10a4ceda6b170cb0edd285d04616115f 100644 (file)
@@ -6074,8 +6074,6 @@ def warn_direct_ivar_access : Warning<"instance variable %0 is being "
   "directly accessed">, InGroup<DiagGroup<"direct-ivar-access">>, DefaultIgnore;
 
 // Spell-checking diagnostics
-def warn_spellcheck_initiated : Warning<"spell-checking initiated for %0">,
-  InGroup<DiagGroup<"spellcheck">>, DefaultIgnore;
 def err_unknown_type_or_class_name_suggest : Error<
   "unknown %select{type|class}2 name %0; did you mean %1?">;
 def err_unknown_typename_suggest : Error<
index b1e5bfa267cab669a2b84700b9920aa0464f2b99..24ac33d9fff7785ecd5a79e338863a3f1f3ec219 100644 (file)
@@ -239,6 +239,9 @@ def fmessage_length : Separate<["-"], "fmessage-length">, MetaVarName<"<N>">,
 def Wno_rewrite_macros : Flag<["-"], "Wno-rewrite-macros">,
   HelpText<"Silence ObjC rewriting warnings">;
 
+def fwarn_on_spellcheck : Flag<["-"], "fwarn-on-spellcheck">,
+  HelpText<"Emit warning if spell-check is initiated, for testing">;
+
 //===----------------------------------------------------------------------===//
 // Frontend Options
 //===----------------------------------------------------------------------===//
index fa592120a427fc2ba5810d8316614b617a207891..f6ba4e50ac4a28e11a8c086c63819c75999eac03 100644 (file)
@@ -561,6 +561,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
   Opts.VerifyDiagnostics = Args.hasArg(OPT_verify);
   Opts.ElideType = !Args.hasArg(OPT_fno_elide_type);
   Opts.ShowTemplateTree = Args.hasArg(OPT_fdiagnostics_show_template_tree);
+  Opts.WarnOnSpellCheck = Args.hasArg(OPT_fwarn_on_spellcheck);
   Opts.ErrorLimit = Args.getLastArgIntValue(OPT_ferror_limit, 0, Diags);
   Opts.MacroBacktraceLimit
     = Args.getLastArgIntValue(OPT_fmacro_backtrace_limit,
index 767096a1c990afe2589fa99090cf8499cc64a8e6..b7547b9998e71967cb626d5e0672c015027fc339 100644 (file)
@@ -56,6 +56,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
 
   Diags.setElideType(Opts.ElideType);
   Diags.setPrintTemplateTree(Opts.ShowTemplateTree);
+  Diags.setWarnOnSpellCheck(Opts.WarnOnSpellCheck);
   Diags.setShowColors(Opts.ShowColors);
  
   // Handle -ferror-limit
index 86ddad21f5d95e91f2e18d02d327deb139d81171..ad5b89a43abc3b725eb3a4f041d7e121042ce762 100644 (file)
@@ -3738,11 +3738,12 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
   if (S && S->isInObjcMethodScope() && Typo == getSuperIdentifier())
     return TypoCorrection();
 
-  // This is for regression testing. It's disabled by default.
-  if (Diags.getDiagnosticLevel(diag::warn_spellcheck_initiated,
-                               TypoName.getLoc()) != DiagnosticsEngine::Ignored)
-    Diag(TypoName.getLoc(), diag::warn_spellcheck_initiated)
-      << TypoName.getName();
+  // This is for testing.
+  if (Diags.getWarnOnSpellCheck()) {
+    unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Warning,
+                                            "spell-checking initiated for %0");
+    Diag(TypoName.getLoc(), DiagID) << TypoName.getName();
+  }
 
   NamespaceSpecifierSet Namespaces(Context, CurContext, SS);
 
index cb2c91bb76cb8c7172c588488fc5707d52a2b866..3fd61e2ecea32f6853550eb66d3ba1299719dd76 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Wspellcheck
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fwarn-on-spellcheck
 
 @interface B
 @property int x;