Skip to content

Commit d7fbad0

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
1 parent a9a0ea9 commit d7fbad0

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
@@ -11304,7 +11304,9 @@ def err_builtin_launder_invalid_arg : Error<
1130411304
"'__builtin_launder' is not allowed">;
1130511305

1130611306
def err_builtin_invalid_arg_type: Error <
11307-
"%ordinal0 argument must be a %1 (was %2)">;
11307+
"%ordinal0 argument must be a "
11308+
"%select{vector, integer or floating point type|matrix|"
11309+
"pointer to a valid matrix element type}1 (was %2)">;
1130811310

1130911311
def err_builtin_matrix_disabled: Error<
1131011312
"matrix types extension is disabled. Pass -fenable-matrix to enable it">;
@@ -11318,11 +11320,8 @@ def err_matrix_separate_incomplete_index: Error<
1131811320
"matrix row and column subscripts cannot be separated by any expression">;
1131911321
def err_matrix_subscript_comma: Error<
1132011322
"comma expressions are not allowed as indices in matrix subscript expressions">;
11321-
def err_builtin_matrix_arg: Error<"1st argument must be a matrix">;
1132211323
def err_builtin_matrix_scalar_unsigned_arg: Error<
1132311324
"%0 argument must be a constant unsigned integer expression">;
11324-
def err_builtin_matrix_pointer_arg: Error<
11325-
"%ordinal0 argument must be a pointer to a valid matrix element type">;
1132611325
def err_builtin_matrix_pointer_arg_mismatch: Error<
1132711326
"the pointee of the 2nd argument must match the element type of the 1st argument (%0 != %1)">;
1132811327
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
@@ -16530,7 +16530,7 @@ static bool checkMathBuiltinElementType(Sema &S, SourceLocation Loc,
1653016530
QualType Ty) {
1653116531
if (!Ty->getAs<VectorType>() && !ConstantMatrixType::isValidElementType(Ty)) {
1653216532
S.Diag(Loc, diag::err_builtin_invalid_arg_type)
16533-
<< 1 << "vector, integer or floating point type" << Ty;
16533+
<< 1 << /* vector, integer or float ty*/ 0 << Ty;
1653416534
return true;
1653516535
}
1653616536
return false;
@@ -16578,7 +16578,8 @@ ExprResult Sema::SemaBuiltinMatrixTranspose(CallExpr *TheCall,
1657816578

1657916579
auto *MType = Matrix->getType()->getAs<ConstantMatrixType>();
1658016580
if (!MType) {
16581-
Diag(Matrix->getBeginLoc(), diag::err_builtin_matrix_arg);
16581+
Diag(Matrix->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16582+
<< 1 << /* matrix ty*/ 1 << Matrix->getType();
1658216583
return ExprError();
1658316584
}
1658416585

@@ -16649,15 +16650,16 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
1664916650
auto *PtrTy = PtrExpr->getType()->getAs<PointerType>();
1665016651
QualType ElementTy;
1665116652
if (!PtrTy) {
16652-
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
16653-
<< PtrArgIdx + 1;
16653+
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16654+
<< PtrArgIdx + 1 << /*pointer to element ty*/ 2 << PtrExpr->getType();
1665416655
ArgError = true;
1665516656
} else {
1665616657
ElementTy = PtrTy->getPointeeType().getUnqualifiedType();
1665716658

1665816659
if (!ConstantMatrixType::isValidElementType(ElementTy)) {
16659-
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
16660-
<< PtrArgIdx + 1;
16660+
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16661+
<< PtrArgIdx + 1 << /* pointer to element ty*/ 2
16662+
<< PtrExpr->getType();
1666116663
ArgError = true;
1666216664
}
1666316665
}
@@ -16756,7 +16758,8 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
1675616758

1675716759
auto *MatrixTy = MatrixExpr->getType()->getAs<ConstantMatrixType>();
1675816760
if (!MatrixTy) {
16759-
Diag(MatrixExpr->getBeginLoc(), diag::err_builtin_matrix_arg) << 0;
16761+
Diag(MatrixExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16762+
<< 1 << /*matrix ty */ 1 << MatrixExpr->getType();
1676016763
ArgError = true;
1676116764
}
1676216765

@@ -16775,8 +16778,8 @@ ExprResult Sema::SemaBuiltinMatrixColumnMajorStore(CallExpr *TheCall,
1677516778
// Check pointer argument.
1677616779
auto *PtrTy = PtrExpr->getType()->getAs<PointerType>();
1677716780
if (!PtrTy) {
16778-
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
16779-
<< PtrArgIdx + 1;
16781+
Diag(PtrExpr->getBeginLoc(), diag::err_builtin_invalid_arg_type)
16782+
<< PtrArgIdx + 1 << /*pointer to element ty*/ 2 << PtrExpr->getType();
1678016783
ArgError = true;
1678116784
} else {
1678216785
QualType ElementTy = PtrTy->getPointeeType();

0 commit comments

Comments
 (0)