Skip to content

Commit 1a2db41

Browse files
committed
PR: Fix variable naming cases for variables, leave lambdas for now
1 parent a2fd8e1 commit 1a2db41

9 files changed

+166
-166
lines changed

compiler-rt/lib/radsan/radsan_context.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ using namespace __sanitizer;
2424

2525
namespace detail {
2626

27-
static pthread_key_t Key;
28-
static pthread_once_t KeyOnce = PTHREAD_ONCE_INIT;
29-
void internalFree(void *Ptr) { __sanitizer::InternalFree(Ptr); }
27+
static pthread_key_t key;
28+
static pthread_once_t key_once = PTHREAD_ONCE_INIT;
29+
void internalFree(void *ptr) { __sanitizer::InternalFree(ptr); }
3030

3131
using __radsan::Context;
3232

3333
Context &GetContextForThisThreadImpl() {
34-
auto MakeTlsKey = []() {
35-
CHECK_EQ(pthread_key_create(&detail::Key, detail::internalFree), 0);
34+
auto make_tls_key = []() {
35+
CHECK_EQ(pthread_key_create(&detail::key, detail::internalFree), 0);
3636
};
3737

38-
pthread_once(&detail::KeyOnce, MakeTlsKey);
39-
Context *CurrentThreadContext =
40-
static_cast<Context *>(pthread_getspecific(detail::Key));
41-
if (CurrentThreadContext == nullptr) {
42-
CurrentThreadContext =
38+
pthread_once(&detail::key_once, make_tls_key);
39+
Context *current_thread_context =
40+
static_cast<Context *>(pthread_getspecific(detail::key));
41+
if (current_thread_context == nullptr) {
42+
current_thread_context =
4343
static_cast<Context *>(InternalAlloc(sizeof(Context)));
44-
new (CurrentThreadContext) Context();
45-
pthread_setspecific(detail::Key, CurrentThreadContext);
44+
new (current_thread_context) Context();
45+
pthread_setspecific(detail::key, current_thread_context);
4646
}
4747

48-
return *CurrentThreadContext;
48+
return *current_thread_context;
4949
}
5050

5151
/*
@@ -70,32 +70,32 @@ namespace __radsan {
7070

7171
Context::Context() = default;
7272

73-
void Context::RealtimePush() { RealtimeDepth++; }
73+
void Context::RealtimePush() { realtime_depth++; }
7474

75-
void Context::RealtimePop() { RealtimeDepth--; }
75+
void Context::RealtimePop() { realtime_depth--; }
7676

77-
void Context::BypassPush() { BypassDepth++; }
77+
void Context::BypassPush() { bypass_depth++; }
7878

79-
void Context::BypassPop() { BypassDepth--; }
79+
void Context::BypassPop() { bypass_depth--; }
8080

81-
void Context::ExpectNotRealtime(const char *InterceptedFunctionName) {
81+
void Context::ExpectNotRealtime(const char *intercepted_function_name) {
8282
if (InRealtimeContext() && !IsBypassed()) {
8383
BypassPush();
84-
PrintDiagnostics(InterceptedFunctionName);
84+
PrintDiagnostics(intercepted_function_name);
8585
detail::InvokeViolationDetectedAction();
8686
BypassPop();
8787
}
8888
}
8989

90-
bool Context::InRealtimeContext() const { return RealtimeDepth > 0; }
90+
bool Context::InRealtimeContext() const { return realtime_depth > 0; }
9191

92-
bool Context::IsBypassed() const { return BypassDepth > 0; }
92+
bool Context::IsBypassed() const { return bypass_depth > 0; }
9393

94-
void Context::PrintDiagnostics(const char *InterceptedFunctionName) {
94+
void Context::PrintDiagnostics(const char *intercepted_function_name) {
9595
fprintf(stderr,
9696
"Real-time violation: intercepted call to real-time unsafe function "
9797
"`%s` in real-time context! Stack trace:\n",
98-
InterceptedFunctionName);
98+
intercepted_function_name);
9999
__radsan::PrintStackTrace();
100100
}
101101

compiler-rt/lib/radsan/radsan_context.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class Context {
2222
void BypassPush();
2323
void BypassPop();
2424

25-
void ExpectNotRealtime(const char *InterceptedFunctionName);
25+
void ExpectNotRealtime(const char *intercepted_function_name);
2626

2727
private:
2828
bool InRealtimeContext() const;
2929
bool IsBypassed() const;
30-
void PrintDiagnostics(const char *InterceptedFunctionName);
30+
void PrintDiagnostics(const char *intercepted_function_name);
3131

32-
int RealtimeDepth{0};
33-
int BypassDepth{0};
32+
int realtime_depth{0};
33+
int bypass_depth{0};
3434
};
3535

3636
Context &GetContextForThisThread();

compiler-rt/lib/radsan/radsan_interceptors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
using namespace __sanitizer;
4242

4343
namespace __radsan {
44-
void ExpectNotRealtime(const char *InterceptedFunctionName) {
45-
GetContextForThisThread().ExpectNotRealtime(InterceptedFunctionName);
44+
void ExpectNotRealtime(const char *intercepted_function_name) {
45+
GetContextForThisThread().ExpectNotRealtime(intercepted_function_name);
4646
}
4747
} // namespace __radsan
4848

compiler-rt/lib/radsan/radsan_interceptors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414
namespace __radsan {
1515
void InitializeInterceptors();
16-
}
16+
} // namespace __radsan

compiler-rt/lib/radsan/radsan_stack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ void SetGlobalStackTraceFormat() {
4343
using namespace __radsan;
4444
void __radsan::PrintStackTrace() {
4545

46-
BufferedStackTrace Stack{};
46+
BufferedStackTrace stack{};
4747

4848
GET_CURRENT_PC_BP;
49-
Stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal);
49+
stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal);
5050

5151
SetGlobalStackTraceFormat();
52-
Stack.Print();
52+
stack.Print();
5353
}

compiler-rt/lib/radsan/tests/radsan_test_context.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,58 @@
1313

1414
#include "radsan_context.h"
1515

16-
TEST(TestRadsanContext, CanCreateContext) { __radsan::Context Context{}; }
16+
TEST(TestRadsanContext, CanCreateContext) { __radsan::Context context{}; }
1717

1818
TEST(TestRadsanContext, ExpectNotRealtimeDoesNotDieBeforeRealtimePush) {
19-
__radsan::Context Context{};
20-
Context.ExpectNotRealtime("do_some_stuff");
19+
__radsan::Context context{};
20+
context.ExpectNotRealtime("do_some_stuff");
2121
}
2222

2323
TEST(TestRadsanContext, ExpectNotRealtimeDoesNotDieAfterPushAndPop) {
24-
__radsan::Context Context{};
25-
Context.RealtimePush();
26-
Context.RealtimePop();
27-
Context.ExpectNotRealtime("do_some_stuff");
24+
__radsan::Context context{};
25+
context.RealtimePush();
26+
context.RealtimePop();
27+
context.ExpectNotRealtime("do_some_stuff");
2828
}
2929

3030
TEST(TestRadsanContext, ExpectNotRealtimeDiesAfterRealtimePush) {
31-
__radsan::Context Context{};
31+
__radsan::Context context{};
3232

33-
Context.RealtimePush();
34-
EXPECT_DEATH(Context.ExpectNotRealtime("do_some_stuff"), "");
33+
context.RealtimePush();
34+
EXPECT_DEATH(context.ExpectNotRealtime("do_some_stuff"), "");
3535
}
3636

3737
TEST(TestRadsanContext,
3838
ExpectNotRealtimeDiesAfterRealtimeAfterMorePushesThanPops) {
39-
__radsan::Context Context{};
39+
__radsan::Context context{};
4040

41-
Context.RealtimePush();
42-
Context.RealtimePush();
43-
Context.RealtimePush();
44-
Context.RealtimePop();
45-
Context.RealtimePop();
46-
EXPECT_DEATH(Context.ExpectNotRealtime("do_some_stuff"), "");
41+
context.RealtimePush();
42+
context.RealtimePush();
43+
context.RealtimePush();
44+
context.RealtimePop();
45+
context.RealtimePop();
46+
EXPECT_DEATH(context.ExpectNotRealtime("do_some_stuff"), "");
4747
}
4848

4949
TEST(TestRadsanContext, ExpectNotRealtimeDoesNotDieAfterBypassPush) {
50-
__radsan::Context Context{};
50+
__radsan::Context context{};
5151

52-
Context.RealtimePush();
53-
Context.BypassPush();
54-
Context.ExpectNotRealtime("do_some_stuff");
52+
context.RealtimePush();
53+
context.BypassPush();
54+
context.ExpectNotRealtime("do_some_stuff");
5555
}
5656

5757
TEST(TestRadsanContext,
5858
ExpectNotRealtimeDoesNotDieIfBypassDepthIsGreaterThanZero) {
59-
__radsan::Context Context{};
59+
__radsan::Context context{};
6060

61-
Context.RealtimePush();
62-
Context.BypassPush();
63-
Context.BypassPush();
64-
Context.BypassPush();
65-
Context.BypassPop();
66-
Context.BypassPop();
67-
Context.ExpectNotRealtime("do_some_stuff");
68-
Context.BypassPop();
69-
EXPECT_DEATH(Context.ExpectNotRealtime("do_some_stuff"), "");
61+
context.RealtimePush();
62+
context.BypassPush();
63+
context.BypassPush();
64+
context.BypassPush();
65+
context.BypassPop();
66+
context.BypassPop();
67+
context.ExpectNotRealtime("do_some_stuff");
68+
context.BypassPop();
69+
EXPECT_DEATH(context.ExpectNotRealtime("do_some_stuff"), "");
7070
}

compiler-rt/lib/radsan/tests/radsan_test_functional.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ using namespace radsan_testing;
4141
using namespace std::chrono_literals;
4242

4343
TEST(TestRadsan, VectorPushBackAllocationDiesWhenRealtime) {
44-
std::vector<float> Vec{};
45-
auto Func = [&Vec]() { Vec.push_back(0.4f); };
44+
std::vector<float> vec{};
45+
auto Func = [&vec]() { vec.push_back(0.4f); };
4646
ExpectRealtimeDeath(Func);
47-
ASSERT_EQ(0u, Vec.size());
47+
ASSERT_EQ(0u, vec.size());
4848
ExpectNonRealtimeSurvival(Func);
49-
ASSERT_EQ(1u, Vec.size());
49+
ASSERT_EQ(1u, vec.size());
5050
}
5151

5252
TEST(TestRadsan, DestructionOfObjectOnHeapDiesWhenRealtime) {
53-
auto AllocatedPtr = std::make_unique<std::array<float, 256>>();
54-
auto Func = [&AllocatedPtr]() { AllocatedPtr.reset(); };
53+
auto allocated_ptr = std::make_unique<std::array<float, 256>>();
54+
auto Func = [&allocated_ptr]() { allocated_ptr.reset(); };
5555
ExpectRealtimeDeath(Func);
56-
ASSERT_NE(nullptr, AllocatedPtr.get());
56+
ASSERT_NE(nullptr, allocated_ptr.get());
5757
ExpectNonRealtimeSurvival(Func);
58-
ASSERT_EQ(nullptr, AllocatedPtr.get());
58+
ASSERT_EQ(nullptr, allocated_ptr.get());
5959
}
6060

6161
TEST(TestRadsan, SleepingAThreadDiesWhenRealtime) {
@@ -79,48 +79,48 @@ TEST(TestRadsan, OfstreamCreationDiesWhenRealtime) {
7979
}
8080

8181
TEST(TestRadsan, LockingAMutexDiesWhenRealtime) {
82-
std::mutex Mutex{};
83-
auto Func = [&]() { Mutex.lock(); };
82+
std::mutex mutex{};
83+
auto Func = [&]() { mutex.lock(); };
8484
ExpectRealtimeDeath(Func);
8585
ExpectNonRealtimeSurvival(Func);
8686
}
8787

8888
TEST(TestRadsan, UnlockingAMutexDiesWhenRealtime) {
89-
std::mutex Mutex{};
90-
Mutex.lock();
91-
auto Func = [&]() { Mutex.unlock(); };
89+
std::mutex mutex{};
90+
mutex.lock();
91+
auto Func = [&]() { mutex.unlock(); };
9292
ExpectRealtimeDeath(Func);
9393
ExpectNonRealtimeSurvival(Func);
9494
}
9595

9696
#if RADSAN_TEST_SHARED_MUTEX
9797

9898
TEST(TestRadsan, LockingASharedMutexDiesWhenRealtime) {
99-
std::shared_mutex Mutex{};
100-
auto Func = [&]() { Mutex.lock(); };
99+
std::shared_mutex mutex{};
100+
auto Func = [&]() { mutex.lock(); };
101101
ExpectRealtimeDeath(Func);
102102
ExpectNonRealtimeSurvival(Func);
103103
}
104104

105105
TEST(TestRadsan, UnlockingASharedMutexDiesWhenRealtime) {
106-
std::shared_mutex Mutex{};
107-
Mutex.lock();
108-
auto Func = [&]() { Mutex.unlock(); };
106+
std::shared_mutex mutex{};
107+
mutex.lock();
108+
auto Func = [&]() { mutex.unlock(); };
109109
ExpectRealtimeDeath(Func);
110110
ExpectNonRealtimeSurvival(Func);
111111
}
112112

113113
TEST(TestRadsan, SharedLockingASharedMutexDiesWhenRealtime) {
114-
std::shared_mutex Mutex{};
115-
auto Func = [&]() { Mutex.lock_shared(); };
114+
std::shared_mutex mutex{};
115+
auto Func = [&]() { mutex.lock_shared(); };
116116
ExpectRealtimeDeath(Func);
117117
ExpectNonRealtimeSurvival(Func);
118118
}
119119

120120
TEST(TestRadsan, SharedUnlockingASharedMutexDiesWhenRealtime) {
121-
std::shared_mutex Mutex{};
122-
Mutex.lock_shared();
123-
auto Func = [&]() { Mutex.unlock_shared(); };
121+
std::shared_mutex mutex{};
122+
mutex.lock_shared();
123+
auto Func = [&]() { mutex.unlock_shared(); };
124124
ExpectRealtimeDeath(Func);
125125
ExpectNonRealtimeSurvival(Func);
126126
}
@@ -141,26 +141,26 @@ void InvokeStdFunction(std::function<void()> &&function) { function(); }
141141
} // namespace
142142

143143
TEST(TestRadsan, CopyingALambdaWithLargeCaptureDiesWhenRealtime) {
144-
std::array<float, 16> LotsOfData{};
145-
auto lambda = [LotsOfData]() mutable {
144+
std::array<float, 16> lots_of_data{};
145+
auto lambda = [lots_of_data]() mutable {
146146
// Stop everything getting optimised out
147-
LotsOfData[3] = 0.25f;
148-
EXPECT_EQ(16, LotsOfData.size());
149-
EXPECT_EQ(0.25f, LotsOfData[3]);
147+
lots_of_data[3] = 0.25f;
148+
EXPECT_EQ(16, lots_of_data.size());
149+
EXPECT_EQ(0.25f, lots_of_data[3]);
150150
};
151151
auto Func = [&]() { InvokeStdFunction(lambda); };
152152
ExpectRealtimeDeath(Func);
153153
ExpectNonRealtimeSurvival(Func);
154154
}
155155

156156
TEST(TestRadsan, AccessingALargeAtomicVariableDiesWhenRealtime) {
157-
std::atomic<float> SmallAtomic{0.0f};
158-
ASSERT_TRUE(SmallAtomic.is_lock_free());
159-
RealtimeInvoke([&SmallAtomic]() { float x = SmallAtomic.load(); });
157+
std::atomic<float> small_atomic{0.0f};
158+
ASSERT_TRUE(small_atomic.is_lock_free());
159+
RealtimeInvoke([&small_atomic]() { float x = small_atomic.load(); });
160160

161-
std::atomic<std::array<float, 2048>> LargeAtomic{};
162-
ASSERT_FALSE(LargeAtomic.is_lock_free());
163-
auto Func = [&]() { auto x = LargeAtomic.load(); };
161+
std::atomic<std::array<float, 2048>> large_atomic{};
162+
ASSERT_FALSE(large_atomic.is_lock_free());
163+
auto Func = [&]() { auto x = large_atomic.load(); };
164164
ExpectRealtimeDeath(Func);
165165
ExpectNonRealtimeSurvival(Func);
166166
}
@@ -196,11 +196,11 @@ TEST(TestRadsan, ThrowingAnExceptionDiesWhenRealtime) {
196196
}
197197

198198
TEST(TestRadsan, DoesNotDieIfTurnedOff) {
199-
std::mutex Mutex{};
199+
std::mutex mutex{};
200200
auto RealtimeUnsafeFunc = [&]() {
201201
__radsan_off();
202-
Mutex.lock();
203-
Mutex.unlock();
202+
mutex.lock();
203+
mutex.unlock();
204204
__radsan_on();
205205
};
206206
RealtimeInvoke(RealtimeUnsafeFunc);

0 commit comments

Comments
 (0)