Enable clang-tidy checks for self-assignment #30234

pull theuni wants to merge 2 commits into bitcoin:master from theuni:clang-tidy-self-assign changing 4 files +20 −11
  1. theuni commented at 5:53 pm on June 5, 2024: member

    See comment here: #30161 (comment)

    Our code failed these checks in three places, which have been fixed up here. Though these appear to have been harmless, adding the check avoids the copy in the self-assignment case so there should be no downside.

    ~Additionally, minisketch failed the check as well. See https://github.com/sipa/minisketch/pull/87~ Edit: Done

    After fixing up the violations, turn on the aggressive clang-tidy check.

    Note for reviewers: git diff -w makes this trivial to review.

  2. DrahtBot commented at 5:53 pm on June 5, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hebasto, TheCharlatan

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    No conflicts as of last run.

  3. hebasto commented at 5:56 pm on June 5, 2024: member

    Concept ACK.

    I’ve created a similar branch this morning following the discussion in #30161 :)

  4. theuni force-pushed on Jun 5, 2024
  5. DrahtBot added the label CI failed on Jun 5, 2024
  6. DrahtBot commented at 6:33 pm on June 5, 2024: contributor

    🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

    Possibly this is due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    Leave a comment here, if you need help tracking down a confusing failure.

    Debug: https://github.com/bitcoin/bitcoin/runs/25855234654

  7. theuni referenced this in commit 4adecc525f on Jun 5, 2024
  8. theuni commented at 7:29 pm on June 5, 2024: member

    @maflcko Hmm, how best to ignore the tidy false-positive in a leveldb header?

    ./leveldb/include/leveldb/status.h:106:24: error: operator=() does not handle self-assignment properly

    It looks like we could add ExcludeHeaderFilterRegex to our tidy config, but that’s not wired up until clang-tidy-19.

  9. theuni referenced this in commit 0c1852be7e on Jun 5, 2024
  10. theuni referenced this in commit 91a15232a0 on Jun 5, 2024
  11. maflcko commented at 9:08 am on June 6, 2024: member
    Could add a patch to the leveldb subtree?
  12. hebasto commented at 9:41 am on June 6, 2024: member

    Hmm, how best to ignore the tidy false-positive in a leveldb header?

    FWIW, in the CMake staging branch, all subtrees are already excluded from being analyzed by clang-tidy.

  13. fanquake commented at 9:45 am on June 6, 2024: member

    FWIW, in the CMake staging branch, all subtrees are already excluded from being analyzed by clang-tidy.

    Is that actually the behaviour we want for all subtrees? Sounds like it could just hide bugs, and no-one is running any checks in the upstream repos.

  14. theuni commented at 2:05 pm on June 6, 2024: member

    Hmm, how best to ignore the tidy false-positive in a leveldb header?

    FWIW, in the CMake staging branch, all subtrees are already excluded from being analyzed by clang-tidy.

    I believe (based on our .bear-tidy-config) that this is the case in current master as well. That’s not the issue here, though.

    What we’re running into is a leveldb header that’s included by dbwrapper.cpp, so excluding the leveldb build itself doesn’t help.

  15. theuni referenced this in commit 9f4f359fdc on Jun 6, 2024
  16. theuni referenced this in commit 15796d4b61 on Jun 6, 2024
  17. theuni commented at 5:23 pm on June 7, 2024: member
    Added a commit to work around in leveldb. @fanquake Would you be ok with carrying this in our subtree? I’m not sure of a better solution.
  18. fanquake referenced this in commit 7fd4905c40 on Jun 10, 2024
  19. fanquake commented at 8:37 am on June 10, 2024: member

    @fanquake Would you be ok with carrying this in our subtree? I’m not sure of a better solution.

    Yea I think that’s fine.

  20. fanquake referenced this in commit 080a47cb8a on Jun 13, 2024
  21. fanquake referenced this in commit 688561cba8 on Jun 13, 2024
  22. theuni force-pushed on Jun 14, 2024
  23. fanquake referenced this in commit 0b94fb8720 on Jun 14, 2024
  24. refactor: add self-assign checks to classes which violate the clang-tidy check
    Both of these cases appear to be harmless, but adding the tests allows us to
    turn on the aggressive clang-tidy checks.
    32b1d13792
  25. ci: enable self-assignment clang-tidy check 26a7f70b5d
  26. theuni force-pushed on Jun 14, 2024
  27. DrahtBot removed the label CI failed on Jun 14, 2024
  28. hebasto approved
  29. hebasto commented at 8:32 am on June 16, 2024: member
    ACK 26a7f70b5d2b1cbfbf03e0b57b9b5ea92dafbb19, I have reviewed the code and it looks OK.
  30. TheCharlatan approved
  31. TheCharlatan commented at 9:31 pm on June 22, 2024: contributor
    ACK 26a7f70b5d2b1cbfbf03e0b57b9b5ea92dafbb19
  32. fanquake merged this on Jul 11, 2024
  33. fanquake closed this on Jul 11, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-09-28 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me