<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Mikail, what you need to read is libformat:<br>
<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/</a></p>
<p>This code is responsible for formatting "unwrapped lines". It's
not a full C++ parser, but it deals with tokens that are annotated
with various bits of context-specific information. I think that
the closing paren thing is quite easy to implement - you just
force a line break on the token following the last function param.
Controlling that however, will be a bit involved as you are
essentially adding a user-visible option that is orthogonal to
every existing formatting style. Getting consensus on that will be
harder than making the source patch. Yet you can always maintain
your own private patches...<br>
</p>
<p>Also, make sure to browse through the tests:<br>
<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/</a></p>
<p>The main file is FormatTest.cpp - it contains most of the C++
formatting tests, AFAIR.</p>
<p>Good luck,<br>
Oleg.<br>
</p>
<div class="moz-cite-prefix">On 2018-12-30 04:34, Mikail Yayla
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAG12wuKs9Ju9j5gCG8VG8fdRkBoeLT7=Xm4ZsDh77bSmDhj_iA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Thank you for the replies. <br>
<div>I understand now that the principle of clang-format is to
support a limited number of styles well.</div>
<div><br>
</div>
<div>We still would like to give a try in implementing some
functionality, to get a sense of how much work would be needed
to adapt clang-format for RTEMS. <br>
</div>
<div><br>
</div>
<div>For RTEMS it would be good to have the option in C to put
the ")" at the end of a function declaration in a separate
line, e.g.:</div>
<div><br>
</div>
<div>bool _Thread_Initialize(<br>
Thread_Information *information,<br>
[...]<br>
Objects_Name name<br>
</div>
<div>
) // <- in a new line<br>
</div>
<div>
{ </div>
<div><br>
</div>
<div>So far I've checked out and complied llvm and clang, and
read some articles in the clang documentation. The
clang-format code is in
LLVM/build/tools/clang/tools/clang-format, and I can compile
it as well. I've been looking through the files and comments,
but I'm struggling to find the files or functions that would
need changes to implement the functionality. <br>
</div>
<div>Could you please give me some pointers on how to proceed,
what to consider, or some reading material ?</div>
<div><br>
</div>
<div>Best,</div>
<div>Mikail</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Mon, Dec 17, 2018 at 1:24 PM Roman Lebedev
<<a href="mailto:lebedev.ri@gmail.com"
moz-do-not-send="true">lebedev.ri@gmail.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On
Mon, Dec 17, 2018 at 3:11 PM Dominique Devienne via cfe-dev<br>
<<a href="mailto:cfe-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> On Sat, Dec 15, 2018 at 12:40 AM Oleg Smolsky via cfe-dev
<<a href="mailto:cfe-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a>> wrote:<br>
>><br>
>> > 2. In line 32, the ")" at the end of the
parameter list needs to be in<br>
>> > a new row, but this doesn't seem to be supported
in clang-format.<br>
>> ><br>
>> > 4. In line 44: If the function call is split
into multiple rows, the<br>
>> > ");" should always be in a new row.<br>
>> ><br>
>> I don't believe there is an option to do that.<br>
>><br>
>> Generally, the tool supports
LLVM/Google/WebKit/Mozilla styles fully and<br>
>> there is a limited set of common/known tweaks that
further customize the<br>
>> behavior. One can dream up any number of rules that
pertain to<br>
>> whitespace in different parts of the C++ syntax, but
it would be an<br>
>> uphill battle for you to get such changes into the
code.<br>
><br>
><br>
> Which is really disappointing from an OSS project...<br>
><br>
> That a new language like Go forces a given style is OK,<br>
> since their "one-true-format" existing from the beginning
of the language.<br>
><br>
> But that clang-format rejects even the idea of a widely
used style of closing<br>
> parens being on their own line, similar to how curlies
are for blocks, on code<br>
> bases which have used those styles for decades, just
because 3 large corporations<br>
> use different styles, is a clear sign something's not
right here.<br>
><br>
> Options to support such a style were discussed several
times on this list, and I haven't<br>
> been lurking for very long either, so it's not like this
is a one-off and seldom used style.<br>
><br>
> Adopting clang-format on a codebase should strive for
minimal changes to well-formatted<br>
> code using a given local style guide, minimising diffs at
the SCM level.<br>
><br>
> It's also frankly a bit condescending to imply all those
peoples (and their millions of lines of code,<br>
> quite literally) are using somehow a "wrong style" not
"worthy" of changing clang-format over.<br>
><br>
> Oleg's reply is friendly and polite, no question there,
but what it implies is offending IMHO.<br>
<br>
Have you seen <a
href="https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options</a><br>
?<br>
More options, while certainly allows for more customizability,
is<br>
always more code, tests,<br>
behavior to preserve and account for going forward.<br>
<br>
> FWIW... --DD<br>
<br>
Roman.<br>
<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
> <a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</blockquote>
</body>
</html>