LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 35099 - clang-format performs SortIncludes even if DisableFormat: true
Summary: clang-format performs SortIncludes even if DisableFormat: true
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: 5.0
Hardware: PC Windows NT
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-26 09:00 PDT by Vlad Vukicevic
Modified: 2021-05-04 11:05 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s): 61dc0f2b593da149a4c0cea67819cd7bdbdd50b8


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vlad Vukicevic 2017-10-26 09:00:39 PDT
DisableFormat: true doesn't turn off SortIncludes (clang-format 5.0):

$ printf '#include <B>\n#include <A>\n' | clang-format -assume-filename=test.cpp -style='{DisableFormat: true}'
#include <A>
#include <B>

It needs to be explicitly specified as false to turn it off:

$ printf '#include <B>\n#include <A>\n' | clang-format -assume-filename=test.cpp -style='{DisableFormat: true, SortIncludes: false}'
#include <B>
#include <A>

Not sure if it is intentional or not -- was surprising at the very least.
Comment 1 NN 2021-04-14 06:36:00 PDT
Issue persist clang-format 11.0.
Comment 2 Nathan James 2021-04-30 07:05:23 PDT
Seems confusing to me as well, put in a quick hotfix https://reviews.llvm.org/D101628