================
@@ -2296,6 +2299,125 @@ TEST_F(FormatTest, SeparatePointerReferenceAlignment) {
   // verifyFormat("int Add2(BTree * &Root, char * szToAdd)", Style);
 }
 
+TEST_F(FormatTest, ReturnTypeAlignment) {
+  // Test that ReturnType overrides PointerAlignment for return types
+  FormatStyle Style = getLLVMStyle();
+  Style.PointerAlignment = {/*Default=*/FormatStyle::PAS_Right,
+                            /*ReturnType=*/FormatStyle::SAS_Left};
+  Style.ReferenceAlignment = {/*Default=*/FormatStyle::RAS_Pointer,
+                              /*ReturnType=*/FormatStyle::SAS_Left};
+
+  // Return type pointers should be left-aligned despite PAS_Right
+  verifyFormat("int* f1(int *a, int *b);", Style);
+  verifyFormat("int& f2(int &a, int &b);", Style);
+  verifyFormat("int&& f3(int &&a, int &&b);", Style);
+
+  // Multiple pointers in return type
+  verifyFormat("int** f4(int **a);", Style);
+  verifyFormat("const int* f5(const int *a);", Style);
+  verifyFormat("int*** f6(int ***a);", Style);
+
+  // Multiple pointers with const qualifiers
+  verifyFormat("const int** f7(const int **a);", Style);
+  verifyFormat("int* const* f8(int *const *a);", Style);
+  verifyFormat("const int* const* f9(const int *const *a);", Style);
+  verifyFormat("int** const f10(int **const a);", Style);
+  verifyFormat("const int** const f11(const int **const a);", Style);
+
+  // Triple pointers with const
----------------
HazardyKnusperkeks wrote:

Do you really think you need that many tests?

https://github.com/llvm/llvm-project/pull/169160
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to