From c0129e2d489cc0ab419c58c4f8451898c2b5e3ae Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 19 Mar 2021 10:21:35 +0100 Subject: Use startswith in targets. gcc/ChangeLog: * common/config/aarch64/aarch64-common.c (aarch64_parse_extension): Use startswith function instead of strncmp. * common/config/bfin/bfin-common.c (bfin_handle_option): Likewise. * common/config/riscv/riscv-common.c (riscv_subset_list::parse): Likewise. * config/aarch64/aarch64-sve-builtins-shapes.cc (parse_type): Likewise. * config/aarch64/aarch64.c (aarch64_process_one_target_attr): Likewise. * config/alpha/alpha.c (alpha_elf_section_type_flags): Likewise. * config/arm/aarch-common.c (arm_md_asm_adjust): Likewise. * config/arm/arm.c (arm_file_start): Likewise. (arm_valid_target_attribute_rec): Likewise. (thumb1_md_asm_adjust): Likewise. * config/arm/driver-arm.c (host_detect_local_cpu): Likewise. * config/avr/avr.c (STR_PREFIX_P): Likewise. (avr_set_current_function): Likewise. (avr_handle_addr_attribute): Likewise. (avr_asm_output_aligned_decl_common): Likewise. (avr_asm_named_section): Likewise. (avr_section_type_flags): Likewise. (avr_asm_select_section): Likewise. * config/c6x/c6x.c (c6x_in_small_data_p): Likewise. (c6x_section_type_flags): Likewise. * config/darwin-c.c (darwin_cfstring_ref_p): Likewise. (darwin_objc_declare_unresolved_class_reference): Likewise. (darwin_objc_declare_class_definition): Likewise. * config/darwin.c (indirect_data): Likewise. (darwin_encode_section_info): Likewise. (darwin_objc2_section): Likewise. (darwin_objc1_section): Likewise. (machopic_select_section): Likewise. (darwin_globalize_label): Likewise. (darwin_label_is_anonymous_local_objc_name): Likewise. (darwin_asm_named_section): Likewise. (darwin_asm_output_dwarf_offset): Likewise. * config/frv/frv.c (frv_string_begins_with): Likewise. (frv_in_small_data_p): Likewise. * config/gcn/mkoffload.c (STR): Likewise. (main): Likewise. * config/i386/i386-builtins.c (get_builtin_code_for_version): Likewise. * config/i386/i386-options.c (ix86_option_override_internal): Likewise. * config/i386/i386.c (x86_64_elf_section_type_flags): Likewise. (ix86_md_asm_adjust): Likewise. * config/i386/intelmic-mkoffload.c (STR): Likewise. * config/i386/winnt.c (i386_pe_asm_named_section): Likewise. (i386_pe_file_end): Likewise. * config/ia64/ia64.c (ia64_in_small_data_p): Likewise. (ia64_section_type_flags): Likewise. * config/mips/driver-native.c (host_detect_local_cpu): Likewise. * config/mips/mips.c (mips_handle_interrupt_attr): Likewise. (mips16_stub_function_p): Likewise. (mips_function_rodata_section): Likewise. * config/msp430/msp430.c (msp430_mcu_name): Likewise. (msp430_function_section): Likewise. (msp430_section_type_flags): Likewise. (msp430_expand_helper): Likewise. * config/nios2/nios2.c (nios2_small_section_name_p): Likewise. (nios2_valid_target_attribute_rec): Likewise. * config/nvptx/mkoffload.c (process): Likewise. (STR): Likewise. * config/pa/som.h: Likewise. * config/pdp11/pdp11.c (pdp11_output_ident): Likewise. * config/riscv/riscv.c (riscv_elf_select_rtx_section): Likewise. * config/rs6000/rs6000.c (VTABLE_NAME_P): Likewise. (rs6000_inner_target_options): Likewise. * config/s390/driver-native.c (s390_host_detect_local_cpu): Likewise. * config/sparc/driver-sparc.c (host_detect_local_cpu): Likewise. * config/vax/vax.c (vax_output_int_move): Likewise. * config/vms/vms-ld.c (startswith): Likewise. (process_args): Likewise. (main): Likewise. * config/vms/vms.c: Likewise. --- gcc/config/avr/avr.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'gcc/config/avr/avr.c') diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 06c84d5..c95c436 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -63,9 +63,6 @@ /* Maximal allowed offset for an address in the LD command */ #define MAX_LD_OFFSET(MODE) (64 - (signed)GET_MODE_SIZE (MODE)) -/* Return true if STR starts with PREFIX and false, otherwise. */ -#define STR_PREFIX_P(STR,PREFIX) (strncmp (STR, PREFIX, strlen (PREFIX)) == 0) - /* The 4 bits starting at SECTION_MACH_DEP are reserved to store the address space where data is to be located. As the only non-generic address spaces are all located in flash, @@ -1092,7 +1089,7 @@ avr_set_current_function (tree decl) that the name of the function is "__vector_NN" so as to catch when the user misspells the vector name. */ - if (!STR_PREFIX_P (name, "__vector")) + if (!startswith (name, "__vector")) warning_at (loc, OPT_Wmisspelled_isr, "%qs appears to be a misspelled " "%qs handler, missing %<__vector%> prefix", name, isr); #endif // AVR-LibC naming conventions @@ -9642,7 +9639,7 @@ static tree avr_handle_addr_attribute (tree *node, tree name, tree args, int flags ATTRIBUTE_UNUSED, bool *no_add) { - bool io_p = (strncmp (IDENTIFIER_POINTER (name), "io", 2) == 0); + bool io_p = startswith (IDENTIFIER_POINTER (name), "io"); location_t loc = DECL_SOURCE_LOCATION (*node); if (!VAR_P (*node)) @@ -10055,7 +10052,7 @@ avr_asm_output_aligned_decl_common (FILE * stream, /* __gnu_lto_slim is just a marker for the linker injected by toplev.c. There is no need to trigger __do_clear_bss code for them. */ - if (!STR_PREFIX_P (name, "__gnu_lto")) + if (!startswith (name, "__gnu_lto")) avr_need_clear_bss_p = true; if (local_p) @@ -10154,7 +10151,7 @@ avr_asm_named_section (const char *name, unsigned int flags, tree decl) const char *old_prefix = ".rodata"; const char *new_prefix = avr_addrspace[as].section_name; - if (STR_PREFIX_P (name, old_prefix)) + if (startswith (name, old_prefix)) { const char *sname = ACONCAT ((new_prefix, name + strlen (old_prefix), NULL)); @@ -10167,19 +10164,19 @@ avr_asm_named_section (const char *name, unsigned int flags, tree decl) } if (!avr_need_copy_data_p) - avr_need_copy_data_p = (STR_PREFIX_P (name, ".data") - || STR_PREFIX_P (name, ".gnu.linkonce.d")); + avr_need_copy_data_p = (startswith (name, ".data") + || startswith (name, ".gnu.linkonce.d")); if (!avr_need_copy_data_p #if defined HAVE_LD_AVR_AVRXMEGA3_RODATA_IN_FLASH && avr_arch->flash_pm_offset == 0 #endif ) - avr_need_copy_data_p = (STR_PREFIX_P (name, ".rodata") - || STR_PREFIX_P (name, ".gnu.linkonce.r")); + avr_need_copy_data_p = (startswith (name, ".rodata") + || startswith (name, ".gnu.linkonce.r")); if (!avr_need_clear_bss_p) - avr_need_clear_bss_p = STR_PREFIX_P (name, ".bss"); + avr_need_clear_bss_p = startswith (name, ".bss"); default_elf_asm_named_section (name, flags, decl); } @@ -10192,7 +10189,7 @@ avr_section_type_flags (tree decl, const char *name, int reloc) { unsigned int flags = default_section_type_flags (decl, name, reloc); - if (STR_PREFIX_P (name, ".noinit")) + if (startswith (name, ".noinit")) { if (decl && TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl) == NULL_TREE) @@ -10402,7 +10399,7 @@ avr_asm_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align) const char * old_prefix = ".rodata"; const char * new_prefix = avr_addrspace[as].section_name; - if (STR_PREFIX_P (name, old_prefix)) + if (startswith (name, old_prefix)) { const char *sname = ACONCAT ((new_prefix, name + strlen (old_prefix), NULL)); -- cgit v1.1