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

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 4 13:47:20 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/142851.diff


1 Files Affected:

- (modified) clang/lib/Frontend/FrontendAction.cpp (+1-1) 


``````````diff
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);
   }

``````````

</details>


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


More information about the cfe-commits mailing list