[cfe-dev] clang-format and BSD KNF

David Watson dwatson at arbor.net
Wed Jun 11 11:09:20 PDT 2014


On Jun 11, 2014, at 2:27 AM, Daniel Jasper <djasper at google.com> wrote:

>  doubt that it is possible to distinguish between these cases.  clang-format works on a stream of tokens, not the AST.  I do not believe that there is any reliable way to distinguish between function prototypes and definitions without at least a partial AST.
> 
> Why not? One ends in a semicolon, the other in an open curly brace. clang-format has to make basically all of its decisions this way..

>From my testing, the StartsDefinition flag is already distinguishing between definitions and declarations.  I just can’t figure out how to reliably examine the value of that flag from the beginning of the function definition (within the mustBreakBefore method).  Once the brace ends up in a separate line, there doesn’t seem to be any links to the next line, or to any meta level structure tying the entire function definition together (like an AST).

David





More information about the cfe-dev mailing list