From d10f6855f2946aafe41e523d000b4ccb45bee7e0 Mon Sep 17 00:00:00 2001 From: Dino Distefano Date: Thu, 8 Nov 2018 13:37:34 -0800 Subject: [PATCH] Making error message more explicit in CXX Reference rule Reviewed By: jvillard Differential Revision: D12902491 fbshipit-source-id: 771cfd96a --- infer/lib/linter_rules/linters.al | 13 +++---------- infer/tests/codetoanalyze/objcpp/linters/issues.exp | 4 ++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/infer/lib/linter_rules/linters.al b/infer/lib/linter_rules/linters.al index 107c4120b..500651d7e 100644 --- a/infer/lib/linter_rules/linters.al +++ b/infer/lib/linter_rules/linters.al @@ -182,20 +182,13 @@ DEFINE-CHECKER CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK = { HOLDS-NEXT) HOLDS-IN-NODE BlockExpr; -// * Alternative ways of writing this check: -// SET report_when = -// WHEN -// captures_cxx_references() -// HOLDS-IN-NODE BlockDecl; -// -// SET report_when = -// is_node(BlockDecl) AND captures_cxx_references(); - SET message = "C++ Reference variable(s) %cxx_ref_captured_in_block% captured by Objective-C block"; - SET suggestion = "C++ References are unmanaged and may be invalid by the time the block executes."; + SET suggestion = "This will very likely cause a crash because C++ References are unmanaged and may be invalid by the time the block executes."; + SET severity = "ERROR"; + SET mode = "ON"; }; // If the declaration has availability attributes, check that it's compatible with diff --git a/infer/tests/codetoanalyze/objcpp/linters/issues.exp b/infer/tests/codetoanalyze/objcpp/linters/issues.exp index ea7e36f64..b49e8d062 100644 --- a/infer/tests/codetoanalyze/objcpp/linters/issues.exp +++ b/infer/tests/codetoanalyze/objcpp/linters/issues.exp @@ -26,8 +26,8 @@ codetoanalyze/objcpp/linters/componentkit/MutableLocalVariablesTest.mm, FooCompo codetoanalyze/objcpp/linters/componentkit/MutableLocalVariablesTest.mm, FooComponent_newWithString, 67, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/componentkit/MutableLocalVariablesTest.mm, SomeClass_init, 38, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, no_bucket, ADVICE, [] codetoanalyze/objcpp/linters/componentkit/UnconventionalSuperclassTest.h, Linters_dummy_method, 15, COMPONENT_WITH_UNCONVENTIONAL_SUPERCLASS, no_bucket, ADVICE, [] -codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm, A_foo, 18, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK, no_bucket, WARNING, [] -codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm, A_foo3, 35, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK, no_bucket, WARNING, [] +codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm, A_foo, 18, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK, no_bucket, ERROR, [] +codetoanalyze/objcpp/linters/cxx_reference_in_block/block.mm, A_foo3, 35, CXX_REFERENCE_CAPTURED_IN_OBJC_BLOCK, no_bucket, ERROR, [] codetoanalyze/objcpp/linters/global-var/B.mm, Linters_dummy_method, 28, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL, no_bucket, WARNING, [] codetoanalyze/objcpp/linters/global-var/B.mm, Linters_dummy_method, 30, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL, no_bucket, WARNING, [] codetoanalyze/objcpp/linters/global-var/B.mm, Linters_dummy_method, 32, GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL, no_bucket, WARNING, []