diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-07-09 17:35:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-07-09 17:35:33 +0000 |
commit | a0068fc64351db9c47916566e3b85ab733cd8d6d (patch) | |
tree | 6e30a06750192ecb464bc4ce890567d8df62ba9e | |
parent | e8d44dd52cd484e486945470bcdf4ae47027dec5 (diff) |
Introduce -f{no-}spell-checking options to enable/disable
spell-checking. By default, spell-checking is enabled for Clang
(obviously) but disabled in CIndex for performance reasons.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107992 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/LangOptions.h | 3 | ||||
-rw-r--r-- | include/clang/Driver/CC1Options.td | 2 | ||||
-rw-r--r-- | include/clang/Driver/Options.td | 2 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 4 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 1 | ||||
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 1 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 2 | ||||
-rw-r--r-- | test/FixIt/no-typo.c | 6 | ||||
-rw-r--r-- | tools/libclang/CIndex.cpp | 2 |
10 files changed, 23 insertions, 1 deletions
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index c4f368801d..bbcceb70ac 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -102,6 +102,8 @@ public: unsigned InlineVisibilityHidden : 1; // Whether inline C++ methods have // hidden visibility by default. + unsigned SpellChecking : 1; // Whether to perform spell-checking for error + // recovery. // FIXME: This is just a temporary option, for testing purposes. unsigned NoBitFieldTypeAlign : 1; @@ -179,6 +181,7 @@ public: CatchUndefined = 0; DumpRecordLayouts = 0; DumpVTableLayouts = 0; + SpellChecking = 1; NoBitFieldTypeAlign = 0; } diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 51695a0848..7076f30995 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -411,6 +411,8 @@ def fno_operator_names : Flag<"-fno-operator-names">, HelpText<"Do not treat C++ operator name keywords as synonyms for operators">; def fno_signed_char : Flag<"-fno-signed-char">, HelpText<"Char is unsigned">; +def fno_spell_checking : Flag<"-fno-spell-checking">, + HelpText<"Disable spell-checking">; def fno_use_cxa_atexit : Flag<"-fno-use-cxa-atexit">, HelpText<"Don't use __cxa_atexit for calling destructors">; def fconstant_string_class : Separate<"-fconstant-string-class">, diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index b12f5be54d..96ec12215b 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -326,6 +326,7 @@ def fno_pascal_strings : Flag<"-fno-pascal-strings">, Group<f_Group>; def fno_rtti : Flag<"-fno-rtti">, Group<f_Group>; def fno_show_column : Flag<"-fno-show-column">, Group<f_Group>; def fno_show_source_location : Flag<"-fno-show-source-location">, Group<f_Group>; +def fno_spell_checking : Flag<"-fno-spell-checking">, Group<f_Group>; def fno_stack_protector : Flag<"-fno-stack-protector">, Group<f_Group>; def fno_strict_aliasing : Flag<"-fno-strict-aliasing">, Group<clang_ignored_f_Group>; def fno_threadsafe_statics : Flag<"-fno-threadsafe-statics">, Group<f_Group>; @@ -365,6 +366,7 @@ def freorder_blocks : Flag<"-freorder-blocks">, Group<clang_ignored_f_Group>; def fshort_wchar : Flag<"-fshort-wchar">, Group<f_Group>; def fshow_overloads_EQ : Joined<"-fshow-overloads=">, Group<f_Group>; def fshow_source_location : Flag<"-fshow-source-location">, Group<f_Group>; +def fspell_checking : Flag<"-fspell-checking">, Group<f_Group>; def fsigned_bitfields : Flag<"-fsigned-bitfields">, Group<f_Group>; def fsigned_char : Flag<"-fsigned-char">, Group<f_Group>; def fstack_protector_all : Flag<"-fstack-protector-all">, Group<f_Group>; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 296d541370..9e03a18ae0 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1401,6 +1401,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_fno_show_source_location)) CmdArgs.push_back("-fno-show-source-location"); + if (!Args.hasFlag(options::OPT_fspell_checking, + options::OPT_fno_spell_checking)) + CmdArgs.push_back("-fno-spell-checking"); + if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ)) A->render(Args, CmdArgs); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 239283a0cc..418d25b0d4 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1321,6 +1321,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.Static = Args.hasArg(OPT_static_define); Opts.DumpRecordLayouts = Args.hasArg(OPT_fdump_record_layouts); Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts); + Opts.SpellChecking = !Args.hasArg(OPT_fno_spell_checking); Opts.NoBitFieldTypeAlign = Args.hasArg(OPT_fno_bitfield_type_align); Opts.OptimizeSize = 0; diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 6acfdb29e4..b452a0d301 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -124,6 +124,7 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) { PARSE_LANGOPT_IMPORTANT(OpenCL, diag::warn_pch_opencl); PARSE_LANGOPT_BENIGN(CatchUndefined); PARSE_LANGOPT_IMPORTANT(ElideConstructors, diag::warn_pch_elide_constructors); + PARSE_LANGOPT_BENIGN(SpellChecking); #undef PARSE_LANGOPT_IMPORTANT #undef PARSE_LANGOPT_BENIGN diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 18ceef99c9..47347cac5e 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -869,6 +869,7 @@ void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) { Record.push_back(LangOpts.OpenCL); Record.push_back(LangOpts.CatchUndefined); Record.push_back(LangOpts.ElideConstructors); + Record.push_back(LangOpts.SpellChecking); Stream.EmitRecord(pch::LANGUAGE_OPTIONS, Record); } diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index c11e3b371d..2e651838df 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -2726,7 +2726,7 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, bool EnteringContext, CorrectTypoContext CTC, const ObjCObjectPointerType *OPT) { - if (Diags.hasFatalErrorOccurred()) + if (Diags.hasFatalErrorOccurred() || !getLangOptions().SpellChecking) return DeclarationName(); // Provide a stop gap for files that are just seriously broken. Trying diff --git a/test/FixIt/no-typo.c b/test/FixIt/no-typo.c new file mode 100644 index 0000000000..05947e88e9 --- /dev/null +++ b/test/FixIt/no-typo.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -fno-spell-checking -verify %s +typedef struct { + float x, y; +} Point; + +point p1; // expected-error{{unknown type name 'point'}} diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index ce9357de33..ee2e45f557 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1184,6 +1184,7 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx, // in the actual argument list. if (source_filename) Args.push_back(source_filename); + Args.push_back("-fno-spell-checking"); Args.insert(Args.end(), command_line_args, command_line_args + num_command_line_args); Args.push_back("-Xclang"); @@ -1247,6 +1248,7 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx, argv.push_back("-o"); char astTmpFile[L_tmpnam]; argv.push_back(tmpnam(astTmpFile)); + argv.push_back("-fno-spell-checking"); // Remap any unsaved files to temporary files. std::vector<llvm::sys::Path> TemporaryFiles; |