Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
VectorKind::Generic);
}

QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize,
QualType Sema::BuildExtVectorType(QualType T, Expr *SizeExpr,
SourceLocation AttrLoc) {
// Unlike gcc's vector_size attribute, we do not allow vectors to be defined
// in conjunction with complex types (pointers, arrays, functions, etc.).
Expand All @@ -2422,40 +2422,40 @@ QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize,
BIT && CheckBitIntElementType(*this, AttrLoc, BIT))
return QualType();

if (!ArraySize->isTypeDependent() && !ArraySize->isValueDependent()) {
std::optional<llvm::APSInt> vecSize =
ArraySize->getIntegerConstantExpr(Context);
if (!vecSize) {
if (!SizeExpr->isTypeDependent() && !SizeExpr->isValueDependent()) {
std::optional<llvm::APSInt> VecSize =
SizeExpr->getIntegerConstantExpr(Context);
if (!VecSize) {
Diag(AttrLoc, diag::err_attribute_argument_type)
<< "ext_vector_type" << AANT_ArgumentIntegerConstant
<< ArraySize->getSourceRange();
<< "ext_vector_type" << AANT_ArgumentIntegerConstant
<< SizeExpr->getSourceRange();
return QualType();
}

if (vecSize->isNegative()) {
Diag(ArraySize->getExprLoc(), diag::err_attribute_vec_negative_size);
if (VecSize->isNegative()) {
Diag(SizeExpr->getExprLoc(), diag::err_attribute_vec_negative_size);
return QualType();
}

if (!vecSize->isIntN(32)) {
if (!VecSize->isIntN(32)) {
Diag(AttrLoc, diag::err_attribute_size_too_large)
<< ArraySize->getSourceRange() << "vector";
<< SizeExpr->getSourceRange() << "vector";
return QualType();
}
// Unlike gcc's vector_size attribute, the size is specified as the
// number of elements, not the number of bytes.
unsigned vectorSize = static_cast<unsigned>(vecSize->getZExtValue());
unsigned VectorSize = static_cast<unsigned>(VecSize->getZExtValue());

if (vectorSize == 0) {
if (VectorSize == 0) {
Diag(AttrLoc, diag::err_attribute_zero_size)
<< ArraySize->getSourceRange() << "vector";
<< SizeExpr->getSourceRange() << "vector";
return QualType();
}

return Context.getExtVectorType(T, vectorSize);
return Context.getExtVectorType(T, VectorSize);
}

return Context.getDependentSizedExtVectorType(T, ArraySize, AttrLoc);
return Context.getDependentSizedExtVectorType(T, SizeExpr, AttrLoc);
}

QualType Sema::BuildMatrixType(QualType ElementTy, Expr *NumRows, Expr *NumCols,
Expand Down