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) {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to