[llvm] [NFC][YAML] Replace iterators with simple getter (PR #130449)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 8 16:21:18 PST 2025


https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/130449

To simplify #130382.


>From d70589646f0a33f81b2aab135d0f4c0f28136b55 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 8 Mar 2025 16:21:03 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/include/llvm/IR/ModuleSummaryIndex.h     | 2 ++
 llvm/include/llvm/IR/ModuleSummaryIndexYAML.h | 6 ++----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 2183675d84e84..396a3fddf4f6b 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1324,6 +1324,8 @@ class CfiFunctionIndex {
     return Index.end();
   }
 
+  std::vector<StringRef> symbols() const { return {begin(), end()}; }
+
   GUIDIterator guid_begin() const { return GUIDIterator(Index.begin()); }
   GUIDIterator guid_end() const { return GUIDIterator(Index.end()); }
   iterator_range<GUIDIterator> guids() const {
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
index b662013d1f998..d5a91763a981c 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
@@ -347,12 +347,10 @@ template <> struct MappingTraits<ModuleSummaryIndex> {
                    index.WithGlobalValueDeadStripping);
 
     if (io.outputting()) {
-      std::vector<StringRef> CfiFunctionDefs(index.CfiFunctionDefs.begin(),
-                                             index.CfiFunctionDefs.end());
+      auto CfiFunctionDefs = index.CfiFunctionDefs.symbols();
       llvm::sort(CfiFunctionDefs);
       io.mapOptional("CfiFunctionDefs", CfiFunctionDefs);
-      std::vector<StringRef> CfiFunctionDecls(index.CfiFunctionDecls.begin(),
-                                              index.CfiFunctionDecls.end());
+      auto CfiFunctionDecls(index.CfiFunctionDecls.symbols());
       llvm::sort(CfiFunctionDecls);
       io.mapOptional("CfiFunctionDecls", CfiFunctionDecls);
     } else {



More information about the llvm-commits mailing list