[clang] [Clang][NFC] Use move in std::vector local in HandleTranslationUnit (PR #142851)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 4 13:46:48 PDT 2025


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

Static analysis flagged this since we could move MergedRanges since it is a std::vector, a local and unused after that line. So there is a potential saving.

>From b427ae1ef18c48126a0faf5f40678cc6e4e30634 Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghmour at intel.com>
Date: Wed, 4 Jun 2025 13:42:45 -0700
Subject: [PATCH] [Clang][NFC] Use move in std::vector local in
 HandleTranslationUnit

Static analysis flagged this since we could move MergedRanges since it is a
std::vector, a local and unused after that line. So there is a potential saving.
---
 clang/lib/Frontend/FrontendAction.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index af9d18ab66108..ef7ae27a2694a 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -181,7 +181,7 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer,
         if (MergedRanges.back().second < It->second)
           MergedRanges.back().second = It->second;
       }
-      Result.push_back({Data.Ref->getName(), MergedRanges});
+      Result.push_back({Data.Ref->getName(), std::move(MergedRanges)});
     }
     printJson(Result);
   }



More information about the cfe-commits mailing list