[clang] [clang][bytecode][NFC] Make Floating::bitcastToMemory const (PR #114777)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 03:50:46 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

The other functions like this are also const.

---
Full diff: https://github.com/llvm/llvm-project/pull/114777.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Floating.h (+1-1) 
- (modified) clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp (+1-1) 


``````````diff
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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/114777


More information about the cfe-commits mailing list