diff --git a/Makefile b/Makefile index e66970698..040d73f6b 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,9 @@ BUILD_SYSTEMS_TESTS += \ waf \ DIRECT_TESTS += \ - c_errors c_frontend c_bufferoverrun cpp_checkers cpp_errors cpp_frontend cpp_quandary + c_bufferoverrun c_errors c_frontend \ + cpp_bufferoverrun cpp_checkers cpp_errors cpp_frontend cpp_quandary \ + ifneq ($(BUCK),no) BUILD_SYSTEMS_TESTS += buck-clang-db endif diff --git a/infer/tests/codetoanalyze/cpp/bufferoverrun/Makefile b/infer/tests/codetoanalyze/cpp/bufferoverrun/Makefile new file mode 100644 index 000000000..eec20303a --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/bufferoverrun/Makefile @@ -0,0 +1,24 @@ +# Copyright (c) 2016 - 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 = bufferoverrun +# see explanations in cpp/errors/Makefile for the custom isystem +CLANG_OPTIONS = -x c++ -std=c++11 -nostdinc++ -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c +INFER_OPTIONS = --ml-buckets cpp --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed +INFERPRINT_OPTIONS = --issues-tests + +SOURCES = \ + trivial.cpp \ + vector.cpp \ + +HEADERS = + +include $(TESTS_DIR)/clang.make + +infer-out/report.json: $(MAKEFILE_LIST) diff --git a/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp b/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp new file mode 100644 index 000000000..6f24ef3cf --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/bufferoverrun/issues.exp @@ -0,0 +1 @@ +codetoanalyze/cpp/bufferoverrun/trivial.cpp, trivial, 2, BUFFER_OVERRUN, [Offset : [10, 10] Size : [10, 10] @ codetoanalyze/cpp/bufferoverrun/trivial.cpp:15:3] diff --git a/infer/tests/codetoanalyze/cpp/bufferoverrun/trivial.cpp b/infer/tests/codetoanalyze/cpp/bufferoverrun/trivial.cpp new file mode 100644 index 000000000..a97f8c585 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/bufferoverrun/trivial.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2016 - present + * + * Programming Research Laboratory (ROPAS) + * Seoul National University, Korea + * 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. + */ + +void trivial() { + int a[10]; + a[10] = 0; /* BUG */ +} diff --git a/infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp b/infer/tests/codetoanalyze/cpp/bufferoverrun/vector.cpp similarity index 100% rename from infer/tests/codetoanalyze/cpp/checkers/bufferoverrun/vector.cpp rename to infer/tests/codetoanalyze/cpp/bufferoverrun/vector.cpp diff --git a/infer/tests/codetoanalyze/cpp/checkers/Makefile b/infer/tests/codetoanalyze/cpp/checkers/Makefile index b93268b9b..aa6b8906a 100644 --- a/infer/tests/codetoanalyze/cpp/checkers/Makefile +++ b/infer/tests/codetoanalyze/cpp/checkers/Makefile @@ -23,7 +23,6 @@ SOURCES = \ siof/siof_templated.cpp \ siof/siof_different_tu.cpp \ siof/std_ios_base_init.cpp \ - bufferoverrun/vector.cpp \ HEADERS = siof/siof_types.h