vgvassilev / clad

clad -- automatic differentiation for C/C++
GNU Lesser General Public License v3.0
280 stars 123 forks source link

Remove useless goto/label statements #938

Closed PetroZarytskyi closed 3 months ago

PetroZarytskyi commented 3 months ago

This PR removes all pairs of goto/label statements with nothing in between:

goto _label0;
_label0:

Obviously, this bit of code doesn't do anything. Such cases make up the majority of goto uses in Clad. The idea in this PR is to check whether the corresponding return statement is the last statement in the function's body. If it is, there's no need to create a goto statement. Before this PR, Clad tests contained 328 goto stmts, now they only contain 21.

Fixes #526.

github-actions[bot] commented 3 months ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 3 months ago

clang-tidy review says "All clean, LGTM! :+1:"

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.75%. Comparing base (4ebd1af) to head (d61d0a4).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vgvassilev/clad/pull/938/graphs/tree.svg?width=650&height=150&src=pr&token=9f6Q4em8hE&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev)](https://app.codecov.io/gh/vgvassilev/clad/pull/938?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) ```diff @@ Coverage Diff @@ ## master #938 +/- ## ========================================== - Coverage 93.76% 93.75% -0.01% ========================================== Files 54 54 Lines 7781 7786 +5 ========================================== + Hits 7296 7300 +4 - Misses 485 486 +1 ``` | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/938?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | Coverage Δ | | |---|---|---| | [lib/Differentiator/ReverseModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/938?src=pr&el=tree&filepath=lib%2FDifferentiator%2FReverseModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL1JldmVyc2VNb2RlVmlzaXRvci5jcHA=) | `97.26% <91.66%> (-0.04%)` | :arrow_down: | | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/938?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | Coverage Δ | | |---|---|---| | [lib/Differentiator/ReverseModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/938?src=pr&el=tree&filepath=lib%2FDifferentiator%2FReverseModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL1JldmVyc2VNb2RlVmlzaXRvci5jcHA=) | `97.26% <91.66%> (-0.04%)` | :arrow_down: |
github-actions[bot] commented 3 months ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 3 months ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 3 months ago

clang-tidy review says "All clean, LGTM! :+1:"