-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ValueFlow: start splitting it into multiple files #4748
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
Conversation
|
@pfultz2 Please have a look. I will also get rid of the |
|
I am reworking this a bit and will fix the matchcompiler and CMake. |
|
Still needs matchcompiler support. Also need to make sure it doesn't impact the performance negatively now the code is no longer completely visible to some of the callers. |
lib/vf/number.cpp
Outdated
|
|
||
| #include "common.h" | ||
|
|
||
| void ValueFlow::number(TokenList *tokenlist) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think we should shorten the names like that as this could conflict with other functions in the future. I understand why we wouldn't want ValueFlow::valueFlowNumber, but we should have a clear naming scheme so they wont conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other transformations have a naming scheme like simplifySomething. I am thinking something like analyzeNumber or assignNumber?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good. Will adjust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/vf/enumvalue.cpp
Outdated
| #include "token.h" | ||
| #include "valueflow.h" | ||
|
|
||
| void ValueFlow::enumValue(SymbolDatabase * symboldatabase, const Settings * settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be inside namespace ValueFlow{ ... }. This will simplify calling the other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had using namespace ValueFlow; in the source files which is better since it doesn't increase the indentation. But I went back on it. I guess I add it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/vf/number.h
Outdated
|
|
||
| namespace ValueFlow | ||
| { | ||
| void number(TokenList *tokenlist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used be valueflow.cpp. I think it would be better to put all the declarations in valueflow.cpp or in a single header that valueflow.cpp includes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in the vf folder is only used by valueflow.cpp. But having a convenience header with all of them in it would be fine I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/vf/common.h
Outdated
|
|
||
| std::string debugString(const ValueFlow::Value& v); | ||
|
|
||
| void setSourceLocation(ValueFlow::Value& v, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think setSourceLocation or debugString need to be put in the header as its only used by setTokenValue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They will be used in more than one of the split off source file. Otherwise I could have directly moved those in. There's probably room for more cleanups/refactoring after it is all done.
| SourceLocation loc = SourceLocation::current()); | ||
| } | ||
|
|
||
| #endif // vfCommonH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to name the header settokenvalue.h. Using a common header can bring in a lot of unnecessary dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to split up common later on. It helps with the incremental approach of the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only split internals of valueflow.cpp into separate files which are only included by valueflow.cpp there will be no additional dependencies compared to before. It is correct though that they might be unneeded in scope of the newly created smaller parts though. That should not cause any issues though and can be cleaned up afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done in this PR since it involves a lot of code.
Wrapping in |
I don't like that the indentation is being increased by that. I think it's nicer to simply add a single line and having them all aligned to the first line. |
|
This currently doesn't play well with the matchcompiler. I have it working in CMake but the regular make is still an issue. It also seems there's some code in it which we don't need anymore. |
3b494c2 to
4f10788
Compare
We should update the formatting to not indent for namespace scopes. |
|
I will give this another stab after #6298 has been merged. |
|
Since it complicates things and does not match the structure the project has been using all along I will omit introducing a subfolder and introduce an underscore in the filenames instead (although that also doesn't match what has been done so far). |
b336045 to
5bba4f5
Compare
|
Re-did the first commit, will re-add the others later. Having this in individual files might also allow us to write unit (and maybe performance tests) for the respective analyze steps. |
|
We could already merge this as a start or I could move yet another step. IMO this change is way too big to do it in a single commit. After all the steps have been moved out I will do the further suggested split of the common code. |
#4748 exposed a different order of files using the Windows code. This was caused by it only sorting the files in case of recursive parsing. But we need to sort all the files and not just the directory contents as the directory order might also be different dependent on the filesystem. This also allows the code to be a bit closer between the implementations.
f7748a0 to
88bff95
Compare
|
Any feedback on this? I would like to proceed on this so it is done within this dev cycle. Also so we could maybe do some work on #6097. |
…oduced `vf_analyze.h` to group all analyze headers
danmar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
valueflow.cppis very monolithic which makes it hard to manage. This is splitting several parts into separate files as discussed in #4642.