| Issue |
52978
|
| Summary |
Recognize similar patterns to be aligned by clang-format
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Julien-Elie
|
Could it be possible for `clang-format` to automatically recognize identical patterns and align them correctly?
(Or provide a way to mention such patterns to align?)
It would be great to have something like the new `AlignArrayOfStructures` parameter for such patterns.
For instance, keep alignment (left or right, depending on the setting) for:
```
#define ARTHEADERINIT(name, type) { name, type, sizeof(name) - 1 }
const ARTHEADER ARTheaders[] = {
ARTHEADERINIT("Approved", HTstd),
ARTHEADERINIT("Control", HTstd),
ARTHEADERINIT("Date", HTreq),
ARTHEADERINIT("Distribution", HTstd),
ARTHEADERINIT("Expires", HTstd),
ARTHEADERINIT("From", HTreq),
};
```
```
is_string("a", concat("a", END), "concat 1");
is_string("ab", concat("a", "b", END), "concat 2");
is_string("ab", concat("ab", "", END), "concat 3");
is_string("ab", concat("", "ab", END), "concat 4");
is_string("", concat("", END), "concat 5");
is_string("abcde", concat("ab", "c", "", "de", END), "concat 6");
is_string("abcde", concat("abc", "de", END, "f", END), "concat 7");
```
```
#define BOOL(def) TYPE_BOOLEAN, { (def), 0, 0, NULL, NULL }
#define NUMBER(def) TYPE_NUMBER, { 0, (def), 0, NULL, NULL }
#define UNUMBER(def) TYPE_UNUMBER, { 0, 0, (def), NULL, NULL }
#define STRING(def) TYPE_STRING, { 0, 0, 0, (def), NULL }
#define LIST(def) TYPE_LIST, { 0, 0, 0, NULL, (def) }
```
```
#define CONF_BOOL(conf, offset) \
(bool *) (void *) ((char *) (conf) + (offset))
#define CONF_NUMBER(conf, offset) \
(long *) (void *) ((char *) (conf) + (offset))
#define CONF_UNUMBER(conf, offset) \
(unsigned long *) (void *) ((char *) (conf) + (offset))
#define CONF_STRING(conf, offset) \
(char **) (void *) ((char *) (conf) + (offset))
#define CONF_LIST(conf, offset) \
(struct vector **) (void *) ((char *) (conf) + (offset))
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs