[clang] Remove warnings from -Wchar-subscripts for known positive constants (PR #69061)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 2 12:55:45 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff e6c0e8565cb05d5884de294b546dac85bc11b497 b46d376e803bae29231e313a623f508e22e6c9d6 -- clang/test/Sema/warn-char-subscripts.cpp clang/lib/Sema/SemaExpr.cpp clang/test/Sema/warn-char-subscripts.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5c84c8ff146a..aa6f6664d1da 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8612,15 +8612,14 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
// For OpenCL, when the number of initializers is a single value,
// it will be replicated to all components of the vector.
if (getLangOpts().OpenCL &&
- VTy->getVectorKind() == VectorType::GenericVector &&
- numExprs == 1) {
- QualType ElemTy = VTy->getElementType();
- ExprResult Literal = DefaultLvalueConversion(exprs[0]);
- if (Literal.isInvalid())
- return ExprError();
- Literal = ImpCastExprToType(Literal.get(), ElemTy,
- PrepareScalarCast(Literal, ElemTy));
- return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.get());
+ VTy->getVectorKind() == VectorType::GenericVector && numExprs == 1) {
+ QualType ElemTy = VTy->getElementType();
+ ExprResult Literal = DefaultLvalueConversion(exprs[0]);
+ if (Literal.isInvalid())
+ return ExprError();
+ Literal = ImpCastExprToType(Literal.get(), ElemTy,
+ PrepareScalarCast(Literal, ElemTy));
+ return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.get());
}
initExprs.append(exprs, exprs + numExprs);
@@ -11078,9 +11077,9 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
// AltiVec-style "vector bool op vector bool" combinations are allowed
// for some operators but not others.
- if (!AllowBothBool &&
- LHSVecType && LHSVecType->getVectorKind() == VectorType::AltiVecBool &&
- RHSVecType && RHSVecType->getVectorKind() == VectorType::AltiVecBool)
+ if (!AllowBothBool && LHSVecType &&
+ LHSVecType->getVectorKind() == VectorType::AltiVecBool && RHSVecType &&
+ RHSVecType->getVectorKind() == VectorType::AltiVecBool)
return ReportInvalid ? InvalidOperands(Loc, LHS, RHS) : QualType();
// This operation may not be performed on boolean vectors.
@@ -14864,8 +14863,8 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
(ResType->castAs<VectorType>()->getVectorKind() !=
VectorType::AltiVecBool)) {
// The z vector extensions allow ++ and -- for non-bool vectors.
- } else if(S.getLangOpts().OpenCL && ResType->isVectorType() &&
- ResType->castAs<VectorType>()->getElementType()->isIntegerType()) {
+ } else if (S.getLangOpts().OpenCL && ResType->isVectorType() &&
+ ResType->castAs<VectorType>()->getElementType()->isIntegerType()) {
// OpenCL V1.2 6.3 says dec/inc ops operate on integer vector types.
} else {
S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
@@ -16354,7 +16353,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
// The z vector extensions don't allow + or - with bool vectors.
(!Context.getLangOpts().ZVector ||
resultType->castAs<VectorType>()->getVectorKind() !=
- VectorType::AltiVecBool))
+ VectorType::AltiVecBool))
break;
else if (resultType->isSveVLSBuiltinType()) // SVE vectors allow + and -
break;
``````````
</details>
https://github.com/llvm/llvm-project/pull/69061
More information about the cfe-commits
mailing list