aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Interp.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-07-18 11:20:48 +0200
committerGitHub <noreply@github.com>2025-07-18 11:20:48 +0200
commitb7660a54157fd45e6276acf35176851196f5df71 (patch)
tree0e0256d10f6308907217ee3663493122801617b7 /clang/lib/AST/ByteCode/Interp.cpp
parent3bb4355bb83692d9c859043076db16baa86431e1 (diff)
downloadllvm-b7660a54157fd45e6276acf35176851196f5df71.zip
llvm-b7660a54157fd45e6276acf35176851196f5df71.tar.gz
llvm-b7660a54157fd45e6276acf35176851196f5df71.tar.bz2
[clang][bytecode] Fix const-in-mutable fields (#149286)
For mutable and const fields, we have two bits in InlineDescriptor, which both get inherited down the hierarchy. When a field is both const and mutable, we CAN read from it if it is a mutable-in-const field, but we _can't_ read from it if it is a const-in-mutable field. We need another bit to distinguish the two cases.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Interp.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index e8b5194..df5e3be 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -566,7 +566,10 @@ bool CheckDowncast(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
bool CheckConst(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
assert(Ptr.isLive() && "Pointer is not live");
- if (!Ptr.isConst() || Ptr.isMutable())
+ if (!Ptr.isConst())
+ return true;
+
+ if (Ptr.isMutable() && !Ptr.isConstInMutable())
return true;
if (!Ptr.isBlockPointer())