Skip to content
Snippets Groups Projects
Commit e48a65d3 authored by Jakub Jelinek's avatar Jakub Jelinek Committed by Jakub Jelinek
Browse files

Ternary operator formatting fixes

While working on PR117028 C2Y changes, I've noticed weird ternary
operator formatting (operand1 ? operand2: operand3).
The usual formatting is operand1 ? operand2 : operand3
where we have around 18000+ cases of that (counting only what fits
on one line) and
indent -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2 -ndj \
       -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -psl -nsc -nsob
documented in
https://www.gnu.org/prep/standards/html_node/Formatting.html#Formatting
does the same.
Some code was even trying to save space as much as possible and used
operand1?operand2:operand3 or
operand1 ? operand2:operand3

Today I've grepped for such cases (the grep was '?.*[^ ]:' and I had to
skim through various false positives with that where the : matched e.g.
stuff inside of strings, or *.md pattern macros or :: scope) and the
following patch is a fix for what I found.

2024-10-16  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* attribs.cc (lookup_scoped_attribute_spec): ?: operator formatting
	fixes.
	* basic-block.h (FOR_BB_INSNS_SAFE): Likewise.
	* cfgcleanup.cc (outgoing_edges_match): Likewise.
	* cgraph.cc (cgraph_node::dump): Likewise.
	* config/arc/arc.cc (gen_acc1, gen_acc2): Likewise.
	* config/arc/arc.h (CLASS_MAX_NREGS, CONSTANT_ADDRESS_P): Likewise.
	* config/arm/arm.cc (arm_print_operand): Likewise.
	* config/cris/cris.md (*b<rnzcond:code><mode>): Likewise.
	* config/darwin.cc (darwin_asm_declare_object_name,
	darwin_emit_common): Likewise.
	* config/darwin-driver.cc (darwin_driver_init): Likewise.
	* config/epiphany/epiphany.md (call, sibcall, call_value,
	sibcall_value): Likewise.
	* config/i386/i386.cc (gen_push2): Likewise.
	* config/i386/i386.h (ix86_cur_cost): Likewise.
	* config/i386/openbsdelf.h (FUNCTION_PROFILER): Likewise.
	* config/loongarch/loongarch-c.cc (loongarch_cpu_cpp_builtins):
	Likewise.
	* config/loongarch/loongarch-cpu.cc (fill_native_cpu_config):
	Likewise.
	* config/riscv/riscv.cc (riscv_union_memmodels): Likewise.
	* config/riscv/zc.md (*mva01s<X:mode>, *mvsa01<X:mode>): Likewise.
	* config/rs6000/mmintrin.h (_mm_cmpeq_pi8, _mm_cmpgt_pi8,
	_mm_cmpeq_pi16, _mm_cmpgt_pi16, _mm_cmpeq_pi32, _mm_cmpgt_pi32):
	Likewise.
	* config/v850/predicates.md (pattern_is_ok_for_prologue): Likewise.
	* config/xtensa/constraints.md (d, C, W): Likewise.
	* coverage.cc (coverage_begin_function, build_init_ctor,
	build_gcov_exit_decl): Likewise.
	* df-problems.cc (df_create_unused_note): Likewise.
	* diagnostic.cc (diagnostic_set_caret_max_width): Likewise.
	* diagnostic-path.cc (path_summary::path_summary): Likewise.
	* expr.cc (expand_expr_divmod): Likewise.
	* gcov.cc (format_gcov): Likewise.
	* gcov-dump.cc (dump_gcov_file): Likewise.
	* genmatch.cc (main): Likewise.
	* incpath.cc (remove_duplicates, register_include_chains): Likewise.
	* ipa-devirt.cc (dump_odr_type): Likewise.
	* ipa-icf.cc (sem_item_optimizer::merge_classes): Likewise.
	* ipa-inline.cc (inline_small_functions): Likewise.
	* ipa-polymorphic-call.cc (ipa_polymorphic_call_context::dump):
	Likewise.
	* ipa-sra.cc (create_parameter_descriptors): Likewise.
	* ipa-utils.cc (find_always_executed_bbs): Likewise.
	* predict.cc (predict_loops): Likewise.
	* selftest.cc (read_file): Likewise.
	* sreal.h (SREAL_SIGN, SREAL_ABS): Likewise.
	* tree-dump.cc (dequeue_and_dump): Likewise.
	* tree-ssa-ccp.cc (bit_value_binop): Likewise.
gcc/c-family/
	* c-opts.cc (c_common_init_options, c_common_handle_option,
	c_common_finish, set_std_c89, set_std_c99, set_std_c11,
	set_std_c17, set_std_c23, set_std_cxx98, set_std_cxx11,
	set_std_cxx14, set_std_cxx17, set_std_cxx20, set_std_cxx23,
	set_std_cxx26): ?: operator formatting fixes.
gcc/cp/
	* search.cc (lookup_member): ?: operator formatting fixes.
	* typeck.cc (cp_build_modify_expr): Likewise.
libcpp/
	* expr.cc (interpret_float_suffix): ?: operator formatting fixes.
parent 935b7fbd
No related branches found
No related tags found
No related merge requests found
Showing
with 86 additions and 86 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment