llvm / llvm/llvm-project

clang-format `AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments` does NOT work on functions

Open
#212,120 1 comment 0 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

clang-format 22 (from llvm repo for Debian) is suggesting to break the alignment of `gimp_scroll_get_adjustment_value`. But it should still remain aligned with `gimp_scrolled_preview_thaw` and `gimp_scroll_adjustment_values` since I am using `AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments`

[.clang-format.zip](https://github.com/user-attachments/files/30388528/default.clang-format.zip)

```diff
--- libgimpwidgets/gimpscrolledpreview.h (before formatting)
+++ libgimpwidgets/gimpscrolledpreview.h (after formatting)
@@ -70,12 +70,12 @@
void gimp_scrolled_preview_thaw (GimpScrolledPreview *preview);

/* utility function for scrolled-window like gimp widgets, like the canvas */
-void gimp_scroll_get_adjustment_values (GdkEventScroll *sevent,
- GtkAdjustment *hadj,
- GtkAdjustment *vadj,
- gdouble *hvalue,
- gdouble *vvalue,
- gboolean clamp_output);
+void gimp_scroll_get_adjustment_values (GdkEventScroll *sevent,
+ GtkAdjustment *hadj,
+ GtkAdjustment *vadj,
+ gdouble *hvalue,
+ gdouble *vvalue,
+ gboolean clamp_output);

/* legacy version of the same (imposes clamping on output) */
void gimp_scroll_adjustment_values (GdkEventScroll *sevent,
```

Contributor guide

Open the contributing guide

Research direction

Start with the formatting example in libgimpwidgets/gimpscrolledpreview.h and the attached .clang-format configuration; reproduce the result with clang-format 22. Trace how AlignConsecutiveDeclarations handles function declarations across empty lines and comments. Done means the three gimp_* declarations remain aligned under this option, with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.