summaryrefslogtreecommitdiff
path: root/gcc/c-family/c-common.h
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-07 16:56:23 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-07 16:56:23 +0000
commit3da97ff7272bb77bacf5293f67e597aa040fc4f1 (patch)
treebcfb76c5cbb7225eaaa830c5addd7d9df3bc60ab /gcc/c-family/c-common.h
parentc7e4445ab0cbe4d9657f72cc56443fb0e314388e (diff)
downloadgcc-3da97ff7272bb77bacf5293f67e597aa040fc4f1.tar.gz
Move class substring_loc from c-family into gcc
gcc/ChangeLog: * Makefile.in (OBJS): Add substring-locations.o. * langhooks-def.h (class substring_loc): New forward decl. (lhd_get_substring_location): New decl. (LANG_HOOKS_GET_SUBSTRING_LOCATION): New macro. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_GET_SUBSTRING_LOCATION. * langhooks.c (lhd_get_substring_location): New function. * langhooks.h (class substring_loc): New forward decl. (struct lang_hooks): Add field get_substring_location. * substring-locations.c: New file, taking definition of format_warning_va and format_warning_at_substring from c-family/c-format.c, making them non-static. * substring-locations.h (class substring_loc): Move class here from c-family/c-common.h. Add and rewrite comments. (format_warning_va): New decl. (format_warning_at_substring): New decl. (get_source_location_for_substring): Add comment. gcc/c-family/ChangeLog: * c-common.c (get_cpp_ttype_from_string_type): Handle being passed a POINTER_TYPE. (substring_loc::get_location): Move to substring-locations.c, keeping implementation as... (c_get_substring_location): New function, from the above, reworked to use accessors rather than member lookup. * c-common.h (class substring_loc): Move to substring-locations.h, replacing with a forward decl. (c_get_substring_location): New decl. * c-format.c: Include "substring-locations.h". (format_warning_va): Move to substring-locations.c. (format_warning_at_substring): Likewise. gcc/c/ChangeLog: * c-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Use c_get_substring_location for this new langhook. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_string_literals.c: Include "substring-locations.h". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240028 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family/c-common.h')
-rw-r--r--gcc/c-family/c-common.h32
1 files changed, 3 insertions, 29 deletions
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 42ce9698bdb..1d923c90de4 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1132,35 +1132,9 @@ extern const char *cb_get_suggestion (cpp_reader *, const char *,
extern GTY(()) string_concat_db *g_string_concat_db;
-/* libcpp can calculate location information about a range of characters
- within a string literal, but doing so is non-trivial.
-
- This class encapsulates such a source location, so that it can be
- passed around (e.g. within c-format.c). It is effectively a deferred
- call into libcpp. If needed by a diagnostic, the actual source_range
- can be calculated by calling the get_range method. */
-
-class substring_loc
-{
- public:
- substring_loc (location_t fmt_string_loc, tree string_type,
- int caret_idx, int start_idx, int end_idx)
- : m_fmt_string_loc (fmt_string_loc), m_string_type (string_type),
- m_caret_idx (caret_idx), m_start_idx (start_idx), m_end_idx (end_idx) {}
-
- void set_caret_index (int caret_idx) { m_caret_idx = caret_idx; }
-
- const char *get_location (location_t *out_loc) const;
-
- location_t get_fmt_string_loc () const { return m_fmt_string_loc; }
-
- private:
- location_t m_fmt_string_loc;
- tree m_string_type;
- int m_caret_idx;
- int m_start_idx;
- int m_end_idx;
-};
+class substring_loc;
+extern const char *c_get_substring_location (const substring_loc &substr_loc,
+ location_t *out_loc);
/* In c-gimplify.c */
extern void c_genericize (tree);