[llvm] [OpenMP][NFC] Use temporary instead of local to take advantage of move semantics (PR #138582)

Shafik Yaghmour via llvm-commits llvm-commits at lists.llvm.org
Mon May 5 13:43:58 PDT 2025


https://github.com/shafik created https://github.com/llvm/llvm-project/pull/138582

Static analysis flagged `MapnamesName` because we could move it into `createOffloadMapnames`. I just replaced the local with a direct call to `createPlatformSpecificName` at the function argument location.

>From 94eb8b3aeed6fee0cc0ad7a0c9f4fd024470ceb4 Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghmour at intel.com>
Date: Mon, 5 May 2025 13:39:06 -0700
Subject: [PATCH] [OpenMP][NFC] Use temporary instead of local to take
 advantage of move semantics

Static analysis flagged MapnamesName because we could move it into
createOffloadMapnames. I just replaced the local with a direct call to
createPlatformSpecificName at the function argument location.
---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index be05f01c94603..468a4da9ac13a 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -8397,9 +8397,8 @@ Error OpenMPIRBuilder::emitOffloadingArrays(
 
   // The information types are only built if provided.
   if (!CombinedInfo.Names.empty()) {
-    std::string MapnamesName = createPlatformSpecificName({"offload_mapnames"});
-    auto *MapNamesArrayGbl =
-        createOffloadMapnames(CombinedInfo.Names, MapnamesName);
+    auto *MapNamesArrayGbl = createOffloadMapnames(
+        CombinedInfo.Names, createPlatformSpecificName({"offload_mapnames"}));
     Info.RTArgs.MapNamesArray = MapNamesArrayGbl;
     Info.EmitDebug = true;
   } else {



More information about the llvm-commits mailing list