[cfe-dev] Clang Format: Add option to align types?
Whisperity via cfe-dev
cfe-dev at lists.llvm.org
Wed Oct 10 02:10:20 PDT 2018
While I am not exactly able to help on the technical details as I’m also new on Clang grounds, if you or anyone else steps forward to implement this, I think it would be nice to early on consider a few more rules, such as:
• Aligning the cv-qualifiers together and indent the real type name into a separate column
• Within some reasonable boundary, align template arguments.
; Whisperity.
From: Marcus Johnson via cfe-dev
Sent: 2018. október 10., szerda 0:41
To: cfe-dev
Subject: [cfe-dev] Clang Format: Add option to align types?
I'm not sure if this is even the right place to ask, I did a quick search looking for a clang-format specific list but couldn't find one, does anyone know if there even is one?
I'm trying to add an option to Clang-Format that would allow users to align variables in structs/classes and functions based on the width of the type identifier.
Here's a couple examples to better illustrate what I'm talking about:
typedef struct Unaligned_Struct {
int wat;
uint8_t huh;
uint64_t who;
} Unaligned_Struct;
int Unaligned_Average(int A, int B, int num) {
int Average = A + B;
int32_t Divided = Average / num;
return Divided;
}
vs
typedef struct Aligned_Struct {
int wat;
uint8_t huh;
uint64_t who;
} Aligned_Struct;
int Aligned_Average(int A, int B, int num) {
int Average = A + B;
int32_t Divided = Average / num;
return Divided;
}
I'm not sure if the formatting is showing up, so I geuss I'l have to describe it.
The Aligned blocks all of the variables have X number of spaces added between the type and the variable name, so that they're all aligned in a single column.
it makes reading the code a lot easier, I've been doing thi manually with my code for a while, and Clang-Format not having this feature is the biggest reason I don't currently use it.
As for my questions, they are:
How exactly do I do this?
Should I write a new enum (I've been thinking about calling it "AlignTypeDeclarationStyle", but that seems a little clunky, and I'm not sure if it's the best way to describe what exactly is going on)
and how exactly would I hook this into the Clang-Format library?
I've never contributed to the LLVM project before, I've read the documents a few times, and I've tried reading the code, but it's very intertwined and it's hard to drill down as deep as I need.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181010/bce009f6/attachment.html>
More information about the cfe-dev
mailing list