-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Clang][NFC] Use const auto & to avoid copy #138069
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 const auto & to avoid copy #138069
Conversation
Static analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying.
@llvm/pr-subscribers-clang Author: Shafik Yaghmour (shafik) ChangesStatic analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying. Full diff: https://github.com/llvm/llvm-project/pull/138069.diff 1 Files Affected:
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index a1394fd3900b0..74fe55fbe24f2 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1959,7 +1959,7 @@ void ModuleMapLoader::handleExportDecl(const modulemap::ExportDecl &ED) {
}
void ModuleMapLoader::handleExportAsDecl(const modulemap::ExportAsDecl &EAD) {
- auto ModName = EAD.Id.front();
+ const auto &ModName = EAD.Id.front();
if (!ActiveModule->ExportAsModule.empty()) {
if (ActiveModule->ExportAsModule == ModName.first) {
|
@llvm/pr-subscribers-clang-modules Author: Shafik Yaghmour (shafik) ChangesStatic analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying. Full diff: https://github.com/llvm/llvm-project/pull/138069.diff 1 Files Affected:
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index a1394fd3900b0..74fe55fbe24f2 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1959,7 +1959,7 @@ void ModuleMapLoader::handleExportDecl(const modulemap::ExportDecl &ED) {
}
void ModuleMapLoader::handleExportAsDecl(const modulemap::ExportAsDecl &EAD) {
- auto ModName = EAD.Id.front();
+ const auto &ModName = EAD.Id.front();
if (!ActiveModule->ExportAsModule.empty()) {
if (ActiveModule->ExportAsModule == ModName.first) {
|
Static analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying.
Static analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying.
Static analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying.
Static analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying.
Static analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying.
Static analysis flagged this code as causing a copy when we never modify ModName and therefore we can use const auto & and avoid copying.