[PATCH] D32298: [clang-format] Replace IncompleteFormat by a struct with Line

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 21 07:30:31 PDT 2017


krasimir added inline comments.


================
Comment at: include/clang/Format/Format.h:1524
+  /// best-effort analysis, and could be imprecise.
+  unsigned Line = 0;
+};
----------------
krasimir wrote:
> djasper wrote:
> > Hm. Something we might need to be thinking about here is whether this should be the line before or after formatting. So specifically, if I format:
> > 
> >   int a
> >       = 1;
> >   f(
> > 
> > Then, this gets reformatted to:
> > 
> >   int a = 1;
> >   f(
> > 
> > Would we want the Line to be 2 or 3?
> I'd go with the original line, because I think it might be more useful and because it's easier to implement.
Even better: the line after formatting is functionally dependent on the line before formatting and the replacements. I see two use-cases: clients that refuse to format in case of syntax error, then they can just use the original line, and clients that apply the partial replacements, which can compute the line after formatting from them and the original line.


https://reviews.llvm.org/D32298





More information about the cfe-commits mailing list