[all-commits] [llvm/llvm-project] 984dd1: [clang-format] Add MainIncludeChar option. (#78752)

j-jorge via All-commits all-commits at lists.llvm.org
Tue Feb 6 01:06:45 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 984dd15d4da33337b2800d4776aa8ecc168b145e
      https://github.com/llvm/llvm-project/commit/984dd15d4da33337b2800d4776aa8ecc168b145e
  Author: j-jorge <j-jorge at users.noreply.github.com>
  Date:   2024-02-06 (Tue, 06 Feb 2024)

  Changed paths:
    M clang/docs/ClangFormatStyleOptions.rst
    M clang/include/clang/Format/Format.h
    M clang/include/clang/Tooling/Inclusions/IncludeStyle.h
    M clang/lib/Format/Format.cpp
    M clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
    M clang/lib/Tooling/Inclusions/IncludeStyle.cpp
    M clang/unittests/Format/SortIncludesTest.cpp

  Log Message:
  -----------
  [clang-format] Add MainIncludeChar option. (#78752)

Resolves #27008, #39735, #53013, #63619.

Hello, this PR adds the MainIncludeChar option to clang-format, allowing
to select which include syntax must be considered when searching for the
main header: quotes (`#include "foo.hpp"`, the default), brackets
(`#include <foo.hpp>`), or both.

The lack of support for brackets has been reported many times, see the
linked issues, so I am pretty sure there is a need for it :)

A short note about why I did not implement a regex approach as discussed
in #53013: while a regex would have allowed many extra ways to describe
the main header, the bug descriptions listed above suggest a very simple
need: support brackets for the main header. This PR answers this needs
in a quite simple way, with a very simple style option. IMHO the feature
space covered by the regex (again, for which there is no demand :)) can
be implemented latter, in addition to the proposed option.

The PR also includes tests for the option with and without grouped
includes.




More information about the All-commits mailing list