llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> The offset we return for them are just indices, so we can use a vector here. --- Full diff: https://github.com/llvm/llvm-project/pull/140513.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+2-2) - (modified) clang/lib/AST/ByteCode/EvalEmitter.h (+3-4) ``````````diff diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp index 37e8d3788a6fe..5498065657e0a 100644 --- a/clang/lib/AST/ByteCode/EvalEmitter.cpp +++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp @@ -20,7 +20,7 @@ EvalEmitter::EvalEmitter(Context &Ctx, Program &P, State &Parent, : Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx) {} EvalEmitter::~EvalEmitter() { - for (auto &[K, V] : Locals) { + for (auto &V : Locals) { Block *B = reinterpret_cast<Block *>(V.get()); if (B->isInitialized()) B->invokeDtor(); @@ -112,7 +112,7 @@ Scope::Local EvalEmitter::createLocal(Descriptor *D) { // Register the local. unsigned Off = Locals.size(); - Locals.insert({Off, std::move(Memory)}); + Locals.push_back(std::move(Memory)); return {Off, D}; } diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h b/clang/lib/AST/ByteCode/EvalEmitter.h index f9c1ff07625b8..7303adba22af7 100644 --- a/clang/lib/AST/ByteCode/EvalEmitter.h +++ b/clang/lib/AST/ByteCode/EvalEmitter.h @@ -111,12 +111,11 @@ class EvalEmitter : public SourceMapper { std::optional<PtrCallback> PtrCB; /// Temporaries which require storage. - llvm::DenseMap<unsigned, std::unique_ptr<char[]>> Locals; + llvm::SmallVector<std::unique_ptr<char[]>> Locals; Block *getLocal(unsigned Index) const { - auto It = Locals.find(Index); - assert(It != Locals.end() && "Missing local variable"); - return reinterpret_cast<Block *>(It->second.get()); + assert(Index < Locals.size()); + return reinterpret_cast<Block *>(Locals[Index].get()); } void updateGlobalTemporaries(); `````````` </details> https://github.com/llvm/llvm-project/pull/140513 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits