From 30541ec32956786bd65d32419075d5214603a4b0 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Sat, 8 Oct 2016 04:53:25 -0700 Subject: [PATCH] [tests] Add test for suboptimal join of attributes Summary: Add a test case for a problem peterogithub uncovered with join of attributes. The expected result is currently incorrect, to be fixed later. Reviewed By: sblackshear Differential Revision: D3970363 fbshipit-source-id: 077705d --- infer/tests/codetoanalyze/java/checkers/Makefile | 10 +++++----- .../java/infer/GuardedByExample.java | 16 ++++++++++++++++ infer/tests/codetoanalyze/java/infer/issues.exp | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/infer/tests/codetoanalyze/java/checkers/Makefile b/infer/tests/codetoanalyze/java/checkers/Makefile index d1d84713c..a5db2f7ca 100644 --- a/infer/tests/codetoanalyze/java/checkers/Makefile +++ b/infer/tests/codetoanalyze/java/checkers/Makefile @@ -11,16 +11,16 @@ ANALYZER = checkers FILES = \ Branch.java \ - FragmentRetainsViewExample.java \ ExpensiveCallExample.java \ - ImmutableCast.java \ ExpensiveInheritanceExample.java \ - NoAllocationExample.java \ ExpensiveInterfaceExample.java \ - PrintfArgsChecker.java \ ExpensiveSubtypingExample.java \ - TraceCallSequence.java \ FragmentDoesNotRetainViewExample.java \ + FragmentRetainsViewExample.java \ + ImmutableCast.java \ + NoAllocationExample.java \ + PrintfArgsChecker.java \ + TraceCallSequence.java \ TwoCheckersExample.java compile: diff --git a/infer/tests/codetoanalyze/java/infer/GuardedByExample.java b/infer/tests/codetoanalyze/java/infer/GuardedByExample.java index 4875814fd..ce63fec89 100644 --- a/infer/tests/codetoanalyze/java/infer/GuardedByExample.java +++ b/infer/tests/codetoanalyze/java/infer/GuardedByExample.java @@ -354,4 +354,20 @@ public class GuardedByExample { } */ + int n; + + public void FP_withloop2() { + synchronized (mLock) { + for (int i = 0; i<=n; i++) { + f = 42; + } + } + } + + public void withoutloop2() { + synchronized (mLock) { + f = 42; + } + } + } diff --git a/infer/tests/codetoanalyze/java/infer/issues.exp b/infer/tests/codetoanalyze/java/infer/issues.exp index e626e0bb6..c5e6f3888 100644 --- a/infer/tests/codetoanalyze/java/infer/issues.exp +++ b/infer/tests/codetoanalyze/java/infer/issues.exp @@ -74,6 +74,7 @@ FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.printStreamNotClosedA GuardedByExample.java, Object GuardedByExample.byRefTrickyBad(), 5, UNSAFE_GUARDED_BY_ACCESS GuardedByExample.java, String GuardedByExample$3.readFromInnerClassBad1(), 2, UNSAFE_GUARDED_BY_ACCESS GuardedByExample.java, String GuardedByExample$4.readFromInnerClassBad2(), 1, UNSAFE_GUARDED_BY_ACCESS +GuardedByExample.java, void GuardedByExample.FP_withloop2(), 3, UNSAFE_GUARDED_BY_ACCESS GuardedByExample.java, void GuardedByExample.readFAfterBlockBad(), 3, UNSAFE_GUARDED_BY_ACCESS GuardedByExample.java, void GuardedByExample.readFBad(), 1, UNSAFE_GUARDED_BY_ACCESS GuardedByExample.java, void GuardedByExample.readFBadWrongAnnotation(), 1, UNSAFE_GUARDED_BY_ACCESS