No longer enforce the subtyping rule for the @PerformanceCritical annotation

Summary:
public
The contravariant subtyping rule for the PerformanceCritial annotation was meant to document the code but can be very too verbose on exisiting project. It is also not necessary as we can get this annotation from the supertypes. I am disabling it for now, but keep the code in case we want to revive it at some point in the future.

Reviewed By: sblackshear

Differential Revision: D2750212

fb-gh-sync-id: 2424281
master
jrm 9 years ago committed by facebook-github-bot-1
parent df97489aa1
commit 0def5c4111

@ -9,19 +9,29 @@
module L = Logging module L = Logging
(* Automatically detect if a method is considered as performance critical
by looking for the annotation in the super-types *)
let infer_performance_critical_methods = true let infer_performance_critical_methods = true
(* Warning name when a performance critical method directly or indirectly
calls a method annotatd as expensive *)
let calls_expensive_method = let calls_expensive_method =
"CHECKERS_CALLS_EXPENSIVE_METHOD" "CHECKERS_CALLS_EXPENSIVE_METHOD"
(* Warning name for the subtyping rule: method not annotated as expensive cannot be overridden
by a method annotated as expensive *)
let expensive_overrides_unexpensive = let expensive_overrides_unexpensive =
"CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED" "CHECKERS_EXPENSIVE_OVERRIDES_UNANNOTATED"
(* Warning name for the subtyping rule: methods overriding methods annotated as performance critical
should also be annotated as performance critical *)
let unannotated_overrides_performance_critical = let unannotated_overrides_performance_critical =
"CHECKERS_UNANNOTATED_OVERRIDES_PERFOMANCE_CRITICAL" "CHECKERS_UNANNOTATED_OVERRIDES_PERFOMANCE_CRITICAL"
(* Triggers report on violation of the sybtyping rule for the performance critical annotation *)
let enforce_performance_critical_subtyping_rule = false
let check_attributes check attributes = let check_attributes check attributes =
let annotated_signature = Annotations.get_annotated_signature attributes in let annotated_signature = Annotations.get_annotated_signature attributes in
@ -176,7 +186,7 @@ let check_one_procedure tenv pname pdesc =
if expensive then if expensive then
PatternMatch.proc_iter_overridden_methods PatternMatch.proc_iter_overridden_methods
check_expensive_subtyping_rules tenv pname; check_expensive_subtyping_rules tenv pname;
if not performance_critical then if enforce_performance_critical_subtyping_rule && not performance_critical then
PatternMatch.proc_iter_overridden_methods PatternMatch.proc_iter_overridden_methods
check_performance_critical_subtyping_rules tenv pname; check_performance_critical_subtyping_rules tenv pname;

@ -1,18 +0,0 @@
/*
* Copyright (c) 2013 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package codetoanalyze.java.checkers;
public class PerformanceCriticalSubtypingExample implements ExpensiveInterfaceExample.I {
public void m1() {}
public void m2() {}
}

@ -1,54 +0,0 @@
/*
* Copyright (c) 2015 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package endtoend.java.checkers;
import static org.hamcrest.MatcherAssert.assertThat;
import static utils.matchers.ResultContainsExactly.containsExactly;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import utils.InferException;
import utils.InferResults;
public class PerformanceCriticalSubtypingTest {
public static final String SOURCE_FILE =
"infer/tests/codetoanalyze/java/checkers/PerformanceCriticalSubtypingExample.java";
public static final String UNANNOTATED_OVERRIDES_PERFOMANCE_CRITICAL =
"CHECKERS_UNANNOTATED_OVERRIDES_PERFOMANCE_CRITICAL";
private static InferResults inferResults;
@BeforeClass
public static void loadResults() throws InterruptedException, IOException {
inferResults =
InferResults.loadCheckersResults(PerformanceCriticalSubtypingTest.class, SOURCE_FILE);
}
@Test
public void matchErrors()
throws IOException, InterruptedException, InferException {
String[] methods = {
"m1",
};
assertThat(
"Results should contain " + UNANNOTATED_OVERRIDES_PERFOMANCE_CRITICAL,
inferResults,
containsExactly(
UNANNOTATED_OVERRIDES_PERFOMANCE_CRITICAL,
SOURCE_FILE,
methods));
}
}
Loading…
Cancel
Save