[PATCH] D30375: Function with unparsed body is a definition

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 8 22:21:16 PDT 2017


sepavloff added a comment.

Thank you for explanation. Probably making new semantic action is an overkill.

The intent was to postpone setting flag `WillHaveBody` as late as possible, to the moment when it becomes clear that the function indeed will have a body. Otherwise parsing of deleted functions is broken. Also in the case of invalid input the resulting function declaration become definition while previously they were not, it also changes existing behavior. The new semantic action set the flag enough late after the call to `ActOnStartOfFunctionBody`, when this treatment is already made.

The new solution uses different path. As previously, `ActOnStartOfFunctionBody` sets `WillHaveBody` but this flag is reset when it becomes clear that body will be available. Such technique is already uses for defaulted functions, so only deleted require the flag reset. `WillHaveBody` is also reset when parsing of function is finished. This transient flag is not needed after the function parsing is done. If `ActOnFinishFunctionBody` is always  called after `ActOnStartOfFunctionBody`, erroneous functions are not leaked as definition.


https://reviews.llvm.org/D30375





More information about the cfe-commits mailing list