Skip to content

extracted ValueFlow::Value to vfvalue.{cpp|h} #4642

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

Merged
merged 4 commits into from
Jan 26, 2023
Merged

Conversation

firewave
Copy link
Collaborator

No description provided.

@firewave
Copy link
Collaborator Author

Those helper structs in valueflow.h only had single users so I moved them to the appropriate scopes.

If we need those in more places we should probably add those to utils.h since it is generic code. I checked for potential duplicates but there were none.

@firewave firewave marked this pull request as ready for review December 13, 2022 23:17
@firewave
Copy link
Collaborator Author

@pfultz2 I am also looking at splitting the ValueFlow analysis i.e. ValueFlow::setValues() from the other code in valueflow.cpp.

It seems like most of the code related to the various steps is not shared at all. So I am wondering if it would be feasible to put these steps into separate modular files like vfnumber.h, 'vfstring.h' etc (or vfanumber). Shared code which is not yet exposed I would leave in the monolithic file for now but put in an internal namespace.

That approach would allow us to make this refactoring incremental and we don't need one big commit. That would also help with preventing/easing with potential conflicts in local branches and existing PRs.

@danmar I would also prefer to add an underscore to the file names though but we have not been doing that so far.

There's also some minor quibbles this exposed which I would clean up anyways.

@pfultz2
Copy link
Contributor

pfultz2 commented Dec 14, 2022

I think it would be better to put valueflow under a subdirectory. And then include it with #include "valueflow/value.h", and the cpp file would be under lib/valueflow/valuecpp. That would match the namespacing for this class.

It seems like most of the code related to the various steps is not shared at all. So I am wondering if it would be feasible to put these steps into separate modular files like vfnumber.h, 'vfstring.h' etc (or vfanumber).

The same here, each pass would be under lib/valueflow/ directory. The issue I see with this is some passes need to construct the analyzer directly, so we should probably add a new valueFlowForward function.

That is my personal opinion. I dont know what @danmar thinks about it.

@pfultz2
Copy link
Contributor

pfultz2 commented Dec 14, 2022

I am also looking at splitting the ValueFlow analysis i.e. ValueFlow::setValues() from the other code in valueflow.cpp.

Yea I would like to move the ConditionHandler to a separate file as well.

@firewave
Copy link
Collaborator Author

I think it would be better to put valueflow under a subdirectory. And then include it with #include "valueflow/value.h", and the cpp file would be under lib/valueflow/valuecpp. That would match the namespacing for this class.

I thought about that as well.

Yea I would like to move the ConditionHandler to a separate file as well.

That would fall under "shared code" i.e. internal stuff. That could probably go into several separate files as suggested.

I think we should decide what folder structure/naming is acceptable and then I will start prototyping with some low-hanging stuff.

@danmar
Copy link
Owner

danmar commented Dec 18, 2022

I think it would be better to put valueflow under a subdirectory. And then include it with #include "valueflow/value.h", and the cpp file would be under lib/valueflow/valuecpp. That would match the namespacing for this class.

It's acceptable to me. I don't have a strong opinion. One opinion I do have is to keep a source file and its header in the same folder.

@firewave
Copy link
Collaborator Author

It's acceptable to me. I don't have a strong opinion. One opinion I do have is to keep a source file and its header in the same folder.

Great!

This can be merged anyways and I will prepare a PR with the first refactoring soon.

@firewave firewave marked this pull request as draft December 30, 2022 15:32
@firewave
Copy link
Collaborator Author

Will be made ready to merge after #4652 goes in.

@firewave firewave marked this pull request as ready for review January 21, 2023 14:20
@danmar danmar merged commit bea6aec into danmar:main Jan 26, 2023
@firewave firewave deleted the vfvalue branch January 26, 2023 21:27
firewave added a commit that referenced this pull request May 26, 2024
`valueflow.cpp` is very monolithic which makes it hard to manage. This
is splitting several parts into separate files as discussed in #4642.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants