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

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 6 13:15:57 PDT 2017


rsmith added a comment.

If you want to take this path, you should also add `ActOnStartOfFunctionBody` calls to the other parts of the parser that parse function definitions: `Parser::ParseLateTemplatedFuncDef`, `Parser::ParseLexedObjCMethodDefs`, and `Parser::ParseLexedMethodDefs`. You should also rename `ActOnFinishFunctionBody` to something like `ActOnFinishFunctionDef` to avoid confusion, because it pairs with `ActOnStartOfFunctionDef` not the new `ActOnStartFunctionBody`.

However, I wonder if there isn't a simpler way to handle this, rather than adding another function that is called almost every time that `ActOnStartOfFunctionDef` is called: the `Declarator` object passed to `ActOnStartOfFunctionDef` already carries a `FunctionDefinitionKind` which tells you whether the function definition has a body. You could extend the non-`Declarator` overload to also take a `FunctionDefinitionKind` and then update the callers to pass in the right value. Then in `ActOnStartOfFunctionDef`, only set `WillHaveBody` if the kind is `FDK_Definition`.


https://reviews.llvm.org/D30375





More information about the cfe-commits mailing list