File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,8 @@ template <typename OnViolationAction>
2121void ExpectNotRealtime (Context &context, OnViolationAction &&OnViolation) {
2222 CHECK (__rtsan_is_initialized ());
2323 if (context.InRealtimeContext () && !context.IsBypassed ()) {
24- context. BypassPush () ;
24+ ScopedBypass sb{ context} ;
2525 OnViolation ();
26- context.BypassPop ();
2726 }
2827}
2928
Original file line number Diff line number Diff line change @@ -35,5 +35,22 @@ class Context {
3535 int bypass_depth_{0 };
3636};
3737
38+ class ScopedBypass {
39+ public:
40+ [[nodiscard]] explicit ScopedBypass (Context &context) : context_(context) {
41+ context_.BypassPush ();
42+ }
43+
44+ ~ScopedBypass () { context_.BypassPop (); }
45+
46+ ScopedBypass (const ScopedBypass &) = delete ;
47+ ScopedBypass &operator =(const ScopedBypass &) = delete ;
48+ ScopedBypass (ScopedBypass &&) = delete ;
49+ ScopedBypass &operator =(ScopedBypass &&) = delete ;
50+
51+ private:
52+ Context &context_;
53+ };
54+
3855Context &GetContextForThisThread ();
3956} // namespace __rtsan
You can’t perform that action at this time.
0 commit comments