-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Expose SSA definitions from dataflow #20149
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
C++: Expose SSA definitions from dataflow #20149
Conversation
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.
Pull Request Overview
This PR exposes the SSA definitions from the internal dataflow library to make them publicly available for external use. The SSA API has been stable for over two years, making it safe to expose these classes to users who have been requesting this functionality.
- Adds a
getAUse()
method to theDefinition
class to retrieve nodes that use a definition - Introduces new SSA definition classes:
ExplicitDefinition
,DirectExplicitDefinition
, andIndirectExplicitDefinition
- Exposes the SSA classes through type aliases in
DataFlowUtil.qll
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
SsaInternals.qll | Adds new SSA definition classes and enhances the Definition class with use tracking |
DataFlowUtil.qll | Creates public type aliases to expose the internal SSA classes |
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
I don't think any other language exposes SSA in terms of data flow nodes. I can see the motivation, though, it's a much shorter path to impact than, say, getting a good SSA on the AST nodes. But it's important to highlight that this is not really pointing in the direction of language api unification (the glorious future). |
I'm happy to rename it to Using But I can see the value in trying to align with other languages on this. I'll experiment a bit and see if I can find a balance that I like 🤔 |
Bahh! We can't even name it |
Ultimately, I think a canonical SSA for C++ could be based on a new class that encapsulates the |
C# generally refers to them as |
Ah, right. I'll follow that direction, then.
Indeed, that makes a lot of sense! I'll keep the API minimal for now and leave open the option of providing an |
g> I don't think any other language exposes SSA in terms of data flow nodes. I can see the motivation, though, it's a much shorter path to impact than, say, getting a good SSA on the AST nodes. But it's important to highlight that this is not really pointing in the direction of language api unification (the glorious future). I don't like the name I've renamed the classes in 33d0598, and modified the API to not expose dataflow nodes (but rather I do agree that we ultimately would like a new abstraction around I did a drive-by cleanups in 7ede3aa and 32e6d09. Nothing exciting is happening there (it's just renaming a few files and changing the name of some private import aliases). |
…s and the internal ones. Let's only import the internal ones.
889925b
to
b70836e
Compare
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
This PR makes it possible to use the dataflow SSA library outside the internal dataflow directory.
This has been a request by people for many years, but I've pushed back on it since we didn't feel the API was stable enough to publicly expose it. However, the API basically hasn't changed since we switched to the "new" dataflow library more than two years ago. So I think it's pretty safe to say that it's stable enough at this point.
I don't think we need a DCA run for this since:
cc @bdrodes since you've been quite noisy about wanting this.
I did a small drive-by fix while here in commit 1: Schack left a TODO for us in #18942 which I've fixed. This makes the predicate identical to Java and C#.