[clang] [clang][bytecode][NFC] Make Floating::bitcastToMemory const (PR #114777)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 03:50:12 PST 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/114777
The other functions like this are also const.
>From c64f8e5f8019fd83fd4a5d02c5ac29047b377354 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 4 Nov 2024 12:49:19 +0100
Subject: [PATCH] [clang][bytecode][NFC] Make Floating::bitcastToMemory const
The other functions like this are also const.
---
clang/lib/AST/ByteCode/Floating.h | 2 +-
clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Floating.h b/clang/lib/AST/ByteCode/Floating.h
index be38e6991dad75..3a874fc6f0b412 100644
--- a/clang/lib/AST/ByteCode/Floating.h
+++ b/clang/lib/AST/ByteCode/Floating.h
@@ -135,7 +135,7 @@ class Floating final {
return Floating(APFloat(Sem, API));
}
- void bitcastToMemory(std::byte *Buff) {
+ void bitcastToMemory(std::byte *Buff) const {
llvm::APInt API = F.bitcastToAPInt();
llvm::StoreIntToMemory(API, (uint8_t *)Buff, bitWidth() / 8);
}
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 8160707e8654d6..948a78f6f787e3 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -321,7 +321,7 @@ static bool readPointerToBuffer(const Context &Ctx, const Pointer &FromPtr,
// This is really just `long double` on x86, which is the only
// fundamental type with padding bytes.
if (T == PT_Float) {
- Floating &F = P.deref<Floating>();
+ const Floating &F = P.deref<Floating>();
unsigned NumBits =
llvm::APFloatBase::getSizeInBits(F.getAPFloat().getSemantics());
assert(NumBits % 8 == 0);
More information about the cfe-commits
mailing list