Skip to content

Commit 0464f2e

Browse files
committed
enhance; add documentation
1 parent 6a687d7 commit 0464f2e

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12519,13 +12519,31 @@ def err_builtin_is_within_lifetime_invalid_arg : Error<
1251912519
"%select{non-|function }0pointer argument to '__builtin_is_within_lifetime' "
1252012520
"is not allowed">;
1252112521

12522+
// A multi-component builtin type diagnostic. The first component broadly
12523+
// selects a scalar or container type (scalar, vector or matrix). The second
12524+
// component selects integer types and the third component selects
12525+
// floating-point types. Any component can be left empty.
1252212526
def err_builtin_invalid_arg_type: Error<
12523-
"%ordinal0 argument must be a"
12524-
"%select{| scalar| vector| matrix| vector,| vector of| scalar or vector of}1"
12525-
"%select{| integer| signed integer| unsigned integer| 'int'|"
12526-
" pointer to a valid matrix element}2"
12527-
"%plural{0:|:%plural{0:|: or}2}3"
12528-
"%select{| floating-point}3 %plural{[0,4]:type|:types}1 (was %4)">;
12527+
"%ordinal0 argument must be a "
12528+
// First component: scalar or container types
12529+
"%select{|scalar|vector|matrix|vector of|scalar or vector of}1"
12530+
// A comma after generic vector/matrix types if there are non-empty second
12531+
// and third components, to initiate a list.
12532+
"%plural{[2,3]:%plural{0:|:%plural{0:|:,}2}3|:}1"
12533+
// A space after a non-empty first component
12534+
"%plural{0:|: }1"
12535+
// Second component: integer-like types
12536+
"%select{|integer|signed integer|unsigned integer|'int'|"
12537+
"pointer to a valid matrix element}2"
12538+
// A space after a non-empty second component
12539+
"%plural{0:|: }2"
12540+
// An 'or' if non-empty second and third components are combined
12541+
"%plural{0:|:%plural{0:|:or }2}3"
12542+
// Third component: floating-point types
12543+
"%select{|floating-point}3"
12544+
// A space after a non-empty third component
12545+
"%plural{0:|: }3"
12546+
"%plural{[0,3]:type|:types}1 (was %4)">;
1252912547

1253012548
def err_builtin_matrix_disabled: Error<
1253112549
"matrix types extension is disabled. Pass -fenable-matrix to enable it">;

clang/lib/Sema/SemaChecking.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,28 +1983,28 @@ checkMathBuiltinElementType(Sema &S, SourceLocation Loc, QualType ArgTy,
19831983
if (!ArgTy->getAs<VectorType>() &&
19841984
!ConstantMatrixType::isValidElementType(ArgTy)) {
19851985
return S.Diag(Loc, diag::err_builtin_invalid_arg_type)
1986-
<< ArgOrdinal << /* vector, */ 4 << /* integer */ 1 << /* fp */ 1
1986+
<< ArgOrdinal << /* vector */ 2 << /* integer */ 1 << /* fp */ 1
19871987
<< ArgTy;
19881988
}
19891989
break;
19901990
case Sema::EltwiseBuiltinArgTyRestriction::FloatTy:
19911991
if (!EltTy->isRealFloatingType()) {
19921992
return S.Diag(Loc, diag::err_builtin_invalid_arg_type)
1993-
<< ArgOrdinal << /* scalar or vector */ 6 << /* no int */ 0
1993+
<< ArgOrdinal << /* scalar or vector */ 5 << /* no int */ 0
19941994
<< /* floating-point */ 1 << ArgTy;
19951995
}
19961996
break;
19971997
case Sema::EltwiseBuiltinArgTyRestriction::IntegerTy:
19981998
if (!EltTy->isIntegerType()) {
19991999
return S.Diag(Loc, diag::err_builtin_invalid_arg_type)
2000-
<< ArgOrdinal << /* scalar or vector */ 6 << /* integer */ 1
2000+
<< ArgOrdinal << /* scalar or vector */ 5 << /* integer */ 1
20012001
<< /* no fp */ 0 << ArgTy;
20022002
}
20032003
break;
20042004
case Sema::EltwiseBuiltinArgTyRestriction::SignedIntOrFloatTy:
20052005
if (EltTy->isUnsignedIntegerType()) {
20062006
return S.Diag(Loc, diag::err_builtin_invalid_arg_type)
2007-
<< 1 << /* scalar or vector */ 6 << /* signed int */ 2
2007+
<< 1 << /* scalar or vector */ 5 << /* signed int */ 2
20082008
<< /* or fp */ 1 << ArgTy;
20092009
}
20102010
break;
@@ -2858,7 +2858,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
28582858

28592859
if (ElTy.isNull() || !ElTy->isFloatingType()) {
28602860
Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
2861-
<< 1 << /* vector of */ 5 << /* no int */ 0 << /* fp */ 1
2861+
<< 1 << /* vector of */ 4 << /* no int */ 0 << /* fp */ 1
28622862
<< Arg->getType();
28632863
return ExprError();
28642864
}
@@ -2888,7 +2888,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
28882888

28892889
if (ElTy.isNull() || !ElTy->isIntegerType()) {
28902890
Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
2891-
<< 1 << /* vector of */ 5 << /* int */ 1 << /* no fp */ 0
2891+
<< 1 << /* vector of */ 4 << /* int */ 1 << /* no fp */ 0
28922892
<< Arg->getType();
28932893
return ExprError();
28942894
}
@@ -15412,7 +15412,7 @@ bool Sema::BuiltinNonDeterministicValue(CallExpr *TheCall) {
1541215412
if (!TyArg->isBuiltinType() && !TyArg->isVectorType())
1541315413
return Diag(TheCall->getArg(0)->getBeginLoc(),
1541415414
diag::err_builtin_invalid_arg_type)
15415-
<< 1 << /* vector, */ 4 << /* integer */ 1 << /* fp */ 1 << TyArg;
15415+
<< 1 << /* vector */ 2 << /* integer */ 1 << /* fp */ 1 << TyArg;
1541615416

1541715417
TheCall->setType(TyArg);
1541815418
return false;

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2493,7 +2493,7 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
24932493

24942494
if (!EltTy->isIntegerType()) {
24952495
Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
2496-
<< 1 << /* scalar or vector of */ 6 << /* integer ty */ 1
2496+
<< 1 << /* scalar or vector of */ 5 << /* integer ty */ 1
24972497
<< /* no fp */ 0 << ArgTy;
24982498
return true;
24992499
}

0 commit comments

Comments
 (0)