From e0c02e7396d57938dbcd99f282bd19693d9f70b4 Mon Sep 17 00:00:00 2001 From: Alexandre Bergel Date: Mon, 4 Mar 2024 17:01:29 +0100 Subject: [PATCH] Added `remove_page` --- src/linting/extended_checks.jl | 3 +++ test/rai_rules_tests.jl | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/linting/extended_checks.jl b/src/linting/extended_checks.jl index 494200b..fbd66e5 100644 --- a/src/linting/extended_checks.jl +++ b/src/linting/extended_checks.jl @@ -66,6 +66,7 @@ struct ArrayWithNoType_Extension <: ExtendedRule end struct Threads_Extension <: ExtendedRule end struct Generated_Extension <: ExtendedRule end struct Sync_Extension <: ExtendedRule end +struct RemovePage_Extension <: ExtendedRule end const all_extended_rule_types = Ref{Any}(InteractiveUtils.subtypes(ExtendedRule)) @@ -193,3 +194,5 @@ function check(::Sync_Extension, x::EXPR) generic_check(x, "@sync hole_variable", msg) generic_check(x, "Threads.@sync hole_variable", msg) end + +check(::RemovePage_Extension, x::EXPR) = generic_check(x, "remove_page(hole_variable,hole_variable)") diff --git a/test/rai_rules_tests.jl b/test/rai_rules_tests.jl index e7bb2c4..155a85f 100644 --- a/test/rai_rules_tests.jl +++ b/test/rai_rules_tests.jl @@ -362,7 +362,7 @@ end "Line 18, column 5: `wait` should be used with extreme caution.") end - @testset "fetch, @inbounds, Atomic, Ptr" begin + @testset "fetch, @inbounds, Atomic, Ptr, remove_page" begin source = """ function f() fut = Future{Any}() @@ -384,6 +384,12 @@ end pointer(page) == Ptr{Nothing}(0) && return end + + function _clear_pager!(pager) + for (pid, _) in pager.owned_pages + remove_page(pager, pid) + end + end """ @test lint_test(source, "Line 3, column 10: `fetch` should be used with extreme caution.") @@ -394,6 +400,8 @@ end @test lint_test(source, "Line 17, column 20: `Atomic` should be used with extreme caution.") @test lint_test(source, "Line 19, column 22: `Ptr` should be used with extreme caution.") + + @test lint_test(source, "Line 24, column 9: `remove_page` should be used with extreme caution.") end @testset "Array with no specific type 01" begin