diff options
author | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-07-20 14:03:03 +0000 |
---|---|---|
committer | dmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-07-20 14:03:03 +0000 |
commit | d0f11d683993cac93ddfa00c7628e167d08585a1 (patch) | |
tree | 4295610e81aed46c2605b630ee7f4d3963766ac1 /gcc/spellcheck-tree.h | |
parent | fdb7080974b87f08b9ff02d6b69f48fd2718007f (diff) | |
download | gcc-d0f11d683993cac93ddfa00c7628e167d08585a1.tar.gz |
Enabling work for C++ handling of misspelled identifiers and typenames
gcc/c/ChangeLog:
* c-decl.c (struct edit_distance_traits<cpp_hashnode *>): Move to
spellcheck-tree.h
(best_macro_match): Likewise, converting from a typedef to a
subclass.
(find_closest_macro_cpp_cb): Move to spellcheck-tree.c.
(lookup_name_fuzzy): Update for change of best_macro_match to a
subclass with a ctor that calls cpp_forall_identifiers.
gcc/ChangeLog:
* diagnostic-show-locus.c (diagnostic_show_locus): If this is the
same location as last time, don't skip if we have fix-it hints.
Clarify the skipping logic by converting it from one "if" clause
to repeated "if" clauses.
* spellcheck-tree.c: Include "cpplib.h".
(find_closest_macro_cpp_cb): Move here from c/c-decl.c.
(best_macro_match::best_macro_match): New constructor.
* spellcheck-tree.h (struct edit_distance_traits<cpp_hashnode *>):
Move here from c/c-decl.c.
(class best_macro_match): Move here from c/c-decl.c, converting
from a typedef to a subclass, gaining a ctor.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238522 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/spellcheck-tree.h')
-rw-r--r-- | gcc/spellcheck-tree.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/spellcheck-tree.h b/gcc/spellcheck-tree.h index 0d5e253562f..0e43d148c95 100644 --- a/gcc/spellcheck-tree.h +++ b/gcc/spellcheck-tree.h @@ -48,4 +48,30 @@ struct edit_distance_traits<tree> } }; +/* Specialization of edit_distance_traits for preprocessor macros. */ + +template <> +struct edit_distance_traits<cpp_hashnode *> +{ + static size_t get_length (cpp_hashnode *hashnode) + { + return hashnode->ident.len; + } + + static const char *get_string (cpp_hashnode *hashnode) + { + return (const char *)hashnode->ident.str; + } +}; + +/* Specialization of best_match<> for finding the closest preprocessor + macro to a given identifier. */ + +class best_macro_match : public best_match<tree, cpp_hashnode *> +{ + public: + best_macro_match (tree goal, edit_distance_t best_distance_so_far, + cpp_reader *reader); +}; + #endif /* GCC_SPELLCHECK_TREE_H */ |