https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/219775
We use const pointers to descriptors everywhere else. >From 4e09931b37a8a62f815e139e195e84a9085246d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Sun, 30 Aug 2026 08:55:50 +0200 Subject: [PATCH] [clang][bytecode] Make Scope::Desc const We use const pointers to descriptors everywhere else. --- clang/lib/AST/ByteCode/ByteCodeEmitter.cpp | 4 ++-- clang/lib/AST/ByteCode/ByteCodeEmitter.h | 2 +- clang/lib/AST/ByteCode/EvalEmitter.cpp | 4 ++-- clang/lib/AST/ByteCode/EvalEmitter.h | 2 +- clang/lib/AST/ByteCode/Function.h | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) 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; }; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
