If the clang-format on/off is in a /* comment */ then the sorting of headers is not ignored
Details
- Reviewers
djasper klimek JonasToth alexfh - Commits
- rG9b468c0b1e3f: [clang-format] clang-format off/on not respected when using C Style comments
rC355266: [clang-format] clang-format off/on not respected when using C Style comments
rL355266: [clang-format] clang-format off/on not respected when using C Style comments
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang/unittests/Format/SortIncludesTest.cpp | ||
---|---|---|
132 ↗ | (On Diff #188880) | Add a test with /* clang-format officially supports C++ */ ;) Seriously speaking, the startswith() condition in the code should be a bit stricter. Maybe just compare with /* clang-format off */ and /* clang-format on */? If there's a motivating use case for just checking the prefix, could you add it to the test? |
clang/unittests/Format/SortIncludesTest.cpp | ||
---|---|---|
132 ↗ | (On Diff #188880) | You know i thought I was being so clever by not having the space after ..off to avoid /*clang-format off*/ That'll teach me! |
Fix negative test case
support the same /*<space>clang-format off<space>*/ in the sort includes that the TokenLexer supports.
clang/lib/Format/Format.cpp | ||
---|---|---|
1792 ↗ | (On Diff #188931) | Should we allow /* clang-format off It is just horrible for this piece of code. */ ? Multiline-comments could span multiple lines and to deactivates clang-format and give reasons. |
clang/lib/Format/Format.cpp | ||
---|---|---|
1792 ↗ | (On Diff #188931) | initially that is kind of what I was trying to do, but if you look over in TokenLexer where its turned off for styling they check only for a single line So to be honest if we are going to change it we should change it in both places, but perhaps that is just overkill. |
clang/lib/Format/Format.cpp | ||
---|---|---|
1792 ↗ | (On Diff #188931) | Totally, not necessary in my eyes, nice plus, so dont implement it :D |