[clang] [clang][bytecode] Improve error detection in BitCastPrim op (PR #158575)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 15 01:35:51 PDT 2025
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 origin/main HEAD --extensions cpp,h -- clang/lib/AST/ByteCode/Compiler.cpp clang/lib/AST/ByteCode/Interp.h clang/test/AST/ByteCode/builtin-bit-cast.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 75b3e2254..1ab89d73a 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -7394,7 +7394,8 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
uint32_t ResultBitWidth = std::max(Ctx.getBitWidth(ToType), 8u);
if (!this->emitBitCastPrim(*ToT, ToTypeIsUChar || ToType->isStdByteType(),
- ResultBitWidth, TargetSemantics, ToType.getTypePtr(), E))
+ ResultBitWidth, TargetSemantics,
+ ToType.getTypePtr(), E))
return false;
if (DiscardResult)
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 7b9783398..b15281b65 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -3569,8 +3569,7 @@ bool InvalidNewDeleteExpr(InterpState &S, CodePtr OpPC, const Expr *E);
template <PrimType Name, class T = typename PrimConv<Name>::T>
inline bool BitCastPrim(InterpState &S, CodePtr OpPC, bool TargetIsUCharOrByte,
- uint32_t ResultBitWidth,
- const llvm::fltSemantics *Sem,
+ uint32_t ResultBitWidth, const llvm::fltSemantics *Sem,
const Type *TargetType) {
const Pointer &FromPtr = S.Stk.pop<Pointer>();
@@ -3579,16 +3578,18 @@ inline bool BitCastPrim(InterpState &S, CodePtr OpPC, bool TargetIsUCharOrByte,
if constexpr (std::is_same_v<T, Pointer>) {
if (!TargetType->isNullPtrType()) {
- S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_bit_cast_invalid_type)
- << /*IsToType=*/true << /*IsReference=*/false << 1/*Pointer*/;
+ S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_bit_cast_invalid_type)
+ << /*IsToType=*/true << /*IsReference=*/false << 1 /*Pointer*/;
return false;
}
// The only pointer type we can validly bitcast to is nullptr_t.
S.Stk.push<Pointer>();
return true;
} else if constexpr (std::is_same_v<T, MemberPointer>) {
- S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_bit_cast_invalid_type)
- << /*IsToType=*/true << /*IsReference=*/false << 2/*MemberPointer*/;
+ S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_bit_cast_invalid_type)
+ << /*IsToType=*/true << /*IsReference=*/false << 2 /*MemberPointer*/;
return false;
} else {
``````````
</details>
https://github.com/llvm/llvm-project/pull/158575
More information about the cfe-commits
mailing list