Fix function rewriting with r-paren between prototype and definition#394
Conversation
A right parentheses appearing between a function prototype and the beginning of its definition caused anything falling between the parenthesis and the actual end of the prototype to be deleted. This problem is fixed by using clang provided source locations instead of locating the closing parenthesis by iterating of the source code characters.
| // Note: getFunctionDeclarationEnd is used instead of getRParenLoc so that | ||
| // itypes are deleted correctly when --remove-itypes is used. |
There was a problem hiding this comment.
Is --remove-itypes still available? I assume we don't want it anymore, and the new code here doesn't use it, so if it lingers we could remove it here or in a later pull request.
There was a problem hiding this comment.
Remove itypes still works on the 5c build, although we'll probably want to update it to include removing unnecessary casts. This comment is removed because the conditional below it handles overwriting the bounds and interop type expression correctly in the first two branches without needing to fall through to getFunctionDeclarationEnd
| if (!End.isValid()) | ||
| End = getFunctionDeclarationEnd(Decl, SM); |
There was a problem hiding this comment.
Is getFunctionDeclarationEnd used elsewhere? It's unfortunate that this condition needs to be here, since it was the offending code, but if it's a hack I think it's better inline rather than exposed to be reused.
|
looks good to me |
|
I this one ready to go? Seems that Kyle approved it. |
Fixes #392. A right parentheses appearing between a function prototype and the
beginning of its definition caused anything falling between the
parenthesis and the actual end of the prototype to be deleted. This
problem is fixed by using clang provided source locations instead of
locating the closing parenthesis by iterating of the source code
characters.