-
Notifications
You must be signed in to change notification settings - Fork 444
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
Add IR utility that helps with return of multiple statements from Transform #4414
Conversation
dcb23a5
to
de68fee
Compare
0844bbb
to
c49a6df
Compare
c49a6df
to
c747f6f
Compare
The way I've dealt with this in other passes is to just return a BlockStatement then use SimplifyControlFlow, but this is more efficient. |
return new IR::IndexedVector<IR::StatOrDecl>(std::forward<Stmts>(stmts)); | ||
} | ||
Util::SourceInfo srcInfo; | ||
if (stmts.size() > 0) { // no .empty in initializer_list! |
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.
std::empty
? I guess that won't work for the other two...
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.
It should work for anything that has .empty or c-style array and on initializer_list. But I could not decide if it is nicer or uglier than size() > 0.
d1bcc8d
to
cf5c8f3
Compare
Example of use is in the test: https://github.com/p4lang/p4c/pull/4414/files#diff-c05e1bbc752f9a1299cec11e3e39374bcd48de0eb2939bdca8b4fca6c0aa65d8R51.