[PATCH] D96744: clang-format IncludeBlocks: Regroup determination of "main" for framework-style includes fix

Conrad Poelman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 16 01:53:58 PST 2021


poelmanc added a comment.

Thanks for the speedy reply and the great tool. With appropriate Regex and Priority settings, `IncludeCategories` worked flawlessly for me aside from not identifying the main header. Treating `#include "foo/bar/baz.h"` as the main header in file `bar/random/baz.h` seems like a bug, but I certainly see the dangers of changing current `<>` behavior. I also considered treating `<>` includes as main headers only if they also contain a forward-slash, e.g.:

  if (!IncludeName.startswith("\"") && !IncludeName.contains("/"))
    return false;

That would resolve the `<string.h>` case, although `#include <sys/types.h>` in a file `anything/sys/types.h` would be identified as the main header. So making an option seems like the cleanest solution. Say, `bool IncludeIsMainAllowBraces`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96744



More information about the cfe-commits mailing list