[PATCH] D143691: Fix clang-formats IncludeCategory to match the documentation

Fabian Keßler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 10 17:58:49 PST 2023


Febbe updated this revision to Diff 496647.
Febbe added a comment.

Fixed the Unit Tests

- rewritten one test, which made the assumption, that there can be only one main header.
  - it now asserts, that all matching headers are considered as main header.
- replaced initialisations of `IncludeCategories.SortPriority` to zero  with the value from `IncludeCategories.Priority`
  - the previous approach to set the SortPriority when it's 0 to Priority, instead of initializing it directly as intended had several drawbacks:
    - values of 0 were not possible and resulted in weird behav.
    - when a main include was matched by another matcher, it got annother sortpriority than 0.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143691/new/

https://reviews.llvm.org/D143691

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/lib/Tooling/Inclusions/IncludeStyle.cpp
  clang/unittests/Format/SortIncludesTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143691.496647.patch
Type: text/x-patch
Size: 9970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230211/fa5aeeee/attachment-0001.bin>


More information about the cfe-commits mailing list