gcc-rich-location.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Declarations relating to class gcc_rich_location
  2. Copyright (C) 2014-2018 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_RICH_LOCATION_H
  16. #define GCC_RICH_LOCATION_H
  17. /* A gcc_rich_location is libcpp's rich_location with additional
  18. helper methods for working with gcc's types. */
  19. class gcc_rich_location : public rich_location
  20. {
  21. public:
  22. /* Constructors. */
  23. /* Constructing from a location. */
  24. gcc_rich_location (source_location loc) :
  25. rich_location (line_table, loc) {}
  26. /* Methods for adding ranges via gcc entities. */
  27. void
  28. add_expr (tree expr);
  29. void
  30. maybe_add_expr (tree t);
  31. void add_fixit_misspelled_id (location_t misspelled_token_loc,
  32. tree hint_id);
  33. /* If LOC is within the spans of lines that will already be printed for
  34. this gcc_rich_location, then add it as a secondary location
  35. and return true.
  36. Otherwise return false.
  37. This allows for a diagnostic to compactly print secondary locations
  38. in one diagnostic when these are near enough the primary locations for
  39. diagnostics-show-locus.c to cope with them, and to fall back to
  40. printing them via a note otherwise e.g.:
  41. gcc_rich_location richloc (primary_loc);
  42. bool added secondary = richloc.add_location_if_nearby (secondary_loc);
  43. error_at_rich_loc (&richloc, "main message");
  44. if (!added secondary)
  45. inform (secondary_loc, "message for secondary");
  46. Implemented in diagnostic-show-locus.c. */
  47. bool add_location_if_nearby (location_t loc);
  48. };
  49. #endif /* GCC_RICH_LOCATION_H */