Skip to content

Commit 3f16ff4

Browse files
[memprof] Use static instead of anonymous namespaces (#87889)
This patch replaces anonymous namespaces with static as per LLVM Coding Standards.
1 parent a3bb9c2 commit 3f16ff4

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

llvm/lib/ProfileData/MemProf.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
namespace llvm {
1212
namespace memprof {
13-
namespace {
14-
size_t serializedSizeV0(const IndexedAllocationInfo &IAI) {
13+
static size_t serializedSizeV0(const IndexedAllocationInfo &IAI) {
1514
size_t Size = 0;
1615
// The number of frames to serialize.
1716
Size += sizeof(uint64_t);
@@ -22,15 +21,14 @@ size_t serializedSizeV0(const IndexedAllocationInfo &IAI) {
2221
return Size;
2322
}
2423

25-
size_t serializedSizeV2(const IndexedAllocationInfo &IAI) {
24+
static size_t serializedSizeV2(const IndexedAllocationInfo &IAI) {
2625
size_t Size = 0;
2726
// The CallStackId
2827
Size += sizeof(CallStackId);
2928
// The size of the payload.
3029
Size += PortableMemInfoBlock::serializedSize();
3130
return Size;
3231
}
33-
} // namespace
3432

3533
size_t IndexedAllocationInfo::serializedSize(IndexedVersion Version) const {
3634
switch (Version) {
@@ -43,8 +41,7 @@ size_t IndexedAllocationInfo::serializedSize(IndexedVersion Version) const {
4341
llvm_unreachable("unsupported MemProf version");
4442
}
4543

46-
namespace {
47-
size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
44+
static size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
4845
size_t Result = sizeof(GlobalValue::GUID);
4946
for (const IndexedAllocationInfo &N : Record.AllocSites)
5047
Result += N.serializedSize(Version0);
@@ -59,7 +56,7 @@ size_t serializedSizeV0(const IndexedMemProfRecord &Record) {
5956
return Result;
6057
}
6158

62-
size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
59+
static size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
6360
size_t Result = sizeof(GlobalValue::GUID);
6461
for (const IndexedAllocationInfo &N : Record.AllocSites)
6562
Result += N.serializedSize(Version2);
@@ -70,7 +67,6 @@ size_t serializedSizeV2(const IndexedMemProfRecord &Record) {
7067
Result += Record.CallSiteIds.size() * sizeof(CallStackId);
7168
return Result;
7269
}
73-
} // namespace
7470

7571
size_t IndexedMemProfRecord::serializedSize(IndexedVersion Version) const {
7672
switch (Version) {
@@ -83,9 +79,8 @@ size_t IndexedMemProfRecord::serializedSize(IndexedVersion Version) const {
8379
llvm_unreachable("unsupported MemProf version");
8480
}
8581

86-
namespace {
87-
void serializeV0(const IndexedMemProfRecord &Record,
88-
const MemProfSchema &Schema, raw_ostream &OS) {
82+
static void serializeV0(const IndexedMemProfRecord &Record,
83+
const MemProfSchema &Schema, raw_ostream &OS) {
8984
using namespace support;
9085

9186
endian::Writer LE(OS, llvm::endianness::little);
@@ -107,8 +102,8 @@ void serializeV0(const IndexedMemProfRecord &Record,
107102
}
108103
}
109104

110-
void serializeV2(const IndexedMemProfRecord &Record,
111-
const MemProfSchema &Schema, raw_ostream &OS) {
105+
static void serializeV2(const IndexedMemProfRecord &Record,
106+
const MemProfSchema &Schema, raw_ostream &OS) {
112107
using namespace support;
113108

114109
endian::Writer LE(OS, llvm::endianness::little);
@@ -124,7 +119,6 @@ void serializeV2(const IndexedMemProfRecord &Record,
124119
for (const auto &CSId : Record.CallSiteIds)
125120
LE.write<CallStackId>(CSId);
126121
}
127-
} // namespace
128122

129123
void IndexedMemProfRecord::serialize(const MemProfSchema &Schema,
130124
raw_ostream &OS, IndexedVersion Version) {
@@ -140,9 +134,8 @@ void IndexedMemProfRecord::serialize(const MemProfSchema &Schema,
140134
llvm_unreachable("unsupported MemProf version");
141135
}
142136

143-
namespace {
144-
IndexedMemProfRecord deserializeV0(const MemProfSchema &Schema,
145-
const unsigned char *Ptr) {
137+
static IndexedMemProfRecord deserializeV0(const MemProfSchema &Schema,
138+
const unsigned char *Ptr) {
146139
using namespace support;
147140

148141
IndexedMemProfRecord Record;
@@ -185,8 +178,8 @@ IndexedMemProfRecord deserializeV0(const MemProfSchema &Schema,
185178
return Record;
186179
}
187180

188-
IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema,
189-
const unsigned char *Ptr) {
181+
static IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema,
182+
const unsigned char *Ptr) {
190183
using namespace support;
191184

192185
IndexedMemProfRecord Record;
@@ -214,7 +207,6 @@ IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema,
214207

215208
return Record;
216209
}
217-
} // namespace
218210

219211
IndexedMemProfRecord
220212
IndexedMemProfRecord::deserialize(const MemProfSchema &Schema,

0 commit comments

Comments
 (0)