On 17/06/2025 14:37, Jeff Law wrote:


On 6/12/25 10:53 AM, Alfie Richards wrote:
The string_slice inherits from array_slice and is used to refer to a
substring of an array that is memory managed elsewhere without modifying
the underlying array.

For example, this is useful in cases such as when needing to refer to a
substring of an attribute in the syntax tree.

Adds some minimal helper functions for string_slice,
such as a strtok alternative, equality operators, strcmp, and a function
to strip whitespace from the beginning and end of a string_slice.

gcc/c-family/ChangeLog:

    * c-format.cc (local_string_slice_node): New node type.
    (asm_fprintf_char_table): New entry.
    (init_dynamic_diag_info): Add support for string_slice.
    * c-format.h (T_STRING_SLICE): New node type.

gcc/ChangeLog:

    * pretty-print.cc (format_phase_2): Add support for string_slice.
    * vec.cc (string_slice::tokenize): New method.
    (strcmp): New implementation for string_slice.
    (string_slice::strip): New method.
    (test_string_slice_initializers): New test.
    (test_string_slice_tokenize): Ditto.
    (test_string_slice_strcmp): Ditto.
    (test_string_slice_equality): Ditto.
    (test_string_slice_inequality): Ditto.
    (test_string_slice_invalid): Ditto.
    (test_string_slice_strip): Ditto.
    (vec_cc_tests): Add new tests.
    * vec.h (class string_slice): New class.
    (strcmp): New implementation for stirng_slice.
Weird.  I thought I'd commented on this already.

The new functions in vec.cc need function comments.

Apologies, will add some.

Should the "strcmp" function be a static method within the string_slice class.  I don't have strong opinions on that and I'm happy to go with consensus opinions.

To be honest I'm a little confused as I thought I had already done this.

Thanks for the feedback, I will send an update to this patch.

Alfie


Jeff

Reply via email to