[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 16 19:31:25 PST 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 b034da7dad150a54661557cc3f712948b1e474e4 26a20b1c3594676b138395f91143356d87ec72cd -- clang/test/SemaCXX/constexpr-vectors-access-elements.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/Interp/State.h clang/test/CodeGenCXX/temporaries.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7468dc5c71..486dd41335 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2782,9 +2782,9 @@ static bool EvalAndBitcastToAPInt(EvalInfo &Info, const Expr *E,
}
unsigned BaseEltSize = EltAsInt.getBitWidth();
if (BigEndian)
- Res |= EltAsInt.zextOrTrunc(VecSize).rotr(i*EltSize+BaseEltSize);
+ Res |= EltAsInt.zextOrTrunc(VecSize).rotr(i * EltSize + BaseEltSize);
else
- Res |= EltAsInt.zextOrTrunc(VecSize).rotl(i*EltSize);
+ Res |= EltAsInt.zextOrTrunc(VecSize).rotl(i * EltSize);
}
return true;
}
@@ -3242,8 +3242,8 @@ static bool HandleLValueIndirectMember(EvalInfo &Info, const Expr *E,
}
/// Get the size of the given type in char units.
-static bool HandleSizeof(EvalInfo &Info, SourceLocation Loc,
- QualType Type, CharUnits &Size) {
+static bool HandleSizeof(EvalInfo &Info, SourceLocation Loc, QualType Type,
+ CharUnits &Size) {
// sizeof(void), __alignof__(void), sizeof(function) = 1 as a gcc
// extension.
if (Type->isVoidType() || Type->isFunctionType()) {
@@ -3872,7 +3872,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
if (Index >= ObjType->castAs<VectorType>()->getNumElements()) {
if (Info.getLangOpts().CPlusPlus11)
Info.FFDiag(E, diag::note_constexpr_access_past_end)
- << handler.AccessKind;
+ << handler.AccessKind;
else
Info.FFDiag(E);
return handler.failed();
@@ -10653,9 +10653,9 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) {
for (unsigned i = 0; i < NElts; i++) {
llvm::APInt Elt;
if (BigEndian)
- Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize);
+ Elt = SValInt.rotl(i * EltSize + EltSize).zextOrTrunc(EltSize);
else
- Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize);
+ Elt = SValInt.rotr(i * EltSize).zextOrTrunc(EltSize);
Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType())));
}
} else {
``````````
</details>
https://github.com/llvm/llvm-project/pull/72607
More information about the cfe-commits
mailing list