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

Jan Voung via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 11:53:45 PDT 2025


================
@@ -12720,6 +12735,21 @@ TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) {
   verifyFormat(("x = (foo *" + AllQualifiers + " __my_qualifier)&v;").str(),
                CustomQualifier);
 
+  // Check additional attribute macros in Google style:
+  FormatStyle LongPointerRightGoogle = getGoogleStyleWithColumns(999);
+  FormatStyle LongPointerLeftGoogle = getGoogleStyleWithColumns(999);
+  LongPointerLeftGoogle.PointerAlignment = FormatStyle::PAS_Left;
+  Twine AllQualifiersPlusGoogle =
+      AllQualifiers + " absl_nonnull absl_nullable absl_nullability_unknown";
+  verifyFormat(("x = (foo *" + AllQualifiersPlusGoogle + ")*v;").str(),
+               LongPointerRightGoogle);
+  verifyFormat(("x = (foo* " + AllQualifiersPlusGoogle + ")*v;").str(),
+               LongPointerLeftGoogle);
+  verifyFormat(("x = (foo *" + AllQualifiersPlusGoogle + ")&v;").str(),
+               LongPointerRightGoogle);
+  verifyFormat(("x = (foo* " + AllQualifiersPlusGoogle + ")&v;").str(),
+               LongPointerLeftGoogle);
+
----------------
jvoung wrote:

Done

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


More information about the cfe-commits mailing list