Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor AbstractDetector to use the visitor pattern #1751

Open
0xalpharush opened this issue Mar 13, 2023 · 0 comments
Open

refactor AbstractDetector to use the visitor pattern #1751

0xalpharush opened this issue Mar 13, 2023 · 0 comments

Comments

@0xalpharush
Copy link
Contributor

Describe the desired feature

Right now, each detector implements its own ad-hoc approach to iterating over a compilation unit. This leaves the analysis author to understand and decide between contracts vs contracts_derived and functions vs functions_top_level vs functions_and_modifiers (even more if we consider inherited vs declared). While for some detectors there is a need for specialization, the vast majority of analyses could reuse a visitor from the AbstractDetector like visit_all_contracts_derived_functions. There are several benefits to this approach:

  1. These visitors require less understanding of the core API and can be clearly documented with guidance on when they should be used.
  2. It will make it easier to survey which detectors and analyze what and update changes to detectors en masse e.g. some detectors likely need to be update to support top level functions.
  3. I believe this would greatly impact performance positively. Rather than N detectors iterating over every comp. unit, contract, function, AbstractDetector would iterator over these and invoke each detector's visitor, reducing complexity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant