[infer][nullable checker] avoid reporting the nullable violations that are already reported by the biabduction analysis
Summary: This is to allow the bi-abduction analysis and the nullable checker for Clang languages to run together without stepping on each other toes. Reviewed By: sblackshear Differential Revision: D6567934 fbshipit-source-id: a318c33master
parent
d6ed9e3bbe
commit
32deab86bd
@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (c) 2017 - 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.
|
||||||
|
|
||||||
|
|
||||||
|
TESTS_DIR = ../../..
|
||||||
|
|
||||||
|
ANALYZER = checkers
|
||||||
|
CLANG_OPTIONS = -c -x c++ -std=c++14
|
||||||
|
INFER_OPTIONS = --no-default-checkers --biabduction --check-nullable --project-root $(TESTS_DIR)
|
||||||
|
INFERPRINT_OPTIONS = --issues-tests
|
||||||
|
|
||||||
|
SOURCES = $(wildcard *.cpp)
|
||||||
|
|
||||||
|
include $(TESTS_DIR)/clang.make
|
||||||
|
|
||||||
|
infer-out/report.json: $(MAKEFILE_LIST)
|
@ -0,0 +1,3 @@
|
|||||||
|
codetoanalyze/cpp/conflicts/test.cpp, test1_bad, 2, NULL_DEREFERENCE, [start of procedure test1_bad(),Skipping nullableMethod(): function or method not found]
|
||||||
|
codetoanalyze/cpp/conflicts/test.cpp, test2_bad, 1, NULLABLE_DEREFERENCE, [dereferencing the return of nullableMethod(),definition of nullableMethod]
|
||||||
|
codetoanalyze/cpp/conflicts/test.cpp, test3_bad, 5, NULLABLE_DEREFERENCE, [dereference of &p,assignment of the nullable value,definition of nullableMethod]
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 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.
|
||||||
|
*/
|
||||||
|
class C {
|
||||||
|
private:
|
||||||
|
int f;
|
||||||
|
|
||||||
|
public:
|
||||||
|
int get() { return f; }
|
||||||
|
};
|
||||||
|
|
||||||
|
C* _Nullable nullableMethod();
|
||||||
|
|
||||||
|
int test1_bad() {
|
||||||
|
C* p = nullableMethod();
|
||||||
|
return p->get(); // reported by the biabduction analysis
|
||||||
|
}
|
||||||
|
|
||||||
|
int test2_bad() {
|
||||||
|
return nullableMethod()->get(); // not reported by the biabduction analysis
|
||||||
|
}
|
||||||
|
|
||||||
|
int test3_bad() {
|
||||||
|
C* p = nullableMethod();
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
p = nullableMethod();
|
||||||
|
}
|
||||||
|
return p->get(); // not reported by the biabduction analysis
|
||||||
|
}
|
Loading…
Reference in new issue