[clang] [clang][bytecode][NFC] Replace a getExpr call with getSource (PR #236402)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 28 05:37:37 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/236402
To match the pattern we usually use. Also rename CheckBitcastType.
>From eba6e40dd0347186d1fecb331ffbc58dc1b48f18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Wed, 28 Oct 2026 13:35:15 +0100
Subject: [PATCH] [clang][bytecode][NFC] Replace a getExpr call with getSource
To match the pattern we usually use. Also rename CheckBitcastType.
---
.../lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 7895c4b62ae895..23607a3ba35528 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -252,7 +252,7 @@ static bool enumeratePointerFields(const Pointer &P, const Context &Ctx,
//
// NOTE: This is a version of checkBitCastConstexprEligibilityType() in
// ExprConstant.cpp.
-static bool CheckBitcastType(InterpState &S, CodePtr OpPC, QualType T,
+static bool checkBitcastType(InterpState &S, CodePtr OpPC, QualType T,
bool IsToType) {
enum {
E_Union = 0,
@@ -297,20 +297,20 @@ static bool CheckBitcastType(InterpState &S, CodePtr OpPC, QualType T,
if (const RecordDecl *RD = T->getAsRecordDecl()) {
if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
for (const CXXBaseSpecifier &BS : CXXRD->bases()) {
- if (!CheckBitcastType(S, OpPC, BS.getType(), IsToType))
+ if (!checkBitcastType(S, OpPC, BS.getType(), IsToType))
return note(C_Base, BS.getType(), BS.getBeginLoc());
}
}
for (const FieldDecl *FD : RD->fields()) {
if (FD->getType()->isReferenceType())
return diag(E_Reference);
- if (!CheckBitcastType(S, OpPC, FD->getType(), IsToType))
+ if (!checkBitcastType(S, OpPC, FD->getType(), IsToType))
return note(C_Member, FD->getType(), FD->getSourceRange());
}
}
if (T->isArrayType() &&
- !CheckBitcastType(S, OpPC, S.getASTContext().getBaseElementType(T),
+ !checkBitcastType(S, OpPC, S.getASTContext().getBaseElementType(T),
IsToType))
return false;
@@ -326,8 +326,8 @@ static bool CheckBitcastType(InterpState &S, CodePtr OpPC, QualType T,
// so its layout is unspecified. For now, we'll simply treat these cases
// as unsupported (this should only be possible with OpenCL bool vectors
// whose element count isn't a multiple of the byte size).
- const Expr *E = S.Current->getExpr(OpPC);
- S.FFDiag(E, diag::note_constexpr_bit_cast_invalid_vector)
+ S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_bit_cast_invalid_vector)
<< QualType(VT, 0) << EltSize << NElts << ASTCtx.getCharWidth();
return false;
}
@@ -432,7 +432,7 @@ bool clang::interp::DoBitCast(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
BitcastBuffer Buffer(FullBitWidth);
size_t BuffSize = FullBitWidth.roundToBytes();
QualType DataType = Ptr.getType();
- if (!CheckBitcastType(S, OpPC, DataType, /*IsToType=*/false))
+ if (!checkBitcastType(S, OpPC, DataType, /*IsToType=*/false))
return false;
bool Success = readPointerToBuffer(S.getContext(), Ptr, Buffer,
@@ -470,9 +470,9 @@ bool clang::interp::DoBitCastPtr(InterpState &S, CodePtr OpPC,
QualType FromType = FromPtr.getFieldDesc()->getDataType(S.getASTContext());
QualType ToType = ToPtr.getFieldDesc()->getDataType(S.getASTContext());
- if (!CheckBitcastType(S, OpPC, ToType, /*IsToType=*/true))
+ if (!checkBitcastType(S, OpPC, ToType, /*IsToType=*/true))
return false;
- if (!CheckBitcastType(S, OpPC, FromType, /*IsToType=*/false))
+ if (!checkBitcastType(S, OpPC, FromType, /*IsToType=*/false))
return false;
const ASTContext &ASTCtx = S.getASTContext();
More information about the cfe-commits
mailing list