[clang] [clang-format] Add support for absl nullability macros (PR #130346)

Jan Voung via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 10 07:51:52 PDT 2025


jvoung wrote:

> I wish they had not been added to the default but can't take them off the lists for backward compatibility. I don't think we should add more. The reason is that people wouldn't be able to turn off the special meaning if they wanted to use e.g. `absl_nonnull` as a regular identifier.

What if this is limited to the Google style? +cc some folks involved in the Google style @ilya-biryukov 
It is not yet in the style guide, but we are working on getting the style guide updated.

The chance of using `absl_nonnull` as a regular identifier at the same time as using the Google style is likely lower.

> Can you log an issue for `std::vector<int * absl_nonnull> y;`? It's a bug IMO and can be easily fixed.

filed https://github.com/llvm/llvm-project/issues/130602 but I think there are still cases it wouldn't cover, right? (like `ContainerWithSize<MyType* absl_nonnull, MySize * MyCount> fixed_array;`)

> Abseil itself doesn't even define them in their .clang-format file.

We're working toward getting it in the google style guide, so it will be covered by `BasedOnStyle:  Google` (which is the main thing in the Abseil .clang-format file), so that folks don't need to specify this individually (and less risk of forgetting to set it and diverging from the style).


https://github.com/llvm/llvm-project/pull/130346


More information about the cfe-commits mailing list