<div dir="ltr">Works fine here (both in a slightly older version and synced to HEAD):<div><br></div><div><div>$ cat format.cpp </div><div>void f(   ) {  </div><div>  </div><div>       // Get the solitary sucessor.</div><div>
  const CFGBlock *Succ = *(Entry->succ_begin());</div><div>}</div></div><div><br></div><div><div>$ cat format.cpp | bin/clang-format -lines 3:3</div><div>void f(   ) {</div><div><br></div><div>  // Get the solitary sucessor.</div>
<div>  const CFGBlock *Succ = *(Entry->succ_begin());</div><div>}</div></div><div><br></div><div>Trailing whitespace is removed but line is otherwise left alone.</div><div><br></div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Thu, Dec 5, 2013 at 11:12 AM, Alp Toker <span dir="ltr"><<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On 05/12/2013 10:05, Daniel Jasper wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is intended behavior. All leading whitespace is assumed to belong to a line. If the line is formatted, the leading whitespace is fixed. Not that it does not format "void f() {" (you can insert arbitrary spaces in there).<br>

</blockquote>
<br></div>
Well, that's the thing which isn't working.<br>
<br>
It is formatting arbitrary spaces in "void f(      )   { " on line 1 even if all the other lines are correct and the requested range is line 3.<br>
<br>
Alp.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
<br>
On Thu, Dec 5, 2013 at 11:02 AM, Alp Toker <<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a> <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>>> wrote:<br>
<br>
<br>
    On 02/12/2013 09:24, Daniel Jasper wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    Fixed in r196080.<br>
</blockquote>
<br>
    Thanks!<br>
<br>
    This avoids unrelated whitespace edits following the change but<br>
    there's still a problem with preceding unrelated lines getting<br>
    modified. Not sure if this is a regression or pre-existing problem.<br>
<br>
    With the attached format.cpp input, requesting formatting of line<br>
    range 3 causes lines 1 and 2 to get edited:<br>
<br>
    |clang-format -lines=3:3 format.cpp | diff -U format.cpp -||<br>
    ||Can't find usable .clang-format, using LLVM style||<br>
    ||--- format.cpp    2013-12-05 09:51:34.000000000 +0000||<br>
    ||+++ -    2013-12-05 09:52:43.000000000 +0000||<br>
    ||@@ -1,5 +1,5 @@||<br>
    ||-void f() { ||<br>
    ||- ||<br>
    ||+void f() {||<br>
    ||+||<br>
    ||   // Get the solitary sucessor.||<br>
    ||   const CFGBlock *Succ = *(Entry->succ_begin());||<br>
    || }|<br>
<br>
    AFAICT the problem only exists with comment lines. Requesting line<br>
    4 doesn't trigger it. Noticed while preparing the comment typo fix<br>
    patches.<br>
<br>
    Alp.<br>
<br>
<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
<br>
    On Mon, Dec 2, 2013 at 9:52 AM, Alp Toker <<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a><br></div></div><div><div class="h5">
    <mailto:<a href="mailto:alp@nuanti.com" target="_blank">alp@nuanti.com</a>>> wrote:<br>
<br>
<br>
        On 02/12/2013 08:24, Daniel Jasper wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        I just tried reproducing this and it still works fine here<br>
        (both in vim and in emacs). Are you sure that clang-format<br>
        removes that trailing whitespace?<br>
</blockquote>
<br>
        Hi Daniel,<br>
<br>
        I think Rafael is onto something.<br>
<br>
        If you take a look at r196038 in clang-tools-extra, there's<br>
        an unrelated whitespace fix that slipped into the commit<br>
        yesterday:<br>
<br>
<br>
        |@@ -262,7 +262,7 @@ StatementMatcher<br>
        makePseudoArrayLoopMatcher() {||<br>
        ||   // Test that the incoming type has a record declaration<br>
        that has methods||<br>
        ||   // called 'begin' and 'end'. If the incoming type is<br>
        const, then make sure||<br>
        ||   // these methods are also marked const.||<br>
        ||-  // ||<br>
        ||+  //||<br>
        ||   // FIXME: To be completely thorough this matcher should<br>
        also ensure the||<br>
        ||   // return type of begin/end is an iterator that<br>
        dereferences to the same as||<br>
        ||   // what operator[] or at() returns. Such a test isn't<br>
        likely to fail except|<br>
<br>
        The line that was legitimately changed is a fair bit above so<br>
        I wouldn't have expected to see this edit to an untouched line.<br>
<br>
        I can try re-creating the patch as it was before running<br>
        clang-format if it'd be any help.<br>
<br>
        diff -U0 | clang-format-diff.py -p1 -i<br>
<br>
        Alp.<br>
<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
<br>
        On Sun, Dec 1, 2013 at 7:01 PM, Rafael Espíndola<br>
        <<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a><br></div></div><div class="im">
        <mailto:<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@<u></u>gmail.com</a>>> wrote:<br>
<br>
            This seems to have caused a regression with at least the<br>
            emacs<br>
            integration. Running clang-format-region now seems to<br>
            remove trailing<br>
            white space from unrelated areas. For example, run it<br>
            with the cursor<br>
            in Sema.cpp:1112:<br>
<br>
              if (!LangOpts.<u></u>RetainCommentsFromSystemHeader<u></u>s &&<br>
<br>
            and the trailing white space in Sema.cpp:1100:<br>
<br>
            // We have a generic lambda if we parsed auto<br>
            parameters, or we have<br>
<br>
            is removed.<br>
<br>
            Cheers,<br>
            Rafael<br>
<br>
<br>
<br>
<br>
        ______________________________<u></u>_________________<br>
        cfe-commits mailing list<br></div>
        <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a>  <mailto:<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.<u></u>edu</a>><br>
        <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-commits</a><br>
</blockquote><div class="im">
<br>
        --         <a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
        the browser experts<br>
<br>
<br>
</div></blockquote><div class="im">
<br>
    --     <a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
    the browser experts<br>
<br>
<br>
</div></blockquote><div class="HOEnZb"><div class="h5">
<br>
-- <br>
<a href="http://www.nuanti.com" target="_blank">http://www.nuanti.com</a><br>
the browser experts<br>
<br>
</div></div></blockquote></div><br></div>