Skip to content

Commit d23255c

Browse files
committed
[gwp_asan] Use anonymous namespace for test helper code
Tests can be at top-level or inside an anonymous namespace, doesn't matter. But putting their helper code inside anonymous namespaces both makes the code compatible with compiling using -Wmissing-declarations and might let the compiler optimize the test good a bit better.
1 parent 9d97c5f commit d23255c

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

compiler-rt/lib/gwp_asan/tests/compression.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace gwp_asan {
1313
namespace compression {
14+
namespace {
1415

1516
TEST(GwpAsanCompressionTest, SingleByteVarInt) {
1617
uint8_t Compressed[1];
@@ -263,5 +264,7 @@ TEST(GwpAsanCompressionTest, CompressPartiallySucceedsWithTooSmallBuffer) {
263264
EXPECT_EQ(pack(Uncompressed, 3u, Compressed, 6u), 5u);
264265
EXPECT_EQ(pack(Uncompressed, 3u, Compressed, 3 * kBytesForLargestVarInt), 5u);
265266
}
267+
268+
} // namespace
266269
} // namespace compression
267270
} // namespace gwp_asan

compiler-rt/lib/gwp_asan/tests/slot_reuse.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include <set>
10+
911
#include "gwp_asan/tests/harness.h"
1012

11-
#include <set>
13+
namespace {
1214

1315
void singleByteGoodAllocDealloc(gwp_asan::GuardedPoolAllocator *GPA) {
1416
void *Ptr = GPA->allocate(1);
@@ -72,3 +74,5 @@ TEST_F(CustomGuardedPoolAllocator, NoReuseBeforeNecessary129) {
7274
InitNumSlots(kPoolSize);
7375
runNoReuseBeforeNecessary(&GPA, kPoolSize);
7476
}
77+
78+
} // namespace

compiler-rt/lib/gwp_asan/tests/thread_contention.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <thread>
1616
#include <vector>
1717

18+
namespace {
19+
1820
void asyncTask(gwp_asan::GuardedPoolAllocator *GPA,
1921
std::atomic<bool> *StartingGun, unsigned NumIterations) {
2022
while (!*StartingGun) {
@@ -63,3 +65,5 @@ TEST_F(CustomGuardedPoolAllocator, ThreadContention) {
6365
InitNumSlots(NumThreads);
6466
runThreadContentionTest(NumThreads, NumIterations, &GPA);
6567
}
68+
69+
} // namespace

0 commit comments

Comments
 (0)