Skip to content

C++: Changes to models library. #4515

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 5 commits into from
Oct 29, 2020
Merged

C++: Changes to models library. #4515

merged 5 commits into from
Oct 29, 2020

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Oct 19, 2020

This is a sort of prototype for changes I intend to make to the entire models library, the intent being to discuss these ideas on a small scale before I spend more time applying them more widely. Once it's merged I intend to make a second, larger PR applying what is agreed upon to all of models\implementations. The changes are:

  • make the QL classes in models\implementations representing library functions private; there may be cases where we think using them directly has legitimate value to users (possibly bits of Allocation.qll), in which case we should consider migrating sufficient code from implementations to interfaces. But in most cases these classes are implementation details, and we may want to change their details in future (for example combining or splitting models).
  • add a QL module for Std, instead of naming lots of classes StdPairConstructor, StdMapInsert etc. This was suggested by @tausbn. I'm not really sure what the pro's and con's will be for us so I'd like to discuss what we want to get out of it before pressing on with this.
  • avoid the pattern: getParameter(_) - because it's believed to be inefficient (I only found one remaining use anyway)
  • more use of [, ] syntax; I expect this is uncontroversial at this point.

I'm also open to further suggestions (porting taint models to the upcoming shared flow summary interface is out of scope, however).

@geoffw0 geoffw0 added the C++ label Oct 19, 2020
@geoffw0 geoffw0 requested a review from a team as a code owner October 19, 2020 18:05
@rdmarsh2
Copy link
Contributor

I'm not sure a private Std module in a file that only has models standard library classes makes a significant difference. It would be more interesting to look at how it affects the iterator models where there are both specific names in std:: and generic concepts like iterator accesses.

@jbj
Copy link
Contributor

jbj commented Oct 27, 2020

Overall I like the direction of these changes, but I have the same reservation as @rdmarsh2.

make the QL classes in models\implementations representing library functions private

Agreed: private by default, and then we can make individual classes public if the value outweighs the maintenance burden.

add a QL module for Std, instead of naming lots of classes StdPairConstructor, StdMapInsert etc. This was suggested by @tausbn.

I don't see the value in this, even if we'll later put public items into that module. A QL module is different from a C++ namespace in that the contents of a QL module has to be enumerated in one central location. That may fit how the Python libraries are organised, but I don't think it fits the C/C++ libraries.

I don't find that Std::PairConstructor breaks up the name in a helpful way. Maybe Std::Pair::Constructor would look good, but I don't see that it looks better than StdPairConstructor. At least not enough to outweigh the library organisation issues.

avoid the pattern: getParameter(_) - because it's believed to be inefficient (I only found one remaining use anyway)

👍

more use of [, ] syntax; I expect this is uncontroversial at this point.

👍

@geoffw0
Copy link
Contributor Author

geoffw0 commented Oct 27, 2020

I'm not sure a private Std module in a file that only has models standard library classes makes a significant difference

I've reverted the addition of the Std module. I'm open to suggestions but I've also yet to see how modules can really improve what we do here.

@jbj
Copy link
Contributor

jbj commented Oct 27, 2020

Sounds good to me. I'll merge this PR Thursday morning unless there are unresolved discussions.

@jbj jbj merged commit 0af62b8 into github:main Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants