Skip to content

Commit 4d59552

Browse files
authored
[NFC][YAML][IR] Output CfiFunction sorted (#130379)
As-is it's NFC, as internally `CfiFunction*` are std::set<>. We are changing internals of `CfiFunctionDefs` and `CfiFunctionDecls` so they will be ordered by GUID. Sorting by name is unnecessary but good for readability and tests.
1 parent c4ed0ad commit 4d59552

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/include/llvm/IR/ModuleSummaryIndexYAML.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#ifndef LLVM_IR_MODULESUMMARYINDEXYAML_H
1010
#define LLVM_IR_MODULESUMMARYINDEXYAML_H
1111

12+
#include "llvm/ADT/StringRef.h"
1213
#include "llvm/IR/ModuleSummaryIndex.h"
1314
#include "llvm/Support/YAMLTraits.h"
15+
#include <algorithm>
1416

1517
namespace llvm {
1618
namespace yaml {
@@ -345,11 +347,13 @@ template <> struct MappingTraits<ModuleSummaryIndex> {
345347
index.WithGlobalValueDeadStripping);
346348

347349
if (io.outputting()) {
348-
std::vector<std::string> CfiFunctionDefs(index.CfiFunctionDefs.begin(),
349-
index.CfiFunctionDefs.end());
350+
std::vector<StringRef> CfiFunctionDefs(index.CfiFunctionDefs.begin(),
351+
index.CfiFunctionDefs.end());
352+
std::sort(CfiFunctionDefs.begin(), CfiFunctionDefs.end());
350353
io.mapOptional("CfiFunctionDefs", CfiFunctionDefs);
351-
std::vector<std::string> CfiFunctionDecls(index.CfiFunctionDecls.begin(),
352-
index.CfiFunctionDecls.end());
354+
std::vector<StringRef> CfiFunctionDecls(index.CfiFunctionDecls.begin(),
355+
index.CfiFunctionDecls.end());
356+
std::sort(CfiFunctionDecls.begin(), CfiFunctionDecls.end());
353357
io.mapOptional("CfiFunctionDecls", CfiFunctionDecls);
354358
} else {
355359
std::vector<std::string> CfiFunctionDefs;

0 commit comments

Comments
 (0)