diff --git a/infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java b/infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java new file mode 100644 index 000000000..699b72485 --- /dev/null +++ b/infer/tests/codetoanalyze/java/checkers/TraceCallSequence.java @@ -0,0 +1,148 @@ +/* + * 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; + + +class TraceCallSequence { + static void begin() { + } + + static void end() { + } + + static void beginWrapper() { + begin(); + } + + static void endWrapper() { + end(); + } + + void thereIsNoEnd() { + begin(); + } // 1 missing end/stop + + void thereIsNoBeginning() { + end(); // too many end/stop; + } + + void ok() { + begin(); + end(); + } + + void wrapper() { + begin(); + beginWrapper(); + end(); + endWrapper(); + } + + void exception1(String s) { + begin(); + int n = s.length(); + end(); + } // 1 missing end/stop + + void exception2(String s) { + int n = s.length(); + begin(); + end(); + } + + void exception3(String s) { + begin(); + try { + int n = s.length(); + } finally { + end(); + } + } + + void infinite(int d) { + int count = 0; + begin(); + begin(); + while (count < d) { + end(); + begin(); + count++; + } + end(); + end(); + } + + void nondet(int x) { + if (x > 0) { + begin(); + } else { + } + end(); // too many end/stop + } + + void grow(int d) { + int count = 0; + while (count < d) { + begin(); + } + } // 2 missing end/stop + + void testBool(String s) { + boolean shouldTrace = s.length() == 4; + if (shouldTrace) { + begin(); + } + + if (shouldTrace) { + shouldTrace = false; + } else { + shouldTrace = true; + } + + if (!shouldTrace) { + end(); + } + } + + void testBoolLoop1(String s) { + boolean shouldTrace = true; + while (s.length() == 4) { + if (shouldTrace) { + begin(); + shouldTrace = false; + } else { + end(); + shouldTrace = true; + } + } + if (!shouldTrace) { + end(); + } + } // 1 missing end/stop + + void testBoolLoop2(String s) { + boolean shouldTrace = true; + try { + while (s.length() == 4) { + if (shouldTrace) { + begin(); + shouldTrace = false; + } else { + end(); + shouldTrace = true; + } + } + } finally { + if (!shouldTrace) { + end(); + } + } + } +} diff --git a/infer/tests/codetoanalyze/objc/errors/Makefile b/infer/tests/codetoanalyze/objc/errors/Makefile index 019cb32a9..2a5bc920d 100644 --- a/infer/tests/codetoanalyze/objc/errors/Makefile +++ b/infer/tests/codetoanalyze/objc/errors/Makefile @@ -23,7 +23,6 @@ INFERPRINT_OPTIONS = --issues-tests SOURCES_DEFAULT = \ field_superclass/B.m \ - memory_leaks_benchmark/FBViewExample.m \ memory_leaks_benchmark/MemoryLeakRaii.m \ memory_leaks_benchmark/NSMakeCollectableExample.m \ memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m \ diff --git a/infer/tests/codetoanalyze/objc/errors/issues.exp b/infer/tests/codetoanalyze/objc/errors/issues.exp index 88bcae48c..837a4aba1 100644 --- a/infer/tests/codetoanalyze/objc/errors/issues.exp +++ b/infer/tests/codetoanalyze/objc/errors/issues.exp @@ -88,7 +88,6 @@ codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZer codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZero2, 2, DIVIDE_BY_ZERO, [start of procedure shouldThrowDivideByZero2(),start of procedure init,return from a call to Base_init,start of procedure returnsZero2(),Condition is false,return from a call to returnsZero2] codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZero3, 3, DIVIDE_BY_ZERO, [start of procedure shouldThrowDivideByZero3(),start of procedure init,return from a call to Derived_init,Condition is true] codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m, PrematureNilTermA_nilInArrayWithObjects, 5, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure nilInArrayWithObjects] -codetoanalyze/objc/errors/memory_leaks_benchmark/FBViewExample.m, FBV_main, 2, PRECONDITION_NOT_MET, [start of procedure main,start of procedure headerView,Condition is false,return from a call to FBV_headerView] codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m, StringInitA_macForIV:, 2, MEMORY_LEAK, [start of procedure macForIV:] codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m, createURLQueryStringBodyEscaping, 6, PRECONDITION_NOT_MET, [start of procedure createURLQueryStringBodyEscaping(),Condition is true] codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m, createURLQueryStringBodyEscaping, 11, UNINITIALIZED_VALUE, [start of procedure createURLQueryStringBodyEscaping(),Condition is false]