Page MenuHomePhabricator

[libc] Fix WrapperGen seeing no arguments as a void argument.
ClosedPublic

Authored by michaelrj on Nov 4 2020, 3:01 PM.

Details

Summary

This corrects WrapperGen generating incorrect wrappers for functions
that take no arguments. Previously it would generate a wrapper with a
single argument of type void.

Diff Detail

Event Timeline

michaelrj created this revision.Nov 4 2020, 3:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2020, 3:01 PM
michaelrj requested review of this revision.Nov 4 2020, 3:01 PM
sivachandra accepted this revision.Nov 5 2020, 9:00 AM
sivachandra added inline comments.
libc/utils/tools/WrapperGen/Main.cpp
51

May be check that the ArgsList.size() is zero? If zero, break out of the for loop, else report a descriptive error?

This revision is now accepted and ready to land.Nov 5 2020, 9:00 AM
michaelrj updated this revision to Diff 303158.Nov 5 2020, 10:10 AM
michaelrj marked an inline comment as done.

change continue to break

submit comments

libc/utils/tools/WrapperGen/Main.cpp
51

ArgsList.size() is still 1 if there are no arguments, that's where the argument of type void is coming from. If ArgsList.size() was ever 0 it wouldn't even enter the for loop, as that's the check at the top. I did change the continue to a break though.

sivachandra added inline comments.Nov 5 2020, 10:15 AM
libc/utils/tools/WrapperGen/Main.cpp
51

Sorry! I intended to say, when you find a void arg type, check that ArgsList.size() == 1. If not, report a descriptive error.

michaelrj updated this revision to Diff 303164.Nov 5 2020, 10:31 AM

add check for a void argument as well as other arguments in the same function.

michaelrj marked an inline comment as done.Nov 5 2020, 10:32 AM

submit comments

sivachandra accepted this revision.Nov 5 2020, 10:38 AM
sivachandra added inline comments.
libc/utils/tools/WrapperGen/Main.cpp
60

Say something like,

"The specification for function " + FunctionName + " lists other arguments along with a void argument."

Pointing out that the specification is at fault tells the user where to go look.

michaelrj updated this revision to Diff 303190.Nov 5 2020, 10:53 AM

make error message more helpful

michaelrj marked an inline comment as done.Nov 5 2020, 10:53 AM

submit messages (I really gotta remember to mark these before I run the arc command)

This revision was landed with ongoing or failed builds.Nov 5 2020, 11:13 AM
This revision was automatically updated to reflect the committed changes.