summaryrefslogtreecommitdiff
path: root/gcc/gcc-rich-location.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-14 23:08:34 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-14 23:08:34 +0000
commit2a990300e8fb3a2c25d5fafe25cd65ca82e5062d (patch)
tree7f70847fe1c3fb731deac7600fe4baa87c0b3c8f /gcc/gcc-rich-location.c
parent06c75b9afb967c65bb08c69758cbaa82b2f884cb (diff)
downloadgcc-2a990300e8fb3a2c25d5fafe25cd65ca82e5062d.tar.gz
Introduce gcc_rich_location::add_fixit_misspelled_id
gcc/c/ChangeLog: * c-typeck.c (build_component_ref): Simplify fixit code by using gcc_rich_location::add_fixit_misspelled_id. (set_init_label): Likewise. gcc/cp/ChangeLog: * typeck.c: Include "gcc-rich-location.h". (finish_class_member_access_expr): Simplify fixit code by using gcc_rich_location::add_fixit_misspelled_id. gcc/ChangeLog: * gcc-rich-location.c (gcc_rich_location::add_fixit_misspelled_id): New method. * gcc-rich-location.h (gcc_rich_location::add_fixit_misspelled_id): Add decl. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237463 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc-rich-location.c')
-rw-r--r--gcc/gcc-rich-location.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/gcc-rich-location.c b/gcc/gcc-rich-location.c
index a03ce0ee5fa..15c0700a25b 100644
--- a/gcc/gcc-rich-location.c
+++ b/gcc/gcc-rich-location.c
@@ -60,3 +60,17 @@ gcc_rich_location::maybe_add_expr (tree t)
if (EXPR_P (t))
add_expr (t);
}
+
+/* Add a fixit hint suggesting replacing the range at MISSPELLED_TOKEN_LOC
+ with the identifier HINT_ID. */
+
+void
+gcc_rich_location::add_fixit_misspelled_id (location_t misspelled_token_loc,
+ tree hint_id)
+{
+ gcc_assert (TREE_CODE (hint_id) == IDENTIFIER_NODE);
+
+ source_range misspelled_token_range
+ = get_range_from_loc (line_table, misspelled_token_loc);
+ add_fixit_replace (misspelled_token_range, IDENTIFIER_POINTER (hint_id));
+}