Skip to content

Conversation

@ChrisThrasher
Copy link
Member

Description

This PR does two things. Primarily it adds [[nodiscard]] to many APIs (both public and private) where it would be unambiguously incorrect to ignore the return value. This makes it more difficult to write programs that misuse the API. GCC and Clang will warn about this by default so it's safe to assume once we add this all SFML 3 users will start potentially receiving these warnings. Whether or not those warnings are converted into errors is a matter of user preference. There are likely more APIs where [[nodiscard]] would be appropriate so we may add it in more places after this PR once a precedent has been established.

The second thing this PR does is use clang-tidy's modernize-use-nodiscard check to automatically flag APIs that ought to be marked with [[nodiscard]] but are not. This only applies to class member functions so this check will not touch free functions. We will have to manually audit the codebase to find free functions that need the [[nodiscard]] attribute. This is doable albeit rather labor intensive.

@ChrisThrasher ChrisThrasher added this to the 3.0 milestone Jun 27, 2024
@coveralls
Copy link
Collaborator

coveralls commented Jun 27, 2024

Pull Request Test Coverage Report for Build 9700969818

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.008%) to 56.196%

Totals Coverage Status
Change from base Build 9691648415: -0.008%
Covered Lines: 11671
Relevant Lines: 19692

💛 - Coveralls
@ChrisThrasher ChrisThrasher merged commit e1469aa into SFML:master Jun 27, 2024
@ChrisThrasher ChrisThrasher deleted the modernize-use-nodiscard branch June 27, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants