Skip to content

Commit 281dbc1

Browse files
committed
[Matrix] Replace some err kinds with err_builtin_invalid_arg_type. (NFC)
Replace some custom matrix diagnostic kinds with the more generic err_builtin_invalid_arg_type introduced in D111985. Reviewed By: aaron.ballman, erichkeane Differential Revision: https://reviews.llvm.org/D112532 (cherry-picked from d7fbad0)
1 parent 6a4f94c commit 281dbc1

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11353,7 +11353,9 @@ def err_builtin_launder_invalid_arg : Error<
1135311353
"'__builtin_launder' is not allowed">;
1135411354

1135511355
def err_builtin_invalid_arg_type: Error <
11356-
"%ordinal0 argument must be a %1 (was %2)">;
11356+
"%ordinal0 argument must be a "
11357+
"%select{vector, integer or floating point type|matrix|"
11358+
"pointer to a valid matrix element type}1 (was %2)">;
1135711359

1135811360
def err_builtin_matrix_disabled: Error<
1135911361
"matrix types extension is disabled. Pass -fenable-matrix to enable it">;
@@ -11367,11 +11369,8 @@ def err_matrix_separate_incomplete_index: Error<
1136711369
"matrix row and column subscripts cannot be separated by any expression">;
1136811370
def err_matrix_subscript_comma: Error<
1136911371
"comma expressions are not allowed as indices in matrix subscript expressions">;
11370-
def err_builtin_matrix_arg: Error<"1st argument must be a matrix">;
1137111372
def err_builtin_matrix_scalar_unsigned_arg: Error<
1137211373
"%0 argument must be a constant unsigned integer expression">;
11373-
def err_builtin_matrix_pointer_arg: Error<
11374-
"%ordinal0 argument must be a pointer to a valid matrix element type">;
1137511374
def err_builtin_matrix_pointer_arg_mismatch: Error<
1137611375
"the pointee of the 2nd argument must match the element type of the 1st argument (%0 != %1)">;
1137711376
def err_builtin_matrix_store_to_const: Error<

clang/lib/Sema/SemaChecking.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16749,7 +16749,7 @@ static bool checkMathBuiltinElementType(Sema &S, SourceLocation Loc,
1674916749
QualType Ty) {
1675016750
if (!Ty->getAs<VectorType>() && !ConstantMatrixType::isValidElementType(Ty)) {
1675116751
S.Diag(Loc, diag::err_builtin_invalid_arg_type)
16752-
<< 1 << "vector, integer or floating point type" << Ty;
16752+
<< 1 << /* vector, integer or float ty*/ 0 << Ty;
1675316753
return true;
1675416754
}
1675516755
return false;
@@ -16797,7 +16797,8 @@ ExprResult Sema::SemaBuiltinMatrixTranspose(CallExpr *TheCall,
1679716797

1679816798
auto *MType = Matrix->getType()->getAs<ConstantMatrixType>();
1679916799
if (!MType) {
16800-
Diag(Matrix->getBeginLoc(), diag::err_builtin_matrix_arg);
16800+
Diag(Matrix->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16801+
<< 1 << /* matrix ty*/ 1 << Matrix->getType();
1680116802
return ExprError();
1680216803
}
1680316804

@@ -16868,15 +16869,16 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
1686816869
auto *PtrTy = PtrExpr->getType()->getAs<PointerType>();
1686916870
QualType ElementTy;
1687016871
if (!PtrTy) {
16871-
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
16872-
<< PtrArgIdx + 1;
16872+
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16873+
<< PtrArgIdx + 1 << /*pointer to element ty*/ 2 << PtrExpr->getType();
1687316874
ArgError = true;
1687416875
} else {
1687516876
ElementTy = PtrTy->getPointeeType().getUnqualifiedType();
1687616877

1687716878
if (!ConstantMatrixType::isValidElementType(ElementTy)) {
16878-
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
16879-
<< PtrArgIdx + 1;
16879+
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16880+
<< PtrArgIdx + 1 << /* pointer to element ty*/ 2
16881+
<< PtrExpr->getType();
1688016882
ArgError = true;
1688116883
}
1688216884
}
@@ -16975,7 +16977,8 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
1697516977

1697616978
auto *MatrixTy = MatrixExpr->getType()->getAs<ConstantMatrixType>();
1697716979
if (!MatrixTy) {
16978-
Diag(MatrixExpr->getBeginLoc(), diag::err_builtin_matrix_arg) << 0;
16980+
Diag(MatrixExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16981+
<< 1 << /*matrix ty */ 1 << MatrixExpr->getType();
1697916982
ArgError = true;
1698016983
}
1698116984

@@ -16994,8 +16997,8 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
1699416997
// Check pointer argument.
1699516998
auto *PtrTy = PtrExpr->getType()->getAs<PointerType>();
1699616999
if (!PtrTy) {
16997-
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
16998-
<< PtrArgIdx + 1;
17000+
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
17001+
<< PtrArgIdx + 1 << /*pointer to element ty*/ 2 << PtrExpr->getType();
1699917002
ArgError = true;
1700017003
} else {
1700117004
QualType ElementTy = PtrTy->getPointeeType();

0 commit comments

Comments
 (0)