-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Call graph as contract annotation #10990
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
f8dd04b
to
781f007
Compare
/// A graph with edges representing calls between functions that may happen during contract construction. | ||
SetOnce<std::shared_ptr<CallGraph const>> creationCallGraph; | ||
/// A graph with edges representing calls between functions that may happen in a deployed contract. | ||
SetOnce<std::shared_ptr<CallGraph const>> deployedCallGraph; |
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'd prefer to use CallGraph
as a value here but I had to use a pointer instead due to dependencies. CallGraph.h
needs AST.h
so including it here would create a dependency cycle. I had to use something that only requires a forward declaration.
And the reason that CallGraph.h
can't just use ASTForward.h
is that it uses ASTNode::CompareByID
in member declarations.
Also, I wanted to at last have unique_ptr
here but that does not work with an incomplete type so I had to use shared_ptr
instead.
/// @returns the parsed contract with the supplied name. Throws an exception if the contract | ||
/// does not exist. | ||
ContractDefinition const& contractDefinition(std::string const& _contractName) const; | ||
|
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.
Is there any particular reason this was private? I made it public so that I can access the contract and its annotations without having to create special methods for that.
* Stores also extra information about contracts that can be created and events that can be emitted | ||
* from any of the functions in it. | ||
*/ | ||
struct CallGraph |
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.
We already have another class called CallGraph
(in Yul optimizer). I'd prefer the name to be unique but any ideas that I have would make this pretty long (and it's used a lot as a prefix for Node
and SpecialNode
).
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.
Looks good!
The graph PR has been accepted so I'm marking this as ready for review. |
Depends on #10973.
This is a refactor on top of #10973 that moves the call graph from
CompilerStack
to an annotation on contract definition. This makes it more convenient to access it.The PR is already complete and ready for review but waiting for #10973 to get merged.