summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-16 01:40:35 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-16 01:40:35 +0000
commit6aa240c03dd68ab413106d6af7a18af1c9b4e872 (patch)
treea75e57eab6b55ee500dea8d2aee96b6bb6d98dbc
parent1efffab67364f5afcc25f5f5f77e0f7ba5d41055 (diff)
downloadclang-6aa240c03dd68ab413106d6af7a18af1c9b4e872.tar.gz
clang-6aa240c03dd68ab413106d6af7a18af1c9b4e872.tar.bz2
clang-6aa240c03dd68ab413106d6af7a18af1c9b4e872.tar.xz
Remove -Wspellcheck and replace it with a diagnostic option.
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
-rw-r--r--include/clang/Basic/Diagnostic.h5
-rw-r--r--include/clang/Basic/DiagnosticOptions.def1
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--include/clang/Driver/CC1Options.td3
-rw-r--r--lib/Frontend/CompilerInvocation.cpp1
-rw-r--r--lib/Frontend/Warnings.cpp1
-rw-r--r--lib/Sema/SemaLookup.cpp11
-rw-r--r--test/SemaObjC/typo-correction.m2
8 files changed, 18 insertions, 8 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index 0a501cb4cc..0b7c54ecf5 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -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.
diff --git a/include/clang/Basic/DiagnosticOptions.def b/include/clang/Basic/DiagnosticOptions.def
index 41bbff2ede..8e5562c863 100644
--- a/include/clang/Basic/DiagnosticOptions.def
+++ b/include/clang/Basic/DiagnosticOptions.def
@@ -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.
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 470732ce68..bd3d1b4e10 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index b1e5bfa267..24ac33d9ff 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -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
//===----------------------------------------------------------------------===//
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index fa592120a4..f6ba4e50ac 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -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,
diff --git a/lib/Frontend/Warnings.cpp b/lib/Frontend/Warnings.cpp
index 767096a1c9..b7547b9998 100644
--- a/lib/Frontend/Warnings.cpp
+++ b/lib/Frontend/Warnings.cpp
@@ -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
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 86ddad21f5..ad5b89a43a 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -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);
diff --git a/test/SemaObjC/typo-correction.m b/test/SemaObjC/typo-correction.m
index cb2c91bb76..3fd61e2ece 100644
--- a/test/SemaObjC/typo-correction.m
+++ b/test/SemaObjC/typo-correction.m
@@ -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;