<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 25, 2013 at 4:00 PM, Christopher Olsen <span dir="ltr"><<a href="mailto:chrisaolsen@gmail.com" target="_blank">chrisaolsen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>I am evaluating clang-format and need control over spacing in template argument lists to conform to our coding standards.<br>
</div><div><br></div><div>I've attached a patch that adds new flags to control this spacing.  Unittests are also included.</div>
<div><br></div><div>- SpacesInAngles - A<int> vs A< int ></div><div>- SpaceInEmptyAngles - template <> vs template < ></div><div>- SpaceAfterTemplateKeyword - template<typename T> vs template <typename T></div>

<div><br></div><div>Note that LanguageStandard=Cpp03 overrides SpacesInAngles=false in the case of '>>' as in A<A<int> ></div><div><br></div><div>Please let me know if there is anything I need to fix for submission.</div>
</div></blockquote><div><br></div><div>I foresee (and have already run into multiple real use cases) where the spacing before, after, in between, etc. of many different kinds of tokens needs to be tweaked. For example:</div>
<div><br></div><div>* multiplicative operators don't have spaces, but additive operators do `a + b*c`</div><div>* spaces before parenthesized lists in function calls `foo (bar)`</div><div>* spaces inside the parentheses of an `if`: `if ( cond ) {`</div>
<div>* "function-like" return: `return(3)`</div><div><br></div><div>I think we should try (though it may not be realistic) to integrate this functionality in a way that covers the different use cases and makes them interact in a consistent and understandable way; otherwise we will just end up growing a forest of not-easy-to-discover options that don't have very good coverage of the configuration space for the next project. For example, adapting clang-format to the OP's project coding standards requires adding 3 new options; is there a realistic upper bound on the number of such options that we will need in order for clang-format to support, say, 1000 different projects from 50 different companies/open-source communities?</div>
<div><br></div><div>One possibility that I can imagine (although I don't know how feasible it is) is to ship another tool (or more likely keep it under an option to clang-format) which does a "one time" analysis to determine a set of parameters that will conform with a given sample source file (or files) and emits a configuration file. This analysis could work with a larger (but very consistent and well-defined) "plumbing" configuration space that essentially parameterizes the "guts" of clang-format (such as `spaceRequiredBefore`, `spaceRequiredBetween`, `splitPenalty`, etc.) in a data-driven way.</div>
<div><br></div><div>On the other hand, I think it has been put out there before is that one of the benefits of clang-format is to help "standardize" to some extent on a common subset of style options, and so providing too-fine-grained support for "tweaking" the output might be undesirable from such a perspective. On the other hand, if clang-format wants to "dominate the world", it can't impose arbitrary changes on a project's coding style. A poignant question is "is it a goal for clang-format be able to conform with more-or-less-arbitrary styles without requiring requiring the users to get involved with clang-format development?", but I can't speak as to the answer.</div>
<div><br></div><div>Daniel, what do you think? </div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">
<div><br></div><div>Thanks!</div><div>Chris</div><div><br></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>