Skip to content

Commit 6032fee

Browse files
authored
[rtsan][NFC] Standardize lambda function case, fix autos (#109541)
1 parent a04db2c commit 6032fee

File tree

4 files changed

+65
-65
lines changed

4 files changed

+65
-65
lines changed

compiler-rt/lib/rtsan/rtsan_context.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ static pthread_once_t key_once = PTHREAD_ONCE_INIT;
2626
static void InternalFreeWrapper(void *ptr) { __sanitizer::InternalFree(ptr); }
2727

2828
static __rtsan::Context &GetContextForThisThreadImpl() {
29-
auto make_thread_local_context_key = []() {
29+
auto MakeThreadLocalContextKey = []() {
3030
CHECK_EQ(pthread_key_create(&context_key, InternalFreeWrapper), 0);
3131
};
3232

33-
pthread_once(&key_once, make_thread_local_context_key);
33+
pthread_once(&key_once, MakeThreadLocalContextKey);
3434
__rtsan::Context *current_thread_context =
3535
static_cast<__rtsan::Context *>(pthread_getspecific(context_key));
3636
if (current_thread_context == nullptr) {

compiler-rt/lib/rtsan/tests/rtsan_test_context.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,24 @@ TEST_F(TestRtsanContext, IsNotRealtimeAfterRealtimePushAndPop) {
4343

4444
TEST_F(TestRtsanContext, RealtimeContextStateIsStatefullyTracked) {
4545
__rtsan::Context context{};
46-
auto const expect_rt = [&context](bool is_rt) {
46+
auto const ExpectRealtime = [&context](bool is_rt) {
4747
EXPECT_THAT(context.InRealtimeContext(), Eq(is_rt));
4848
};
49-
expect_rt(false);
49+
ExpectRealtime(false);
5050
context.RealtimePush(); // depth 1
51-
expect_rt(true);
51+
ExpectRealtime(true);
5252
context.RealtimePush(); // depth 2
53-
expect_rt(true);
53+
ExpectRealtime(true);
5454
context.RealtimePop(); // depth 1
55-
expect_rt(true);
55+
ExpectRealtime(true);
5656
context.RealtimePush(); // depth 2
57-
expect_rt(true);
57+
ExpectRealtime(true);
5858
context.RealtimePop(); // depth 1
59-
expect_rt(true);
59+
ExpectRealtime(true);
6060
context.RealtimePop(); // depth 0
61-
expect_rt(false);
61+
ExpectRealtime(false);
6262
context.RealtimePush(); // depth 1
63-
expect_rt(true);
63+
ExpectRealtime(true);
6464
}
6565

6666
TEST_F(TestRtsanContext, IsNotBypassedAfterDefaultConstruction) {
@@ -76,22 +76,22 @@ TEST_F(TestRtsanContext, IsBypassedAfterBypassPush) {
7676

7777
TEST_F(TestRtsanContext, BypassedStateIsStatefullyTracked) {
7878
__rtsan::Context context{};
79-
auto const expect_bypassed = [&context](bool is_bypassed) {
79+
auto const ExpectBypassed = [&context](bool is_bypassed) {
8080
EXPECT_THAT(context.IsBypassed(), Eq(is_bypassed));
8181
};
82-
expect_bypassed(false);
82+
ExpectBypassed(false);
8383
context.BypassPush(); // depth 1
84-
expect_bypassed(true);
84+
ExpectBypassed(true);
8585
context.BypassPush(); // depth 2
86-
expect_bypassed(true);
86+
ExpectBypassed(true);
8787
context.BypassPop(); // depth 1
88-
expect_bypassed(true);
88+
ExpectBypassed(true);
8989
context.BypassPush(); // depth 2
90-
expect_bypassed(true);
90+
ExpectBypassed(true);
9191
context.BypassPop(); // depth 1
92-
expect_bypassed(true);
92+
ExpectBypassed(true);
9393
context.BypassPop(); // depth 0
94-
expect_bypassed(false);
94+
ExpectBypassed(false);
9595
context.BypassPush(); // depth 1
96-
expect_bypassed(true);
96+
ExpectBypassed(true);
9797
}

compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ void InvokeStdFunction(std::function<void()> &&function) { function(); }
142142

143143
TEST(TestRtsan, CopyingALambdaWithLargeCaptureDiesWhenRealtime) {
144144
std::array<float, 16> lots_of_data;
145-
auto lambda = [lots_of_data]() mutable {
145+
auto LargeLambda = [lots_of_data]() mutable {
146146
// Stop everything getting optimised out
147147
lots_of_data[3] = 0.25f;
148148
EXPECT_EQ(16u, lots_of_data.size());
149149
EXPECT_EQ(0.25f, lots_of_data[3]);
150150
};
151-
auto Func = [&]() { InvokeStdFunction(lambda); };
151+
auto Func = [&]() { InvokeStdFunction(LargeLambda); };
152152
ExpectRealtimeDeath(Func);
153153
ExpectNonRealtimeSurvival(Func);
154154
}

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors.cpp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,15 @@ TEST(TestRtsanInterceptors, NanosleepDiesWhenRealtime) {
200200
*/
201201

202202
TEST_F(RtsanFileTest, OpenDiesWhenRealtime) {
203-
auto func = [this]() { open(GetTemporaryFilePath(), O_RDONLY); };
204-
ExpectRealtimeDeath(func, kOpenFunctionName);
205-
ExpectNonRealtimeSurvival(func);
203+
auto Func = [this]() { open(GetTemporaryFilePath(), O_RDONLY); };
204+
ExpectRealtimeDeath(Func, kOpenFunctionName);
205+
ExpectNonRealtimeSurvival(Func);
206206
}
207207

208208
TEST_F(RtsanFileTest, OpenatDiesWhenRealtime) {
209-
auto func = [this]() { openat(0, GetTemporaryFilePath(), O_RDONLY); };
210-
ExpectRealtimeDeath(func, kOpenAtFunctionName);
211-
ExpectNonRealtimeSurvival(func);
209+
auto Func = [this]() { openat(0, GetTemporaryFilePath(), O_RDONLY); };
210+
ExpectRealtimeDeath(Func, kOpenAtFunctionName);
211+
ExpectNonRealtimeSurvival(Func);
212212
}
213213

214214
TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
@@ -231,22 +231,22 @@ TEST_F(RtsanFileTest, OpenCreatesFileWithProperMode) {
231231
}
232232

233233
TEST_F(RtsanFileTest, CreatDiesWhenRealtime) {
234-
auto func = [this]() { creat(GetTemporaryFilePath(), S_IWOTH | S_IROTH); };
235-
ExpectRealtimeDeath(func, kCreatFunctionName);
236-
ExpectNonRealtimeSurvival(func);
234+
auto Func = [this]() { creat(GetTemporaryFilePath(), S_IWOTH | S_IROTH); };
235+
ExpectRealtimeDeath(Func, kCreatFunctionName);
236+
ExpectNonRealtimeSurvival(Func);
237237
}
238238

239239
TEST(TestRtsanInterceptors, FcntlDiesWhenRealtime) {
240-
auto func = []() { fcntl(0, F_GETFL); };
241-
ExpectRealtimeDeath(func, kFcntlFunctionName);
242-
ExpectNonRealtimeSurvival(func);
240+
auto Func = []() { fcntl(0, F_GETFL); };
241+
ExpectRealtimeDeath(Func, kFcntlFunctionName);
242+
ExpectNonRealtimeSurvival(Func);
243243
}
244244

245245
TEST_F(RtsanFileTest, FcntlFlockDiesWhenRealtime) {
246246
int fd = creat(GetTemporaryFilePath(), S_IRUSR | S_IWUSR);
247247
ASSERT_THAT(fd, Ne(-1));
248248

249-
auto func = [fd]() {
249+
auto Func = [fd]() {
250250
struct flock lock {};
251251
lock.l_type = F_RDLCK;
252252
lock.l_whence = SEEK_SET;
@@ -257,8 +257,8 @@ TEST_F(RtsanFileTest, FcntlFlockDiesWhenRealtime) {
257257
ASSERT_THAT(fcntl(fd, F_GETLK, &lock), Eq(0));
258258
ASSERT_THAT(lock.l_type, F_UNLCK);
259259
};
260-
ExpectRealtimeDeath(func, kFcntlFunctionName);
261-
ExpectNonRealtimeSurvival(func);
260+
ExpectRealtimeDeath(Func, kFcntlFunctionName);
261+
ExpectNonRealtimeSurvival(Func);
262262

263263
close(fd);
264264
}
@@ -267,7 +267,7 @@ TEST_F(RtsanFileTest, FcntlSetFdDiesWhenRealtime) {
267267
int fd = creat(GetTemporaryFilePath(), S_IRUSR | S_IWUSR);
268268
ASSERT_THAT(fd, Ne(-1));
269269

270-
auto func = [fd]() {
270+
auto Func = [fd]() {
271271
int old_flags = fcntl(fd, F_GETFD);
272272
ASSERT_THAT(fcntl(fd, F_SETFD, FD_CLOEXEC), Eq(0));
273273

@@ -279,26 +279,26 @@ TEST_F(RtsanFileTest, FcntlSetFdDiesWhenRealtime) {
279279
ASSERT_THAT(fcntl(fd, F_GETFD), Eq(old_flags));
280280
};
281281

282-
ExpectRealtimeDeath(func, kFcntlFunctionName);
283-
ExpectNonRealtimeSurvival(func);
282+
ExpectRealtimeDeath(Func, kFcntlFunctionName);
283+
ExpectNonRealtimeSurvival(Func);
284284

285285
close(fd);
286286
}
287287

288288
TEST(TestRtsanInterceptors, CloseDiesWhenRealtime) {
289-
auto func = []() { close(0); };
290-
ExpectRealtimeDeath(func, "close");
291-
ExpectNonRealtimeSurvival(func);
289+
auto Func = []() { close(0); };
290+
ExpectRealtimeDeath(Func, "close");
291+
ExpectNonRealtimeSurvival(Func);
292292
}
293293

294294
TEST_F(RtsanFileTest, FopenDiesWhenRealtime) {
295-
auto func = [this]() {
296-
auto fd = fopen(GetTemporaryFilePath(), "w");
297-
EXPECT_THAT(fd, Ne(nullptr));
295+
auto Func = [this]() {
296+
FILE *f = fopen(GetTemporaryFilePath(), "w");
297+
EXPECT_THAT(f, Ne(nullptr));
298298
};
299299

300-
ExpectRealtimeDeath(func, kFopenFunctionName);
301-
ExpectNonRealtimeSurvival(func);
300+
ExpectRealtimeDeath(Func, kFopenFunctionName);
301+
ExpectNonRealtimeSurvival(Func);
302302
}
303303

304304
class RtsanOpenedFileTest : public RtsanFileTest {
@@ -327,39 +327,39 @@ class RtsanOpenedFileTest : public RtsanFileTest {
327327
};
328328

329329
TEST_F(RtsanOpenedFileTest, FreadDiesWhenRealtime) {
330-
auto func = [this]() {
330+
auto Func = [this]() {
331331
char c{};
332332
fread(&c, 1, 1, GetOpenFile());
333333
};
334-
ExpectRealtimeDeath(func, "fread");
335-
ExpectNonRealtimeSurvival(func);
334+
ExpectRealtimeDeath(Func, "fread");
335+
ExpectNonRealtimeSurvival(Func);
336336
}
337337

338338
TEST_F(RtsanOpenedFileTest, FwriteDiesWhenRealtime) {
339339
const char *message = "Hello, world!";
340-
auto func = [&]() { fwrite(&message, 1, 4, GetOpenFile()); };
341-
ExpectRealtimeDeath(func, "fwrite");
342-
ExpectNonRealtimeSurvival(func);
340+
auto Func = [&]() { fwrite(&message, 1, 4, GetOpenFile()); };
341+
ExpectRealtimeDeath(Func, "fwrite");
342+
ExpectNonRealtimeSurvival(Func);
343343
}
344344

345345
TEST_F(RtsanFileTest, FcloseDiesWhenRealtime) {
346-
auto fd = fopen(GetTemporaryFilePath(), "w");
347-
EXPECT_THAT(fd, Ne(nullptr));
348-
auto func = [fd]() { fclose(fd); };
349-
ExpectRealtimeDeath(func, "fclose");
350-
ExpectNonRealtimeSurvival(func);
346+
FILE *f = fopen(GetTemporaryFilePath(), "w");
347+
EXPECT_THAT(f, Ne(nullptr));
348+
auto Func = [f]() { fclose(f); };
349+
ExpectRealtimeDeath(Func, "fclose");
350+
ExpectNonRealtimeSurvival(Func);
351351
}
352352

353353
TEST(TestRtsanInterceptors, PutsDiesWhenRealtime) {
354-
auto func = []() { puts("Hello, world!\n"); };
355-
ExpectRealtimeDeath(func);
356-
ExpectNonRealtimeSurvival(func);
354+
auto Func = []() { puts("Hello, world!\n"); };
355+
ExpectRealtimeDeath(Func);
356+
ExpectNonRealtimeSurvival(Func);
357357
}
358358

359359
TEST_F(RtsanOpenedFileTest, FputsDiesWhenRealtime) {
360-
auto func = [this]() { fputs("Hello, world!\n", GetOpenFile()); };
361-
ExpectRealtimeDeath(func);
362-
ExpectNonRealtimeSurvival(func);
360+
auto Func = [this]() { fputs("Hello, world!\n", GetOpenFile()); };
361+
ExpectRealtimeDeath(Func);
362+
ExpectNonRealtimeSurvival(Func);
363363
}
364364

365365
TEST_F(RtsanOpenedFileTest, ReadDiesWhenRealtime) {

0 commit comments

Comments
 (0)