[clang] [clang][bytecode] Remove unused members from `EvalEmitter` (PR #186601)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 14 08:18:18 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/186601
Remove the DenseMap handling lambda paramter mappings from `EvalEmitter`. This was always unused. Remove it and use `if constexpr` to keep things compiling.
>From 1abd61c75196232981545b5c7261cb4fc3d12eba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sat, 14 Mar 2026 06:29:35 +0100
Subject: [PATCH] smaller EvalEmitter
---
clang/lib/AST/ByteCode/Compiler.cpp | 26 +++++++++++++++-----------
clang/lib/AST/ByteCode/EvalEmitter.h | 4 ----
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 13d6dcc92356d..8bbdf284b313d 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5776,10 +5776,12 @@ bool Compiler<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
if (DiscardResult)
return true;
- if (this->LambdaThisCapture.Offset > 0) {
- if (this->LambdaThisCapture.IsPtr)
- return this->emitGetThisFieldPtr(this->LambdaThisCapture.Offset, E);
- return this->emitGetPtrThisField(this->LambdaThisCapture.Offset, E);
+ if constexpr (!std::is_same_v<Emitter, EvalEmitter>) {
+ if (this->LambdaThisCapture.Offset > 0) {
+ if (this->LambdaThisCapture.IsPtr)
+ return this->emitGetThisFieldPtr(this->LambdaThisCapture.Offset, E);
+ return this->emitGetPtrThisField(this->LambdaThisCapture.Offset, E);
+ }
}
// In some circumstances, the 'this' pointer does not actually refer to the
@@ -7491,14 +7493,16 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
return this->visitDeclRef(D, E);
};
- // Lambda captures.
- if (auto It = this->LambdaCaptures.find(D);
- It != this->LambdaCaptures.end()) {
- auto [Offset, IsPtr] = It->second;
+ if constexpr (!std::is_same_v<Emitter, EvalEmitter>) {
+ // Lambda captures.
+ if (auto It = this->LambdaCaptures.find(D);
+ It != this->LambdaCaptures.end()) {
+ auto [Offset, IsPtr] = It->second;
- if (IsPtr)
- return this->emitGetThisFieldPtr(Offset, E);
- return this->emitGetPtrThisField(Offset, E);
+ if (IsPtr)
+ return this->emitGetThisFieldPtr(Offset, E);
+ return this->emitGetPtrThisField(Offset, E);
+ }
}
if (const auto *DRE = dyn_cast<DeclRefExpr>(E);
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h b/clang/lib/AST/ByteCode/EvalEmitter.h
index a9f87db5d7f8d..f5c51c5f3dfa0 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -92,10 +92,6 @@ class EvalEmitter : public SourceMapper {
/// Parameter indices.
llvm::DenseMap<const ParmVarDecl *, ParamOffset> Params;
- /// Lambda captures.
- llvm::DenseMap<const ValueDecl *, ParamOffset> LambdaCaptures;
- /// Offset of the This parameter in a lambda record.
- ParamOffset LambdaThisCapture{0, false};
/// Local descriptors.
llvm::SmallVector<SmallVector<Local, 8>, 2> Descriptors;
std::optional<SourceInfo> LocOverride = std::nullopt;
More information about the cfe-commits
mailing list