[clang] Avoid copying Param and Constr (PR #65488)

Mauro Baladés via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 6 07:36:39 PDT 2023


https://github.com/mauro-balades created https://github.com/llvm/llvm-project/pull/65488:

None

>From 36748679e04ecf52877c01e6dcc8d662349d5b00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mauro=20Balad=C3=A9s?= <mauro.balades at tutanota.com>
Date: Wed, 6 Sep 2023 16:36:12 +0200
Subject: [PATCH] Avoid copying Param and Constr

---
 clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 229bf04c77fae44..6ee6e72d99ec57b 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -597,7 +597,7 @@ std::optional<Object> serializeTemplateMixinImpl(const RecordTy &Record,
 
   Object Generics;
   Array GenericParameters;
-  for (const auto Param : Template.getParameters()) {
+  for (const auto &Param : Template.getParameters()) {
     Object Parameter;
     Parameter["name"] = Param.Name;
     Parameter["index"] = Param.Index;
@@ -608,7 +608,7 @@ std::optional<Object> serializeTemplateMixinImpl(const RecordTy &Record,
     Generics["parameters"] = std::move(GenericParameters);
 
   Array GenericConstraints;
-  for (const auto Constr : Template.getConstraints()) {
+  for (const auto &Constr : Template.getConstraints()) {
     Object Constraint;
     Constraint["kind"] = Constr.Kind;
     Constraint["lhs"] = Constr.LHS;



More information about the cfe-commits mailing list