aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-07-18 11:10:57 +0200
committerGitHub <noreply@github.com>2025-07-18 11:10:57 +0200
commit3bb4355bb83692d9c859043076db16baa86431e1 (patch)
treece0372ea5ff4a44d2d314dea9cd46cd153eab9b3 /clang/lib/AST/ByteCode
parent0b7a95a6fd81b31634a3723a0bea6d9d91bbc230 (diff)
downloadllvm-3bb4355bb83692d9c859043076db16baa86431e1.zip
llvm-3bb4355bb83692d9c859043076db16baa86431e1.tar.gz
llvm-3bb4355bb83692d9c859043076db16baa86431e1.tar.bz2
[clang][bytecode] Report mutable reads when copying unions (#149320)
Diffstat (limited to 'clang/lib/AST/ByteCode')
-rw-r--r--clang/lib/AST/ByteCode/InterpBuiltin.cpp2
-rw-r--r--clang/lib/AST/ByteCode/InterpFrame.cpp5
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 9ce1e38..462b9a1 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2905,6 +2905,8 @@ static bool copyRecord(InterpState &S, CodePtr OpPC, const Pointer &Src,
if (!copyField(F, /*Activate=*/true))
return false;
} else {
+ if (!CheckMutable(S, OpPC, Src.atField(F.Offset)))
+ return false;
Pointer DestField = Dest.atField(F.Offset);
zeroAll(DestField);
}
diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp
index a5a4bd2..d62a4f6 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -128,6 +128,11 @@ static bool shouldSkipInBacktrace(const Function *F) {
if (FD->getDeclName().getCXXOverloadedOperator() == OO_New ||
FD->getDeclName().getCXXOverloadedOperator() == OO_Array_New)
return true;
+
+ if (const auto *MD = dyn_cast<CXXMethodDecl>(FD);
+ MD && MD->getParent()->isAnonymousStructOrUnion())
+ return true;
+
return false;
}