-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][NFC] Use std::move to avoid copy #138073
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
[Clang][NFC] Use std::move to avoid copy #138073
Conversation
Static analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable.
@llvm/pr-subscribers-clang-modules @llvm/pr-subscribers-clang Author: Shafik Yaghmour (shafik) ChangesStatic analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable. Full diff: https://github.com/llvm/llvm-project/pull/138073.diff 1 Files Affected:
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index a1394fd3900b0..0b47ff5fa71f8 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -2010,7 +2010,8 @@ void ModuleMapLoader::handleConflict(const modulemap::ConflictDecl &CD) {
Conflict.Id = CD.Id;
Conflict.Message = CD.Message;
- ActiveModule->UnresolvedConflicts.push_back(Conflict);
+ // FIXME: when we move to C++20 we should consider using emplace_back
+ ActiveModule->UnresolvedConflicts.push_back(std::move(Conflict));
}
void ModuleMapLoader::handleInferredModuleDecl(
|
Static analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable.
Static analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable.
Static analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable.
Static analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable.
Static analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable.
Static analysis flagged this code for using copy when we could use std::move.
Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and avoid a local variable.