Skip to content

Commit

Permalink
[rtsan][NFC] Remove unncessary namespace specifiers (llvm#110197)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjappl authored Sep 27, 2024
1 parent d9853a8 commit e069434
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
8 changes: 4 additions & 4 deletions compiler-rt/lib/rtsan/rtsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@ SANITIZER_INTERFACE_ATTRIBUTE bool __rtsan_is_initialized() {
}

SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_enter() {
__rtsan::GetContextForThisThread().RealtimePush();
GetContextForThisThread().RealtimePush();
}

SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_realtime_exit() {
__rtsan::GetContextForThisThread().RealtimePop();
GetContextForThisThread().RealtimePop();
}

SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_disable() {
__rtsan::GetContextForThisThread().BypassPush();
GetContextForThisThread().BypassPush();
}

SANITIZER_INTERFACE_ATTRIBUTE void __rtsan_enable() {
__rtsan::GetContextForThisThread().BypassPop();
GetContextForThisThread().BypassPop();
}

SANITIZER_INTERFACE_ATTRIBUTE void
Expand Down
13 changes: 7 additions & 6 deletions compiler-rt/lib/rtsan/rtsan_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <pthread.h>

using namespace __sanitizer;
using namespace __rtsan;

static pthread_key_t context_key;
static pthread_once_t key_once = PTHREAD_ONCE_INIT;
Expand All @@ -31,12 +32,12 @@ static __rtsan::Context &GetContextForThisThreadImpl() {
};

pthread_once(&key_once, MakeThreadLocalContextKey);
__rtsan::Context *current_thread_context =
static_cast<__rtsan::Context *>(pthread_getspecific(context_key));
Context *current_thread_context =
static_cast<Context *>(pthread_getspecific(context_key));
if (current_thread_context == nullptr) {
current_thread_context = static_cast<__rtsan::Context *>(
__sanitizer::InternalAlloc(sizeof(__rtsan::Context)));
new (current_thread_context) __rtsan::Context();
current_thread_context =
static_cast<Context *>(InternalAlloc(sizeof(Context)));
new (current_thread_context) Context();
pthread_setspecific(context_key, current_thread_context);
}

Expand All @@ -57,6 +58,6 @@ bool __rtsan::Context::InRealtimeContext() const { return realtime_depth_ > 0; }

bool __rtsan::Context::IsBypassed() const { return bypass_depth_ > 0; }

__rtsan::Context &__rtsan::GetContextForThisThread() {
Context &__rtsan::GetContextForThisThread() {
return GetContextForThisThreadImpl();
}
2 changes: 1 addition & 1 deletion compiler-rt/lib/rtsan/rtsan_diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void BufferedStackTrace::UnwindImpl(uptr pc, uptr bp, void *context,
} // namespace __sanitizer

namespace {
class Decorator : public __sanitizer::SanitizerCommonDecorator {
class Decorator : public SanitizerCommonDecorator {
public:
Decorator() : SanitizerCommonDecorator() {}
const char *FunctionName() const { return Green(); }
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/lib/rtsan/tests/rtsan_test_assertions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestRtsanAssertions : public ::testing::Test {
void SetUp() override { __rtsan_ensure_initialized(); }
};

static void ExpectViolationAction(__rtsan::Context &context,
static void ExpectViolationAction(Context &context,
bool expect_violation_callback) {
::testing::MockFunction<void()> mock_on_violation;
EXPECT_CALL(mock_on_violation, Call).Times(expect_violation_callback ? 1 : 0);
Expand All @@ -32,22 +32,22 @@ static void ExpectViolationAction(__rtsan::Context &context,

TEST_F(TestRtsanAssertions,
ExpectNotRealtimeDoesNotCallViolationActionIfNotInRealtimeContext) {
__rtsan::Context context{};
Context context{};
ASSERT_FALSE(context.InRealtimeContext());
ExpectViolationAction(context, false);
}

TEST_F(TestRtsanAssertions,
ExpectNotRealtimeCallsViolationActionIfInRealtimeContext) {
__rtsan::Context context{};
Context context{};
context.RealtimePush();
ASSERT_TRUE(context.InRealtimeContext());
ExpectViolationAction(context, true);
}

TEST_F(TestRtsanAssertions,
ExpectNotRealtimeDoesNotCallViolationActionIfRealtimeButBypassed) {
__rtsan::Context context{};
Context context{};
context.RealtimePush();
context.BypassPush();
ASSERT_TRUE(context.IsBypassed());
Expand Down
15 changes: 8 additions & 7 deletions compiler-rt/lib/rtsan/tests/rtsan_test_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <gtest/gtest.h>

using namespace __rtsan;
using namespace ::testing;

class TestRtsanContext : public Test {
Expand All @@ -23,26 +24,26 @@ class TestRtsanContext : public Test {
};

TEST_F(TestRtsanContext, IsNotRealtimeAfterDefaultConstruction) {
__rtsan::Context context{};
Context context{};
EXPECT_THAT(context.InRealtimeContext(), Eq(false));
}

TEST_F(TestRtsanContext, IsRealtimeAfterRealtimePush) {
__rtsan::Context context{};
Context context{};
context.RealtimePush();
EXPECT_THAT(context.InRealtimeContext(), Eq(true));
}

TEST_F(TestRtsanContext, IsNotRealtimeAfterRealtimePushAndPop) {
__rtsan::Context context{};
Context context{};
context.RealtimePush();
ASSERT_THAT(context.InRealtimeContext(), Eq(true));
context.RealtimePop();
EXPECT_THAT(context.InRealtimeContext(), Eq(false));
}

TEST_F(TestRtsanContext, RealtimeContextStateIsStatefullyTracked) {
__rtsan::Context context{};
Context context{};
auto const ExpectRealtime = [&context](bool is_rt) {
EXPECT_THAT(context.InRealtimeContext(), Eq(is_rt));
};
Expand All @@ -64,18 +65,18 @@ TEST_F(TestRtsanContext, RealtimeContextStateIsStatefullyTracked) {
}

TEST_F(TestRtsanContext, IsNotBypassedAfterDefaultConstruction) {
__rtsan::Context context{};
Context context{};
EXPECT_THAT(context.IsBypassed(), Eq(false));
}

TEST_F(TestRtsanContext, IsBypassedAfterBypassPush) {
__rtsan::Context context{};
Context context{};
context.BypassPush();
EXPECT_THAT(context.IsBypassed(), Eq(true));
}

TEST_F(TestRtsanContext, BypassedStateIsStatefullyTracked) {
__rtsan::Context context{};
Context context{};
auto const ExpectBypassed = [&context](bool is_bypassed) {
EXPECT_THAT(context.IsBypassed(), Eq(is_bypassed));
};
Expand Down

0 comments on commit e069434

Please sign in to comment.