# Why are the breaks sometimes removed when AlwaysBreakAfterReturnType is All?

**URL:** <https://discourse.llvm.org/t/why-are-the-breaks-sometimes-removed-when-alwaysbreakafterreturntype-is-all/75780>\
**Category:** Using Clang\
**Tags:** clang-format\
**Created:** [December 19, 2023, 12:56pm UTC](https://discourse.llvm.org/t/why-are-the-breaks-sometimes-removed-when-alwaysbreakafterreturntype-is-all/75780 "2023-12-19T12:56:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattmundell](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/mattmundell/32/20892_2.png) [@mattmundell](https://discourse.llvm.org/u/mattmundell)\
**Post date:** [December 19, 2023, 12:56pm UTC](https://discourse.llvm.org/t/why-are-the-breaks-sometimes-removed-when-alwaysbreakafterreturntype-is-all/75780/1 "2023-12-19T12:56:12Z")

</div>

Hi

I’m trying to understand this clang-format behaviour.

When AlwaysBreakAfterReturnType is set to All the break after the return type is removed in some cases.

For example:

```auto
printf "int\nshort();\n" | clang-format -style='{ AlwaysBreakAfterReturnType: All }'

```

returns

```auto
int short();

```

instead of

```auto
int
short();

```

Is there some other option that also affects the break?

Thanks  
Matt

---

<div class="post-metadata">

**Author:** ![owenpan](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/owenpan/32/23240_2.png) [@owenpan](https://discourse.llvm.org/u/owenpan)\
**Post date:** [December 22, 2023, 12:47am UTC](https://discourse.llvm.org/t/why-are-the-breaks-sometimes-removed-when-alwaysbreakafterreturntype-is-all/75780/2 "2023-12-22T00:47:18Z")

</div>

This is because `short` is a keyword. Try e.g. `int abcde();`. If you still run into problems, you can file an issue on GitHub.

---

<div class="post-metadata">

**Author:** ![mattmundell](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/mattmundell/32/20892_2.png) [@mattmundell](https://discourse.llvm.org/u/mattmundell)\
**Post date:** [December 22, 2023, 1:04am UTC](https://discourse.llvm.org/t/why-are-the-breaks-sometimes-removed-when-alwaysbreakafterreturntype-is-all/75780/3 "2023-12-22T01:04:02Z")

</div>

Ah, silly of me to use “short” as my test case.

This is closer to my actual code:

```auto
printf "int\niso_time(time_t);\n" | clang-format -style='{ AlwaysBreakAfterReturnType: All }'

```

returning

```auto
int iso_time(time_t);

```

Am I missing something else about keywords in this case? It works if make the arg a “time\_t \*”.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![owenpan](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/owenpan/32/23240_2.png) [@owenpan](https://discourse.llvm.org/u/owenpan)\
**Post date:** [December 22, 2023, 5:52am UTC](https://discourse.llvm.org/t/why-are-the-breaks-sometimes-removed-when-alwaysbreakafterreturntype-is-all/75780/4 "2023-12-22T05:52:33Z")

</div>

clang-format should be able to handle this if it knows that `time_t` is a type name. I’ve opened a [pull request](https://github.com/llvm/llvm-project/pull/76206) that will fix this, provided that you add `time_t` to the `TypeNames` option:

```auto
$ printf "int\niso_time(time_t);\n" | clang-format -style='{ AlwaysBreakAfterReturnType: All, TypeNames: [time_t] }'
int
iso_time(time_t);
$ 

```
