[cfe-dev] clang-format breaks the code in short functions with C++ style comment

Eran Ifrah eran.ifrah at gmail.com
Sat Sep 6 10:46:09 PDT 2014


Hi,
I just encountered this use case with clang-format:

Consider the following function:

...
    void Reset() { // Like Clear() but retain m_initialCommand. Used when
an editor is reloaded
       m_commands.clear();
    }
​...​

​and in my clang-format plugin, I have the option:
​"Allow Short Functions on A Single Line" enabled.

So, after indenting I get this:

    void Reset() { // Like Clear() but retain m_initialCommand. Used when
an editor is reloaded m_commands.clear(); }

Which breaks compilation (and thanks to gcc poor error reporting it only
took me 30 mins to figure what went wrong :P )

Thanks,

-- 
Eran Ifrah,
Author of codelite, a cross platform open source C/C++ IDE:
http://www.codelite.org
CodeLite IDE Blog: http://codeliteide.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140906/a7b1d4ac/attachment.html>


More information about the cfe-dev mailing list