LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27353 - PointerAlignment: Right interaction with AlignConsecutiveDeclarations
Summary: PointerAlignment: Right interaction with AlignConsecutiveDeclarations
Status: CONFIRMED
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-14 13:26 PDT by Seth
Modified: 2021-05-28 13:04 PDT (History)
7 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Seth 2016-04-14 13:26:42 PDT
Repro:
$ cat sample.c
int* a;
unsigned long long x;
double* b;
$ clang-format -style="{PointerAlignment: Right, AlignConsecutiveDeclarations: true}" sample.c
int *              a;
unsigned long long x;
double *           b;

Expected/desired output is:

int                *a;
unsigned long long  x;
double             *b;
Comment 1 Ronak Gandhi 2017-12-11 13:52:16 PST
+1

I'd like to get this fixed as well. 

With current implementation, AlignConsecutiveDeclarations breaks PointerAlignment.
Comment 2 Roland Schulz 2018-08-12 19:07:59 PDT
In the code (clang/lib/Format/WhitespaceManager.cpp:449) contains a comment about this. It states it is unclear how

  const char* const* v1;
  float const* v2;
  SomeVeryLongType const& v3;

should be aligned. Does everyone agree that

  const char *const      *v1;
  float const            *v2;
  SomeVeryLongType const &v3;

is correct?

Or does anyone want:

  const char      *const *v1;

Or something else?
Comment 3 Roland Schulz 2018-08-15 12:34:51 PDT
Addressed by https://reviews.llvm.org/D27651
Comment 4 Marek Kurdej 2021-05-28 13:04:11 PDT
https://reviews.llvm.org/D103245