[clang] 043b608 - [Matrix] Use 1st/2nd instead of first/second in matrix diags.

Florian Hahn via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 25 03:55:17 PDT 2020


Author: Florian Hahn
Date: 2020-06-25T11:55:03+01:00
New Revision: 043b608399559969f563eaa52e11a7ffe37137d9

URL: https://github.com/llvm/llvm-project/commit/043b608399559969f563eaa52e11a7ffe37137d9
DIFF: https://github.com/llvm/llvm-project/commit/043b608399559969f563eaa52e11a7ffe37137d9.diff

LOG: [Matrix] Use 1st/2nd instead of first/second in matrix diags.

This was suggested in D72782 and brings the diagnostics more in line
with how argument references are handled elsewhere.

Reviewers: rjmccall, jfb, Bigcheese

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D82473

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticSemaKinds.td
    clang/lib/Sema/SemaChecking.cpp
    clang/test/Sema/matrix-type-builtins.c
    clang/test/SemaCXX/matrix-type-builtins.cpp
    clang/test/SemaObjC/matrix-type-builtins.m

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index beccdf9a3210..9067c45adc77 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10789,13 +10789,13 @@ def err_matrix_separate_incomplete_index: Error<
   "matrix row and column subscripts cannot be separated by any expression">;
 def err_matrix_subscript_comma: Error<
   "comma expressions are not allowed as indices in matrix subscript expressions">;
-def err_builtin_matrix_arg: Error<"first argument must be a matrix">;
+def err_builtin_matrix_arg: Error<"1st argument must be a matrix">;
 def err_builtin_matrix_scalar_unsigned_arg: Error<
   "%0 argument must be a constant unsigned integer expression">;
 def err_builtin_matrix_pointer_arg: Error<
-  "%0 argument must be a pointer to a valid matrix element type">;
+  "%ordinal0 argument must be a pointer to a valid matrix element type">;
 def err_builtin_matrix_pointer_arg_mismatch: Error<
-  "the pointee of the second argument must match the element type of the first argument (%0 != %1)">;
+  "the pointee of the 2nd argument must match the element type of the 1st argument (%0 != %1)">;
 def err_builtin_matrix_store_to_const: Error<
   "cannot store matrix to read-only pointer">;
 def err_builtin_matrix_stride_too_small: Error<

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e6a3b54c3cc1..9d0516e0232e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -15295,7 +15295,8 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
   if (checkArgCount(*this, TheCall, 4))
     return ExprError();
 
-  Expr *PtrExpr = TheCall->getArg(0);
+  unsigned PtrArgIdx = 0;
+  Expr *PtrExpr = TheCall->getArg(PtrArgIdx);
   Expr *RowsExpr = TheCall->getArg(1);
   Expr *ColumnsExpr = TheCall->getArg(2);
   Expr *StrideExpr = TheCall->getArg(3);
@@ -15319,14 +15320,14 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
   QualType ElementTy;
   if (!PtrTy) {
     Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-        << "first";
+        << PtrArgIdx + 1;
     ArgError = true;
   } else {
     ElementTy = PtrTy->getPointeeType().getUnqualifiedType();
 
     if (!ConstantMatrixType::isValidElementType(ElementTy)) {
       Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-          << "first";
+          << PtrArgIdx + 1;
       ArgError = true;
     }
   }
@@ -15402,8 +15403,9 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
   if (checkArgCount(*this, TheCall, 3))
     return ExprError();
 
+  unsigned PtrArgIdx = 1;
   Expr *MatrixExpr = TheCall->getArg(0);
-  Expr *PtrExpr = TheCall->getArg(1);
+  Expr *PtrExpr = TheCall->getArg(PtrArgIdx);
   Expr *StrideExpr = TheCall->getArg(2);
 
   bool ArgError = false;
@@ -15442,7 +15444,7 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
   auto *PtrTy = PtrExpr->getType()->getAs<PointerType>();
   if (!PtrTy) {
     Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
-        << "second";
+        << PtrArgIdx + 1;
     ArgError = true;
   } else {
     QualType ElementTy = PtrTy->getPointeeType();

diff  --git a/clang/test/Sema/matrix-type-builtins.c b/clang/test/Sema/matrix-type-builtins.c
index d8da11aa05aa..2f7e4549e495 100644
--- a/clang/test/Sema/matrix-type-builtins.c
+++ b/clang/test/Sema/matrix-type-builtins.c
@@ -11,11 +11,11 @@ void transpose(sx5x10_t a, ix3x2_t b, dx3x3 c, int *d, int e) {
   b = __builtin_matrix_transpose(b);
   // expected-error at -1 {{assigning to 'ix3x2_t' (aka 'int __attribute__((matrix_type(3, 2)))') from incompatible type 'int __attribute__((matrix_type(2, 3)))'}}
   __builtin_matrix_transpose(d);
-  // expected-error at -1 {{first argument must be a matrix}}
+  // expected-error at -1 {{1st argument must be a matrix}}
   __builtin_matrix_transpose(e);
-  // expected-error at -1 {{first argument must be a matrix}}
+  // expected-error at -1 {{1st argument must be a matrix}}
   __builtin_matrix_transpose("test");
-  // expected-error at -1 {{first argument must be a matrix}}
+  // expected-error at -1 {{1st argument must be a matrix}}
 
   ix3x3 m = __builtin_matrix_transpose(c);
   // expected-error at -1 {{initializing 'ix3x3' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') with an expression of incompatible type 'double __attribute__((matrix_type(3, 3)))'}}
@@ -43,10 +43,10 @@ void column_major_load(float *p1, int *p2, _Bool *p3, struct Foo *p4) {
   // expected-error at -1 {{stride must be greater or equal to the number of rows}}
 
   sx5x10_t a8 = __builtin_matrix_column_major_load(p3, 5, 10, 6);
-  // expected-error at -1 {{first argument must be a pointer to a valid matrix element type}}
+  // expected-error at -1 {{1st argument must be a pointer to a valid matrix element type}}
 
   sx5x10_t a9 = __builtin_matrix_column_major_load(p4, 5, 10, 6);
-  // expected-error at -1 {{first argument must be a pointer to a valid matrix element type}}
+  // expected-error at -1 {{1st argument must be a pointer to a valid matrix element type}}
 
   sx5x10_t a10 = __builtin_matrix_column_major_load(p1, 1ull << 21, 10, 6);
   // expected-error at -1 {{row dimension is outside the allowed range [1, 1048575}}
@@ -54,13 +54,13 @@ void column_major_load(float *p1, int *p2, _Bool *p3, struct Foo *p4) {
   // expected-error at -1 {{column dimension is outside the allowed range [1, 1048575}}
 
   sx5x10_t a12 = __builtin_matrix_column_major_load(
-      10,         // expected-error {{first argument must be a pointer to a valid matrix element type}}
+      10,         // expected-error {{1st argument must be a pointer to a valid matrix element type}}
       1ull << 21, // expected-error {{row dimension is outside the allowed range [1, 1048575]}}
       1ull << 21, // expected-error {{column dimension is outside the allowed range [1, 1048575]}}
       "");        // expected-warning {{incompatible pointer to integer conversion casting 'char [1]' to type 'unsigned long'}}
 
   sx5x10_t a13 = __builtin_matrix_column_major_load(
-      10,  // expected-error {{first argument must be a pointer to a valid matrix element type}}
+      10,  // expected-error {{1st argument must be a pointer to a valid matrix element type}}
       *p4, // expected-error {{casting 'struct Foo' to incompatible type 'unsigned long'}}
       "",  // expected-error {{column argument must be a constant unsigned integer expression}}
            // expected-warning at -1 {{incompatible pointer to integer conversion casting 'char [1]' to type 'unsigned long'}}
@@ -73,18 +73,18 @@ void column_major_store(sx5x10_t *m1, ix3x2_t *m2, float *p1, int *p2, struct Fo
   __builtin_matrix_column_major_store(*m1, p1, 0);
   // expected-error at -1 {{stride must be greater or equal to the number of rows}}
   __builtin_matrix_column_major_store(*m1, p2, 10);
-  // expected-error at -1 {{the pointee of the second argument must match the element type of the first argument ('int' != 'float')}}
+  // expected-error at -1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('int' != 'float')}}
   __builtin_matrix_column_major_store(p1, p2, 10);
-  // expected-error at -1 {{first argument must be a matrix}}
+  // expected-error at -1 {{1st argument must be a matrix}}
 
   __builtin_matrix_column_major_store(
-      "",   // expected-error {{first argument must be a matrix}}
-      10,   // expected-error {{second argument must be a pointer to a valid matrix element type}}
+      "",   // expected-error {{1st argument must be a matrix}}
+      10,   // expected-error {{2nd argument must be a pointer to a valid matrix element type}}
       *p3); // expected-error {{casting 'struct Foo' to incompatible type 'unsigned long'}}
 
   __builtin_matrix_column_major_store(
       *m1,
-      10, // expected-error {{second argument must be a pointer to a valid matrix element type}}
+      10, // expected-error {{2nd argument must be a pointer to a valid matrix element type}}
       10);
 
   *m1 = __builtin_matrix_column_major_store(*m1, p1, 10);

diff  --git a/clang/test/SemaCXX/matrix-type-builtins.cpp b/clang/test/SemaCXX/matrix-type-builtins.cpp
index 3850e4ff901b..fce4d6fb2162 100644
--- a/clang/test/SemaCXX/matrix-type-builtins.cpp
+++ b/clang/test/SemaCXX/matrix-type-builtins.cpp
@@ -15,9 +15,9 @@ typename MyMatrix<EltTy1, R1, C1>::matrix_t transpose(MyMatrix<EltTy0, R0, C0> &
   // expected-error at -3 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 3)))'}}
 
   __builtin_matrix_transpose(A);
-  // expected-error at -1 {{first argument must be a matrix}}
-  // expected-error at -2 {{first argument must be a matrix}}
-  // expected-error at -3 {{first argument must be a matrix}}
+  // expected-error at -1 {{1st argument must be a matrix}}
+  // expected-error at -2 {{1st argument must be a matrix}}
+  // expected-error at -3 {{1st argument must be a matrix}}
 
   return __builtin_matrix_transpose(A.value);
   // expected-error at -1 {{cannot initialize return object of type 'typename MyMatrix<unsigned int, 2U, 3U>::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 3)))') with an rvalue of type 'unsigned int __attribute__((matrix_type(3, 2)))'}}
@@ -99,13 +99,13 @@ void call_column_major_load_temp(unsigned *Ptr, unsigned X) {
   // expected-error at -1 {{row argument must be a constant unsigned integer expression}}
   // expected-error at -2 {{column argument must be a constant unsigned integer expression}}
   (void)__builtin_matrix_column_major_load(X, 2, 2, 2);
-  // expected-error at -1 {{first argument must be a pointer to a valid matrix element type}}
+  // expected-error at -1 {{1st argument must be a pointer to a valid matrix element type}}
 }
 
 template <typename EltTy0, unsigned R0, unsigned C0, typename PtrTy>
 void column_major_store(MyMatrix<EltTy0, R0, C0> &A, PtrTy Ptr, unsigned Stride) {
   __builtin_matrix_column_major_store(A.value, Ptr, Stride);
-  // expected-error at -1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}}
+  // expected-error at -1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'unsigned int')}}
 }
 
 template <typename MTy, typename PtrTy, unsigned Stride>
@@ -126,14 +126,14 @@ template <typename EltTy0, unsigned R0, unsigned C0, typename EltTy1>
 void column_major_store(MyMatrix<EltTy0, R0, C0> &A, EltTy1 *Ptr) {
   __builtin_matrix_column_major_store(A.value, Ptr, 1);
   // expected-error at -1 3 {{stride must be greater or equal to the number of rows}}
-  // expected-error at -2 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}}
-  // expected-error at -3 {{the pointee of the second argument must match the element type of the first argument ('unsigned int' != 'float')}}
+  // expected-error at -2 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'unsigned int')}}
+  // expected-error at -3 {{the pointee of the 2nd argument must match the element type of the 1st argument ('unsigned int' != 'float')}}
 
   char *s;
   return __builtin_matrix_column_major_store(A.value, s, 20);
-  // expected-error at -1 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}}
-  // expected-error at -2 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}}
-  // expected-error at -3 {{he pointee of the second argument must match the element type of the first argument ('char' != 'float')}}
+  // expected-error at -1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('char' != 'unsigned int')}}
+  // expected-error at -2 {{the pointee of the 2nd argument must match the element type of the 1st argument ('char' != 'unsigned int')}}
+  // expected-error at -3 {{he pointee of the 2nd argument must match the element type of the 1st argument ('char' != 'float')}}
 }
 
 void test_column_major_store_template(unsigned *Ptr1, float *Ptr2) {
@@ -152,9 +152,9 @@ void test_column_major_store_constexpr(unsigned *Ptr, MyMatrix<unsigned, 3, 3> &
   __builtin_matrix_column_major_store(M.value, Ptr, constexpr1());
   // expected-error at -1 {{stride must be greater or equal to the number of rows}}
   __builtin_matrix_column_major_store(constexpr1(), Ptr, 1);
-  // expected-error at -1 {{first argument must be a matrix}}
+  // expected-error at -1 {{1st argument must be a matrix}}
   __builtin_matrix_column_major_store(M.value, constexpr1(), 1);
-  // expected-error at -1 {{second argument must be a pointer to a valid matrix element type}}
+  // expected-error at -1 {{2nd argument must be a pointer to a valid matrix element type}}
   // expected-error at -2 {{stride must be greater or equal to the number of rows}}
 }
 
@@ -162,5 +162,5 @@ void test_column_major_store_wrapper(unsigned *Ptr, MyMatrix<unsigned, 3, 3> &M,
   __builtin_matrix_column_major_store(M.value, Ptr, W);
 
   __builtin_matrix_column_major_store(W, Ptr, W);
-  // expected-error at -1 {{first argument must be a matrix}}
+  // expected-error at -1 {{1st argument must be a matrix}}
 }

diff  --git a/clang/test/SemaObjC/matrix-type-builtins.m b/clang/test/SemaObjC/matrix-type-builtins.m
index dc18905963e4..21b8bf864271 100644
--- a/clang/test/SemaObjC/matrix-type-builtins.m
+++ b/clang/test/SemaObjC/matrix-type-builtins.m
@@ -22,10 +22,10 @@ void test_element_type_mismatch(u4x4 m, MatrixValue *mv) {
 
 double test_store(MatrixValue *mv, float *Ptr) {
   __builtin_matrix_column_major_store(mv.value, Ptr, 1);
-  // expected-error at -1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'double')}}
+  // expected-error at -1 {{the pointee of the 2nd argument must match the element type of the 1st argument ('float' != 'double')}}
   // expected-error at -2 {{stride must be greater or equal to the number of rows}}
 
   __builtin_matrix_column_major_store(mv.value, mv.value, mv.value);
-  // expected-error at -1 {{second argument must be a pointer to a valid matrix element type}}
+  // expected-error at -1 {{2nd argument must be a pointer to a valid matrix element type}}
   // expected-error at -2 {{casting 'double4x4' (aka 'double __attribute__((matrix_type(4, 4)))') to incompatible type 'unsigned long}}
 }


        


More information about the cfe-commits mailing list