Skip to content

C++: resolveElement #7

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
Aug 21, 2018
Merged

C++: resolveElement #7

merged 5 commits into from
Aug 21, 2018

Conversation

ian-semmle
Copy link
Contributor

This should make it easier to experiment with ideas such as linker awareness in QL.

calumgrant pushed a commit to calumgrant/ql that referenced this pull request Aug 3, 2018
JavaScript: Fix `ArgumentsRedefined` to do what its name says.

cached @element underlyingElement(Element e) {
result = e
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add QLDoc to these four predicates to explain how they are supposed to be used. New code might easily get these calls wrong, especially if we don't all understand how to use them. In particular, how do I choose between using unresolveElement and underlyingElement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if isClass(e)
then result = resolve(e)
else result = e
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this predicate is only for use in this file, shouldn't we make it private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


cached @element underlyingElement(Element e) {
result = e
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make all four predicates cached? Do they compute more than they seem to because of the casts between @element and Element? At least unresolveElement wouldn't have to be cached if it were defined in terms of mkElement, right?

I don't know how the optimizer turns these cached annotations into stages, but I'm guessing it will create a stage per predicate here. We can prevent that by grouping the predicates into a cached private module and importing that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some experiments, and found that performance drop is none are cached, but only resolveElement needs to be cached.

For example, if you have 3 types called T, where t1 and t2 are defined
but t3 isn't, then you will have

    unspecifiedtype(t1, t1)
    unspecifiedtype(t2, t2)
    unspecifiedtype(t3, t3)

    t1 = resolve(t1)
    t1 = resolve(t3)
    t2 = resolve(t2)
    t2 = resolve(t3)

so given

    Type getUnspecifiedType() {
        unspecifiedtype(unresolve(this), unresolve(result))
    }

you get t1.getUnspecifiedType() = t2.

I think that in general the best thing to do is to not unresolve 'this',
but to just take the underlying value.
Copy link
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from a typo. There's of course no need to advance the submodule when fixing the typo, so the PR in the internal repo can be merged as is.

* Get the `@element` that this `Element` extends. This should normally
* only be called from member predicates, where `e` is `this` and you
* need the result for an argument to a database extensional.
* See `unresolveElement` for when `e` is `this`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "not" in the last sentence.

Copy link
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this without the typo fix so we don't risk getting another submodule conflict.

@jbj jbj merged commit ea9bff0 into github:master Aug 21, 2018
@ian-semmle ian-semmle deleted the alg6un_squashed branch August 21, 2018 10:19
aibaars added a commit that referenced this pull request Oct 14, 2021
Refactor dbscheme generator to use intermediate representation
smowton pushed a commit to smowton/codeql that referenced this pull request Oct 28, 2021
hohn referenced this pull request in hohn/codeql Dec 13, 2021
lecture notes for oauth2 proxy workshop
erik-krogh referenced this pull request in erik-krogh/ql Dec 15, 2021
erik-krogh referenced this pull request in erik-krogh/ql Dec 15, 2021
tiferet added a commit that referenced this pull request Sep 19, 2022
New features: Shipping model. 9 new features, remove the old ones that have been replaced by new ones. The codeql PR has been rebased on top of main. #7 (with a fixed package version)

https://ml.azure.com/runs/classification_1663364335_afeafbe1?wsid=/subscriptions/91095667-e119-4555-acea-1826488492f0/resourcegroups/ATM-CodeML/workspaces/ATM-Workspace&tid=398a6654-997b-47e9-b12b-9515b896b4de
jhelie pushed a commit that referenced this pull request Nov 22, 2022
New features: Shipping model. 9 new features, remove the old ones that have been replaced by new ones. The codeql PR has been rebased on top of main. #7 (with a fixed package version)

https://ml.azure.com/runs/classification_1663364335_afeafbe1?wsid=/subscriptions/91095667-e119-4555-acea-1826488492f0/resourcegroups/ATM-CodeML/workspaces/ATM-Workspace&tid=398a6654-997b-47e9-b12b-9515b896b4de
dbartol pushed a commit that referenced this pull request Dec 18, 2024
Better handling of input and output expressions
dbartol pushed a commit that referenced this pull request Dec 18, 2024
Fix incorrect source for dorny path filters
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.

2 participants