Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Cameron via cfe-commits
cameron314 added a comment. Ooh, and I should also add, there's a non-trivial cost to grabbing the entire file contents as a string and then converting it to UTF-8. If ClangFormat was faster, this would certainly become a significant bottleneck that can't really be worked around. http://revie

Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Cameron via cfe-commits
cameron314 added a comment. We did profile at one point, to see if it was something we could trivially speed up (it wasn't). Most of it was on the parsing/annotation side, yes (which makes sense, since that's the majority of the work when the format region itself is limited). I'm afraid I don't

Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Daniel Jasper via cfe-commits
djasper added a comment. It has very basic newline detection, but if possible, I'd like to not significantly increase that. Specifically, I don't think it is worth the complexity of additional configuration options that users have to worry about, if it can just do the right thing (which IMO, it

Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Cameron via cfe-commits
cameron314 added a comment. Too late ;-) We've successfully integrated it as the engine behind our auto-formatting feature, passing only the minimal context necessary. We tried at first to supply the full file context, but that turned out to be much too slow in larger files. (We did a fair bit o

Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Daniel Jasper via cfe-commits
djasper added a comment. Passing snippets / single lines from an IDE does not make sense. Don't try to go down this road. clang-format always needs the full file as context. If you are already in an IDE, that IDE should control the line endings, not clang-format. Write a thin wrapper that chang

Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Cameron via cfe-commits
cameron314 added a comment. Sure :-) The motivation behind this patch (and a few more upcoming ones) is to make ClangFormat (the library) more friendly for IDE integration (which is our primary use case), in particular for on-the-fly auto-formatting. In an IDE auto-format setting, it's often t

Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Daniel Jasper via cfe-commits
djasper added a comment. Can you elaborate more on what case this is actually addressing? Are you saying that you have a one-line file without linebreaks that you want clang-format to format? http://reviews.llvm.org/D19031 ___ cfe-commits mailing

Re: [PATCH] D19031: clang-format: Flexible line endings

2016-04-12 Thread Cameron via cfe-commits
cameron314 added a comment. ClangFormat still needs to know what kind of newline to insert when reformatting code. It already had the "auto-detect newline" behaviour; this patch simply allows the auto-detection to be overridden with an explicit setting. This is important for short files that ha