Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

tbaederr
Copy link
Contributor

@tbaederr tbaederr commented Nov 4, 2024

The other functions like this are also const.

The other functions like this are also const.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 4, 2024

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

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

@tbaederr tbaederr merged commit fb30208 into llvm:main Nov 4, 2024
11 checks passed
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants