From 0f693ed4cd03fdfc9697270c4ba6b0a19842faba Mon Sep 17 00:00:00 2001 From: Wenju He Date: Thu, 11 Dec 2025 10:39:20 +0100 Subject: [PATCH] [NFC][libclc] Fix coverity issue: Creating temporary of type llvm::SmallDenseMap ...(TypeReplacements) --- .../libclc-remangler/LibclcRemangler.cpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libclc/utils/libclc-remangler/LibclcRemangler.cpp b/libclc/utils/libclc-remangler/LibclcRemangler.cpp index 39528e6221156..3d6e5b5caa640 100644 --- a/libclc/utils/libclc-remangler/LibclcRemangler.cpp +++ b/libclc/utils/libclc-remangler/LibclcRemangler.cpp @@ -281,7 +281,7 @@ using Demangler = ManglingParser; class Remangler { public: Remangler(ASTContext *AST, const Node *Root, - SmallDenseMap TypeReplacements) + const SmallDenseMap &TypeReplacements) : AST(AST), Root(Root), TypeReplacements(TypeReplacements) { MangleContext.reset( ItaniumMangleContext::create(*AST, AST->getDiagnostics())); @@ -728,7 +728,7 @@ class Remangler { ASTContext *AST = nullptr; std::unique_ptr MangleContext{}; const Node *Root = nullptr; - SmallDenseMap TypeReplacements{}; + const SmallDenseMap &TypeReplacements; bool Failed = false; @@ -790,16 +790,18 @@ class TargetTypeReplacements { createRemangledTypeReplacements(); } - SmallDenseMap getParameterTypeReplacements() { + const SmallDenseMap & + getParameterTypeReplacements() const { return ParameterTypeReplacements; } - SmallDenseMap getCloneTypeReplacements() { + const SmallDenseMap & + getCloneTypeReplacements() const { return CloneTypeReplacements; } - SmallDenseMap - getRemangledCloneTypeReplacements() { + const SmallDenseMap & + getRemangledCloneTypeReplacements() const { return RemangledCloneTypeReplacements; } }; @@ -841,11 +843,11 @@ class LibCLCRemangler : public ASTConsumer { Replacements.getRemangledCloneTypeReplacements()); } - bool - createCloneFromMap(llvm::Module *M, StringRef OriginalName, - const itanium_demangle::Node *FunctionTree, - SmallDenseMap TypeReplacements, - bool CloneeTypeReplacement = false) { + bool createCloneFromMap( + llvm::Module *M, StringRef OriginalName, + const itanium_demangle::Node *FunctionTree, + const SmallDenseMap &TypeReplacements, + bool CloneeTypeReplacement = false) { Remangler ATR{ASTCtx, FunctionTree, TypeReplacements}; std::string const RemangledName = ATR.remangle();