do not add existing includes.
Details
Diff Detail
Event Timeline
I am happy to get this in for now, but I actually think the right solution might be to let clang-format de-duplicate #includes in general. What do you think?
It should be quite straight-forward to de-duplicate #includes in the same block in sortIncludes. I'm happy to add this into sortIncludes, but I'm not sure if this is a behavior users would expect from clang-format since it deletes code?
And maybe duplicated headers are not that common in the first place? I would rather rely on users (like #include_fixer) to make sure there is no duplicated #include.
Well, it is easy to not see duplicated #includes when they aren't properly sorted. When clang-format then goes in and sorts them, they end up next to each other. And I think no user really wants that.
Agreed. So, do we still want to skip existing #includes here or simply rely on sortIncludes to de-duplicate?
Lets get this in for now. We can always remove it if we think it is no longer useful.
unittests/Format/CleanupTest.cpp | ||
---|---|---|
692 | Please also add a test with quoted #includes as well as combined forms (inserting <vector> when there already is "vector" and vice versa). |
- addressed reviewer's comments.
unittests/Format/CleanupTest.cpp | ||
---|---|---|
701 | I'm not sure... this might not be the best behavior. FIXME added. |
Please also add a test with quoted #includes as well as combined forms (inserting <vector> when there already is "vector" and vice versa).