aboutsummaryrefslogtreecommitdiff
path: root/gcc/collect2.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-03-17 16:36:44 +0100
committerMartin Liska <mliska@suse.cz>2021-05-10 09:33:29 +0200
commit6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b (patch)
treefe403786765fe8f105492c94df12561b01c35cb8 /gcc/collect2.c
parentfea26bad2e5b9078d6a6b16d5e48653e31794273 (diff)
downloadgcc-6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b.zip
gcc-6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b.tar.gz
gcc-6ba3079dce89d9b63bf5dbd5e320ea2bf96f196b.tar.bz2
Come up with startswith function.
gcc/ada/ChangeLog: * gcc-interface/utils.c (def_builtin_1): Use startswith function instead of strncmp. gcc/analyzer/ChangeLog: * sm-file.cc (is_file_using_fn_p): Use startswith function instead of strncmp. gcc/ChangeLog: * builtins.c (is_builtin_name): Use startswith function instead of strncmp. * collect2.c (main): Likewise. (has_lto_section): Likewise. (scan_libraries): Likewise. * coverage.c (coverage_checksum_string): Likewise. (coverage_init): Likewise. * dwarf2out.c (is_cxx): Likewise. (gen_compile_unit_die): Likewise. * gcc-ar.c (main): Likewise. * gcc.c (init_spec): Likewise. (read_specs): Likewise. (execute): Likewise. (check_live_switch): Likewise. * genattrtab.c (write_attr_case): Likewise. (IS_ATTR_GROUP): Likewise. * gencfn-macros.c (main): Likewise. * gengtype.c (type_for_name): Likewise. (gen_rtx_next): Likewise. (get_file_langdir): Likewise. (write_local): Likewise. * genmatch.c (get_operator): Likewise. (get_operand_type): Likewise. (expr::gen_transform): Likewise. * genoutput.c (validate_optab_operands): Likewise. * incpath.c (add_sysroot_to_chain): Likewise. * langhooks.c (lang_GNU_C): Likewise. (lang_GNU_CXX): Likewise. (lang_GNU_Fortran): Likewise. (lang_GNU_OBJC): Likewise. * lto-wrapper.c (run_gcc): Likewise. * omp-general.c (omp_max_simt_vf): Likewise. * omp-low.c (omp_runtime_api_call): Likewise. * opts-common.c (parse_options_from_collect_gcc_options): Likewise. * read-rtl-function.c (function_reader::read_rtx_operand_r): Likewise. * real.c (real_from_string): Likewise. * selftest.c (assert_str_startswith): Likewise. * timevar.c (timer::validate_phases): Likewise. * tree.c (get_file_function_name): Likewise. * ubsan.c (ubsan_use_new_style_p): Likewise. * varasm.c (default_function_rodata_section): Likewise. (incorporeal_function_p): Likewise. (default_section_type_flags): Likewise. * system.h (startswith): Define startswith. gcc/c-family/ChangeLog: * c-ada-spec.c (print_destructor): Use startswith function instead of strncmp. (dump_ada_declaration): Likewise. * c-common.c (disable_builtin_function): Likewise. (def_builtin_1): Likewise. * c-format.c (check_tokens): Likewise. (check_plain): Likewise. (convert_format_name_to_system_name): Likewise. gcc/c/ChangeLog: * c-aux-info.c (affix_data_type): Use startswith function instead of strncmp. * c-typeck.c (build_function_call_vec): Likewise. * gimple-parser.c (c_parser_gimple_parse_bb_spec): Likewise. gcc/cp/ChangeLog: * decl.c (duplicate_decls): Use startswith function instead of strncmp. (cxx_builtin_function): Likewise. (omp_declare_variant_finalize_one): Likewise. (grokfndecl): Likewise. * error.c (dump_decl_name): Likewise. * mangle.c (find_decomp_unqualified_name): Likewise. (write_guarded_var_name): Likewise. (decl_tls_wrapper_p): Likewise. * parser.c (cp_parser_simple_type_specifier): Likewise. (cp_parser_tx_qualifier_opt): Likewise. * pt.c (template_parm_object_p): Likewise. (dguide_name_p): Likewise. gcc/d/ChangeLog: * d-builtins.cc (do_build_builtin_fn): Use startswith function instead of strncmp. * dmd/dinterpret.c (evaluateIfBuiltin): Likewise. * dmd/dmangle.c: Likewise. * dmd/hdrgen.c: Likewise. * dmd/identifier.c (Identifier::toHChars2): Likewise. gcc/fortran/ChangeLog: * decl.c (variable_decl): Use startswith function instead of strncmp. (gfc_match_end): Likewise. * gfortran.h (gfc_str_startswith): Likewise. * module.c (load_omp_udrs): Likewise. (read_module): Likewise. * options.c (gfc_handle_runtime_check_option): Likewise. * primary.c (match_arg_list_function): Likewise. * trans-decl.c (gfc_get_symbol_decl): Likewise. * trans-expr.c (gfc_conv_procedure_call): Likewise. * trans-intrinsic.c (gfc_conv_ieee_arithmetic_function): Likewise. gcc/go/ChangeLog: * gofrontend/runtime.cc (Runtime::name_to_code): Use startswith function instead of strncmp. gcc/objc/ChangeLog: * objc-act.c (objc_string_ref_type_p): Use startswith function instead of strncmp. * objc-encoding.c (encode_type): Likewise. * objc-next-runtime-abi-02.c (has_load_impl): Likewise.
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r--gcc/collect2.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c
index bd37143..0ddb169 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -956,7 +956,7 @@ main (int argc, char **argv)
{
if (! strcmp (argv[i], "-debug"))
debug = true;
- else if (!strncmp (argv[i], "-fno-lto", 8))
+ else if (startswith (argv[i], "-fno-lto"))
lto_mode = LTO_MODE_NONE;
else if (! strcmp (argv[i], "-plugin"))
{
@@ -970,7 +970,7 @@ main (int argc, char **argv)
selected_linker = USE_GOLD_LD;
else if (strcmp (argv[i], "-fuse-ld=lld") == 0)
selected_linker = USE_LLD_LD;
- else if (strncmp (argv[i], "-o", 2) == 0)
+ else if (startswith (argv[i], "-o"))
{
/* Parse the output filename if it's given so that we can make
meaningful temp filenames. */
@@ -984,19 +984,19 @@ main (int argc, char **argv)
/* These flags are position independent, although their order
is important - subsequent flags override earlier ones. */
else if (strcmp (argv[i], "-b64") == 0)
- aix64_flag = 1;
+ aix64_flag = 1;
/* -bexport:filename always needs the :filename */
- else if (strncmp (argv[i], "-bE:", 4) == 0
- || strncmp (argv[i], "-bexport:", 9) == 0)
- export_flag = 1;
+ else if (startswith (argv[i], "-bE:")
+ || startswith (argv[i], "-bexport:"))
+ export_flag = 1;
else if (strcmp (argv[i], "-brtl") == 0
|| strcmp (argv[i], "-bsvr4") == 0
|| strcmp (argv[i], "-G") == 0)
- aixrtl_flag = 1;
+ aixrtl_flag = 1;
else if (strcmp (argv[i], "-bnortl") == 0)
- aixrtl_flag = 0;
+ aixrtl_flag = 0;
else if (strcmp (argv[i], "-blazy") == 0)
- aixlazy_flag = 1;
+ aixlazy_flag = 1;
#endif
}
@@ -1016,11 +1016,11 @@ main (int argc, char **argv)
const char *q = extract_string (&p);
if (*q == '-' && (q[1] == 'm' || q[1] == 'f'))
num_c_args++;
- if (strncmp (q, "-flto-partition=none", 20) == 0)
+ if (startswith (q, "-flto-partition=none"))
no_partition = true;
- else if (strncmp (q, "-fno-lto", 8) == 0)
+ else if (startswith (q, "-fno-lto"))
lto_mode = LTO_MODE_NONE;
- else if (strncmp (q, "-save-temps", 11) == 0)
+ else if (startswith (q, "-save-temps"))
/* FIXME: Honour =obj. */
save_temps = true;
else if (strcmp (q, "-dumpdir") == 0)
@@ -1254,7 +1254,7 @@ main (int argc, char **argv)
(void) extract_string (&p);
#ifdef COLLECT_EXPORT_LIST
/* Detect any invocation with -fvisibility. */
- if (strncmp (q, "-fvisibility", 12) == 0)
+ if (startswith (q, "-fvisibility"))
visibility_flag = 1;
#endif
}
@@ -1303,7 +1303,7 @@ main (int argc, char **argv)
break;
case 'f':
- if (strncmp (arg, "-flto", 5) == 0)
+ if (startswith (arg, "-flto"))
{
#ifdef ENABLE_LTO
/* Do not pass LTO flag to the linker. */
@@ -1315,13 +1315,13 @@ main (int argc, char **argv)
#endif
}
else if (!use_collect_ld
- && strncmp (arg, "-fuse-ld=", 9) == 0)
+ && startswith (arg, "-fuse-ld="))
{
/* Do not pass -fuse-ld={bfd|gold|lld} to the linker. */
ld1--;
ld2--;
}
- else if (strncmp (arg, "-fno-lto", 8) == 0)
+ else if (startswith (arg, "-fno-lto"))
{
/* Do not pass -fno-lto to the linker. */
ld1--;
@@ -1462,7 +1462,7 @@ main (int argc, char **argv)
ld2--;
#endif
}
- else if (strncmp (arg, "--demangle", 10) == 0)
+ else if (startswith (arg, "--demangle"))
{
#ifndef HAVE_LD_DEMANGLE
no_demangle = 0;
@@ -1479,7 +1479,7 @@ main (int argc, char **argv)
ld2--;
#endif
}
- else if (strncmp (arg, "--sysroot=", 10) == 0)
+ else if (startswith (arg, "--sysroot="))
target_system_root = arg + 10;
else if (strcmp (arg, "--version") == 0)
verbose = true;
@@ -2307,13 +2307,9 @@ has_lto_section (void *data, const char *name ATTRIBUTE_UNUSED,
{
int *found = (int *) data;
- if (strncmp (name, LTO_SECTION_NAME_PREFIX,
- sizeof (LTO_SECTION_NAME_PREFIX) - 1) != 0)
- {
- if (strncmp (name, OFFLOAD_SECTION_NAME_PREFIX,
- sizeof (OFFLOAD_SECTION_NAME_PREFIX) - 1) != 0)
- return 1;
- }
+ if (!startswith (name, LTO_SECTION_NAME_PREFIX)
+ && !startswith (name, OFFLOAD_SECTION_NAME_PREFIX))
+ return 1;
*found = 1;
@@ -2619,7 +2615,7 @@ scan_libraries (const char *prog_name)
continue;
name = p;
- if (strncmp (name, "not found", sizeof ("not found") - 1) == 0)
+ if (startswith (name, "not found"))
fatal_error (input_location, "dynamic dependency %s not found", buf);
/* Find the end of the symbol name. */