Skip to content

[Clang][NFC] Use move in std::vector local in HandleTranslationUnit #142851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

shafik
Copy link
Collaborator

@shafik shafik commented Jun 4, 2025

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.

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.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jun 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 4, 2025

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

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

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shafik shafik merged commit cd5c555 into llvm:main Jun 5, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants