Implement Levenshtein distance; use in C FE for misspelled field names
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 13 Nov 2015 01:54:41 +0000 (01:54 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Fri, 13 Nov 2015 01:54:41 +0000 (01:54 +0000)
commit277fe616911ac1ce91e9f1178d648303b4a26940
tree574b1272f86df52172c56c614532ff5032b6f73d
parent6d82151f8c08d123eaab63409cd8ba6f85d0539c
Implement Levenshtein distance; use in C FE for misspelled field names

This is the combination of:
  [PATCH 1/2] Implement Levenshtein distance
  [PATCH 2/2] C FE: suggest corrections for misspelled field names
plus some nit fixes in spellcheck.c.

gcc/ChangeLog:
* Makefile.in (OBJS): Add spellcheck.o.
* spellcheck.c: New file.
* spellcheck.h: New file.

gcc/c/ChangeLog:
* c-typeck.c: Include spellcheck.h.
(lookup_field_fuzzy_find_candidates): New function.
(lookup_field_fuzzy): New function.
(build_component_ref): If the field was not found, try using
lookup_field_fuzzy and potentially offer a suggestion.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/levenshtein-test-1.c: New file.
* gcc.dg/plugin/levenshtein_plugin.c: New file.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add
levenshtein_plugin.c.
* gcc.dg/spellcheck-fields.c: New file.

From-SVN: r230284
gcc/ChangeLog
gcc/Makefile.in
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/spellcheck.c [new file with mode: 0644]
gcc/spellcheck.h [new file with mode: 0644]
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/levenshtein-test-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/levenshtein_plugin.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/plugin/plugin.exp
gcc/testsuite/gcc.dg/spellcheck-fields.c [new file with mode: 0644]