[all-commits] [llvm/llvm-project] 9a0156: [clang-format] Fix qualifier ordering for lines af...

Ruoyu Zhong via All-commits all-commits at lists.llvm.org
Sat Sep 27 20:12:58 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9a01561760a2785fbf6d66f86ba2361d36a648f7
      https://github.com/llvm/llvm-project/commit/9a01561760a2785fbf6d66f86ba2361d36a648f7
  Author: Ruoyu Zhong <zhongruoyu at outlook.com>
  Date:   2025-09-27 (Sat, 27 Sep 2025)

  Changed paths:
    M clang/lib/Format/QualifierAlignmentFixer.cpp
    M clang/unittests/Format/QualifierFixerTest.cpp

  Log Message:
  -----------
  [clang-format] Fix qualifier ordering for lines after PP directives (#160731)

Lines appearing after preprocessor conditional blocks (like `#endif`)
were not having their qualifiers reordered by `QualifierOrder`, while
lines inside the conditional blocks were processed correctly.

The issue was that tokens on lines following preprocessor directives
have `MustBreakBefore` = `true`. The qualifier alignment logic was
breaking immediately upon encountering any token with `MustBreakBefore`
= `true`, preventing analysis of the entire line.

The fix allows processing to continue when `MustBreakBefore` = `true` on
the first token of a line, since this is expected behavior (the token
legitimately starts a new line). Only tokens with `MustBreakBefore` =
`true` that appear mid-line will cause the analysis loop to break.

Fixes https://github.com/llvm/llvm-project/issues/160487.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list