-
Notifications
You must be signed in to change notification settings - Fork 14k
[Draft] Summary Based Analysis Prototype #144224
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
base: main
Are you sure you want to change the base?
Conversation
… the summaries from
…ry consumer logic
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
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 did not have time to look at it properly, just some small drive by comments.
return *SummaryCtx; | ||
} | ||
|
||
void createSummaryContext() { SummaryCtx.reset(new SummaryContext()); } |
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.
Should we assert here that we don't have a summary context yet?
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'm not sure tbh. I just mirrored what other create functions such as CompilerInstance::createSema()
do. Those don't assert the existence, so maybe the consumers of the class expect this kind of behaviour.
|
||
namespace clang { | ||
class FunctionSummary { | ||
SmallVector<char> ID; |
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.
Why SmallVector instead of a string type?
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 just an artifact from index::generateUSRForDecl()
expecting a SmallVectorImpl<char> &
as it's buffer. In the very beginning, the constructor of this class took a FunctionDecl
and generated the USR into this field.
This and every other data structure used needs to be revisited throught these source files once again before the patch is finalized.
FunctionSummary(SmallVector<char> ID, std::set<const SummaryAttr *> Attrs, | ||
std::set<SmallVector<char>> Calls); | ||
|
||
SmallVector<char> getID() const { return ID; } |
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.
Did you want to return a StringRef/ArrayRef instead?
}); | ||
}); | ||
} | ||
} // namespace clang |
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.
Nit: missing new line.
This is the initial implementation of how I imagine summaries used in clang and the CSA. There are still rooms for improvement and the patch still serves as an RFC to discuss which direction to go further.
1.) Compile each TU to generate the summaries
2.) Give the path to the directory containing the summaries to a clang tool to use them
The summaries for
main.cpp
andfoo.cpp
look like this: