[clang] [clang][bytecode] Make Scope::Desc const (PR #219775)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 29 23:57:38 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
We use const pointers to descriptors everywhere else.
---
Full diff: https://github.com/llvm/llvm-project/pull/219775.diff
5 Files Affected:
- (modified) clang/lib/AST/ByteCode/ByteCodeEmitter.cpp (+2-2)
- (modified) clang/lib/AST/ByteCode/ByteCodeEmitter.h (+1-1)
- (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+2-2)
- (modified) clang/lib/AST/ByteCode/EvalEmitter.h (+1-1)
- (modified) clang/lib/AST/ByteCode/Function.h (+2-2)
``````````diff
diff --git a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
index f04478eb6ac16..a8806b7358bec 100644
--- a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
@@ -89,11 +89,11 @@ void ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl,
Func->setIsFullyCompiled(true);
}
-Scope::Local ByteCodeEmitter::createLocal(Descriptor *D) {
+Scope::Local ByteCodeEmitter::createLocal(const Descriptor *D) {
NextLocalOffset += sizeof(Block);
unsigned Location = NextLocalOffset;
NextLocalOffset += align(Block::InlineDescMD + D->getAllocSize());
- return {Location, D};
+ return {D, Location};
}
void ByteCodeEmitter::emitLabel(LabelTy Label) {
diff --git a/clang/lib/AST/ByteCode/ByteCodeEmitter.h b/clang/lib/AST/ByteCode/ByteCodeEmitter.h
index 34342e53837b9..24244520645d7 100644
--- a/clang/lib/AST/ByteCode/ByteCodeEmitter.h
+++ b/clang/lib/AST/ByteCode/ByteCodeEmitter.h
@@ -70,7 +70,7 @@ class ByteCodeEmitter {
bool checkingForUndefinedBehavior() const { return false; }
/// Callback for local registration.
- Local createLocal(Descriptor *D);
+ Local createLocal(const Descriptor *D);
/// Parameter indices.
llvm::DenseMap<const ParmVarDecl *, FuncParam> Params;
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 3afc864fbfd51..9d38113ce77c2 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -149,7 +149,7 @@ void EvalEmitter::emitLabel(LabelTy Label) { CurrentLabel = Label; }
EvalEmitter::LabelTy EvalEmitter::getLabel() { return NextLabel++; }
-Scope::Local EvalEmitter::createLocal(Descriptor *D) {
+Scope::Local EvalEmitter::createLocal(const Descriptor *D) {
// Allocate memory for a local.
auto Memory = std::make_unique<char[]>(sizeof(Block) + D->getAllocSize() +
Block::InlineDescMD);
@@ -170,7 +170,7 @@ Scope::Local EvalEmitter::createLocal(Descriptor *D) {
// Register the local.
unsigned Off = Locals.size();
Locals.push_back(std::move(Memory));
- return {Off, D};
+ return {D, Off};
}
bool EvalEmitter::jumpTrue(const LabelTy &Label, SourceInfo SI) {
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h b/clang/lib/AST/ByteCode/EvalEmitter.h
index 26bb22a71a3ce..e005706ad857b 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -100,7 +100,7 @@ class EvalEmitter : public SourceMapper {
}
/// Callback for registering a local.
- Local createLocal(Descriptor *D);
+ Local createLocal(const Descriptor *D);
/// Parameter indices.
llvm::DenseMap<const ParmVarDecl *, FuncParam> Params;
diff --git a/clang/lib/AST/ByteCode/Function.h b/clang/lib/AST/ByteCode/Function.h
index 9742a16b50f2c..05cddfdeecb62 100644
--- a/clang/lib/AST/ByteCode/Function.h
+++ b/clang/lib/AST/ByteCode/Function.h
@@ -37,10 +37,10 @@ class Scope final {
public:
/// Information about a local's storage.
struct Local {
+ /// Descriptor of the local.
+ const Descriptor *Desc;
/// Offset of the local in frame.
unsigned Offset;
- /// Descriptor of the local.
- Descriptor *Desc;
/// If the cleanup for this local should be emitted.
bool EnabledByDefault = true;
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/219775
More information about the cfe-commits
mailing list