spellcheck-tree.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Find near-matches for identifiers.
  2. Copyright (C) 2015-2019 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_SPELLCHECK_TREE_H
  16. #define GCC_SPELLCHECK_TREE_H
  17. #include "spellcheck.h"
  18. /* spellcheck-tree.c */
  19. extern edit_distance_t
  20. get_edit_distance (tree ident_s, tree ident_t);
  21. extern tree
  22. find_closest_identifier (tree target, const auto_vec<tree> *candidates);
  23. /* Specialization of edit_distance_traits for identifiers. */
  24. template <>
  25. struct edit_distance_traits<tree>
  26. {
  27. static size_t get_length (tree id)
  28. {
  29. gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
  30. return IDENTIFIER_LENGTH (id);
  31. }
  32. static const char *get_string (tree id)
  33. {
  34. gcc_assert (TREE_CODE (id) == IDENTIFIER_NODE);
  35. return IDENTIFIER_POINTER (id);
  36. }
  37. };
  38. #endif /* GCC_SPELLCHECK_TREE_H */