[clang] acc40ed - [Clang][NFC] Use const auto & to avoid copy (#138069)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 1 09:52:12 PDT 2025
Author: Shafik Yaghmour
Date: 2025-05-01T09:52:09-07:00
New Revision: acc40ed0a747ad8f5dbb93788da7ce104c36c0a3
URL: https://github.com/llvm/llvm-project/commit/acc40ed0a747ad8f5dbb93788da7ce104c36c0a3
DIFF: https://github.com/llvm/llvm-project/commit/acc40ed0a747ad8f5dbb93788da7ce104c36c0a3.diff
LOG: [Clang][NFC] Use const auto & to avoid copy (#138069)
Static analysis flagged this code as causing a copy when we never modify
ModName and therefore we can use const auto & and avoid copying.
Added:
Modified:
clang/lib/Lex/ModuleMap.cpp
Removed:
################################################################################
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) {
More information about the cfe-commits
mailing list