[all-commits] [llvm/llvm-project] 5723fc: [Format] Fix isStartOfName to recognize attributes...

Ilya Biryukov via All-commits all-commits at lists.llvm.org
Mon Jan 15 05:57:17 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5723fce088068cc91cf22e3a3da5700e213ce63e
      https://github.com/llvm/llvm-project/commit/5723fce088068cc91cf22e3a3da5700e213ce63e
  Author: Ilya Biryukov <ibiryukov at google.com>
  Date:   2024-01-15 (Mon, 15 Jan 2024)

  Changed paths:
    M clang/lib/Format/Format.cpp
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [Format] Fix isStartOfName to recognize attributes (#76804)

This addresses a problem with formatting attributes. Some context:
- eaff083035c8 changed `isStartOfName` to fix problems inside
`#pragma`s, but this behavior changed formatting of attribute macros in
an undesirable way.
- efeb546865c233dfa7706ee0316c676de9f69897 changed Google format style
to fix some widely used attributes.

Instead of changing the format style, this commit specializes behavior
introduced in eaff083035c8 to `#pragma`s. This seems to work well in
both cases.

Also update the test with two `GUARDED_BY` directives. While the
formatting after efeb546865c233dfa7706ee0316c676de9f69897 seems better,
this case is rare enough to not warrant the extra complexity. We are
reverting it back to the state it had before
efeb546865c233dfa7706ee0316c676de9f69897.

---------

Co-authored-by: Owen Pan <owenpiano at gmail.com>




More information about the All-commits mailing list