Skip to content

Replace SCOPE flags with bitfields#16753

Merged
dkorpel merged 3 commits intodlang:masterfrom
dkorpel:scope-bitflags
Jul 30, 2024
Merged

Replace SCOPE flags with bitfields#16753
dkorpel merged 3 commits intodlang:masterfrom
dkorpel:scope-bitflags

Conversation

@dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Jul 25, 2024

In light of the recent #16752, get rid of error-prone bitmasking logic.

While we're at it, I renamed some of the fields because without flags they can be misleading: sc.free sounds like it calls free(sc), so rename it to sc.canFree.

There's 2 flags which aren't booleans, but instead form an ad-hoc enumeration of contracts, so I converted that to an enum Contract and added enum support to dmd.common.bitfields. I can split that improvement off in its own PR to make this one easier to review.

I kept the layout the same as with the SCOPE flag to be sure, but those _padding fields can be removed in a next PR.

@dkorpel dkorpel added the Severity:Refactoring No semantic changes to code label Jul 25, 2024
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#16753"

@dkorpel dkorpel marked this pull request as ready for review July 25, 2024 16:12
@dkorpel dkorpel requested a review from ibuclaw as a code owner July 25, 2024 16:12
@dkorpel
Copy link
Contributor Author

dkorpel commented Jul 30, 2024

Ping @RazvanN7

@dkorpel dkorpel merged commit 5c90c55 into dlang:master Jul 30, 2024
@dkorpel dkorpel deleted the scope-bitflags branch July 30, 2024 16:47
thewilsonator pushed a commit to thewilsonator/dmd that referenced this pull request Oct 7, 2024
* Replace SCOPE flags with bitfields

* Use getProtection instead of getVisibility

* Fix bitfields with bootstrap compiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Severity:Refactoring No semantic changes to code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants