[Ada] Remove redundant checks for missing lists
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 20 May 2022 07:41:30 +0000 (09:41 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 2 Jun 2022 09:06:45 +0000 (09:06 +0000)
commitb05a31e579ec2e46c46c4b3f36fffdf0e959bd1f
treefccac0415278884fdcc26f23e557960b669f4d79
parent89e037d0e36654e84823c47980ef19dc0f77b8ce
[Ada] Remove redundant checks for missing lists

When iterating over list elements with First/Next there is no need to
check if the list is present, because First intentionally returns Empty
if list is not present and the condition of subsequent loop will not be
satisfied.

Code cleanup; semantics is unaffected.

Occurrences of the redundant pattern were found with:

  $ grep First -B 3 | less

and examining the output for the calls to Present.

gcc/ada/

* exp_ch13.adb, exp_ch5.adb, exp_ch9.adb, exp_strm.adb,
sem_ch10.adb, sem_ch13.adb, sem_ch5.adb, sem_ch6.adb,
sem_ch8.adb, sem_elab.adb, sem_eval.adb, sem_prag.adb,
sem_util.adb: Remove checks for the missing list before
iterating with First/Next; reindent code and refill comments.
13 files changed:
gcc/ada/exp_ch13.adb
gcc/ada/exp_ch5.adb
gcc/ada/exp_ch9.adb
gcc/ada/exp_strm.adb
gcc/ada/sem_ch10.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_elab.adb
gcc/ada/sem_eval.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb