[clang-doc] Prevent copying loop variables (NFC)

/llvm-project/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp:86:19:
error: loop variable '[Name, FileName]' creates a copy from type 'std::pair<llvm::StringRef, llvm::StringRef> const' [-Werror,-Wrange-loop-construct]
  for (const auto [Name, FileName] : Partials)
                  ^
/llvm-project/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp:86:8:
note: use reference type 'std::pair<llvm::StringRef, llvm::StringRef> const &' to prevent copying
  for (const auto [Name, FileName] : Partials)
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  &
1 error generated.
This commit is contained in:
Jie Fu 2025-05-23 09:00:19 +08:00
parent d6596482ef
commit 34e63be925

View File

@ -83,7 +83,7 @@ setupTemplate(std::unique_ptr<MustacheTemplateFile> &Template,
if (Error Err = T.takeError())
return Err;
Template = std::move(T.get());
for (const auto [Name, FileName] : Partials)
for (const auto &[Name, FileName] : Partials)
if (auto Err = Template->registerPartialFile(Name, FileName))
return Err;
return Error::success();