aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-25 11:23:34 +0200
committerGitHub <noreply@github.com>2025-04-25 11:23:34 +0200
commit211b51e4713d814d6fa894f4fc309a364c5642ce (patch)
treec45da24e48f2aa59235f8b30bd280e2e999dd8f0 /clang/lib/AST/ByteCode/Compiler.cpp
parent5a645109c3a965dcaab08e3485f2fa505e44cde3 (diff)
downloadllvm-211b51e4713d814d6fa894f4fc309a364c5642ce.zip
llvm-211b51e4713d814d6fa894f4fc309a364c5642ce.tar.gz
llvm-211b51e4713d814d6fa894f4fc309a364c5642ce.tar.bz2
[clang][bytecode] Propagate IsVolatile bit to subobjects (#137293)
For ```c++ struct S { constexpr S(int=0) : i(1) {} int i; }; constexpr volatile S vs; ``` reading from `vs.i` is not allowed, even though `i` is not volatile qualified. Propagate the IsVolatile bit down the hierarchy, so we know reading from `vs.i` is a volatile read.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 65d87cd..3c774c1 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -364,8 +364,7 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
Desc = P.createDescriptor(SubExpr, *T);
else
Desc = P.createDescriptor(SubExpr, PointeeType.getTypePtr(),
- std::nullopt, true, false,
- /*IsMutable=*/false, nullptr);
+ std::nullopt, /*IsConst=*/true);
}
uint64_t Val = Ctx.getASTContext().getTargetNullPointerValue(CE->getType());
@@ -417,8 +416,7 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
Desc = nullptr;
else
Desc = P.createDescriptor(CE, PtrType->getPointeeType().getTypePtr(),
- Descriptor::InlineDescMD, true, false,
- /*IsMutable=*/false, nullptr);
+ Descriptor::InlineDescMD, /*IsConst=*/true);
if (!this->emitGetIntPtr(T, Desc, CE))
return false;
@@ -3400,14 +3398,13 @@ bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) {
Desc = nullptr; // We're not going to use it in this case.
else
Desc = P.createDescriptor(E, *ElemT, /*SourceTy=*/nullptr,
- Descriptor::InlineDescMD,
- /*IsConst=*/false, /*IsTemporary=*/false,
- /*IsMutable=*/false);
+ Descriptor::InlineDescMD);
} else {
Desc = P.createDescriptor(
E, ElementType.getTypePtr(),
E->isArray() ? std::nullopt : Descriptor::InlineDescMD,
- /*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false, Init);
+ /*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false,
+ /*IsVolatile=*/false, Init);
}
}
@@ -4355,7 +4352,7 @@ Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
Descriptor *D = P.createDescriptor(
Src, Ty.getTypePtr(), Descriptor::InlineDescMD, Ty.isConstQualified(),
- IsTemporary, /*IsMutable=*/false, Init);
+ IsTemporary, /*IsMutable=*/false, /*IsVolatile=*/false, Init);
if (!D)
return std::nullopt;
D->IsConstexprUnknown = IsConstexprUnknown;
@@ -4377,7 +4374,7 @@ std::optional<unsigned> Compiler<Emitter>::allocateTemporary(const Expr *E) {
Descriptor *D = P.createDescriptor(
E, Ty.getTypePtr(), Descriptor::InlineDescMD, Ty.isConstQualified(),
- /*IsTemporary=*/true, /*IsMutable=*/false, /*Init=*/nullptr);
+ /*IsTemporary=*/true);
if (!D)
return std::nullopt;