This is an archive of the discontinued LLVM Phabricator instance.

Fix bug 20892 - clang-format does not handle C-style comments
ClosedPublic

Authored by lifted on Sep 11 2014, 3:05 AM.

Details

Summary

http://llvm.org/bugs/show_bug.cgi?id=20892

Add support of C-style formatting enabling/disabling directives. Now the following two styles are supported:

// clang-format on
/* clang-format on */

The flexibility in comments (support of extra spaces and/or slashes, etc.) is deliberately avoided to simplify search in large code bases.

Diff Detail

Event Timeline

lifted updated this revision to Diff 13580.Sep 11 2014, 3:05 AM
lifted retitled this revision from to Fix bug 20892 - clang-format does not handle C-style comments.
lifted updated this object.
lifted added a reviewer: djasper.
lifted added subscribers: klimek, Unknown Object (MLST).
djasper edited edge metadata.Sep 11 2014, 3:17 AM

Thanks for picking this up!

I am against supporting "///" and "/**" style comments as I don't see a good reason for using them for this purpose. I am even against trimming the whitespace. I want the comments to have a single spelling that I can easily search for in a bigger codebase.

I am against supporting "///" and "/**" style comments

That's reasonable. I will remove all that nontrivial logic and replace it with simple comparisons against // clang-format on and /* clang-format on */.

lifted updated this revision to Diff 13586.Sep 11 2014, 7:12 AM
lifted edited edge metadata.

Simplify formatting directives recognition logic

lifted updated this object.Sep 11 2014, 7:18 AM
djasper accepted this revision.Sep 11 2014, 7:19 AM
djasper edited edge metadata.

One comment, otherwise looks good.

lib/Format/Format.cpp
1736

I don't think it is worth pulling out these functions, but I don't feel strongly.

This revision is now accepted and ready to land.Sep 11 2014, 7:19 AM
lifted closed this revision.Sep 11 2014, 7:56 AM