diff --git a/Makefile b/Makefile index 95ca971c3..f267572ed 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ ifeq ($(IS_FACEBOOK_TREE),yes) include $(ROOT_DIR)/facebook/Makefile.env endif -BUILD_SYSTEMS_TESTS = assembly clang_translation project_root_rel +BUILD_SYSTEMS_TESTS = assembly clang_translation linters project_root_rel ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant endif diff --git a/infer/src/clang/ComponentKit.ml b/infer/src/clang/ComponentKit.ml index d08e1b966..f7c04b1e4 100644 --- a/infer/src/clang/ComponentKit.ml +++ b/infer/src/clang/ComponentKit.ml @@ -25,7 +25,7 @@ let is_in_main_file translation_unit_context an = | None -> false | Some file -> - DB.inode_equal + DB.source_file_equal (CLocation.source_file_from_path file) translation_unit_context.CFrontend_config.source_file diff --git a/infer/src/clang/cLocation.ml b/infer/src/clang/cLocation.ml index ce8ceb26a..6635a3100 100644 --- a/infer/src/clang/cLocation.ml +++ b/infer/src/clang/cLocation.ml @@ -45,7 +45,7 @@ let should_do_frontend_check trans_unit_ctx (loc_start, _) = match loc_start.Clang_ast_t.sl_file with | Some file -> let equal_current_source file = - DB.inode_equal (source_file_from_path file) + DB.source_file_equal (source_file_from_path file) trans_unit_ctx.CFrontend_config.source_file in equal_current_source file || (file_in_project file && not Config.testing_mode) diff --git a/infer/tests/build_systems/codetoanalyze/linters/src/main.mm b/infer/tests/build_systems/codetoanalyze/linters/src/main.mm new file mode 100644 index 000000000..8bd0ecc56 --- /dev/null +++ b/infer/tests/build_systems/codetoanalyze/linters/src/main.mm @@ -0,0 +1,10 @@ +#include "../../../../codetoanalyze/objcpp/linters/componentkit/FakeComponentKitHeader.h" + +@interface SomeClass : CKCompositeComponent +@end +@implementation SomeClass ++ (instancetype) new { + int i; // error + return nil; +} +@end diff --git a/infer/tests/build_systems/codetoanalyze/linters/tsrc_symlink b/infer/tests/build_systems/codetoanalyze/linters/tsrc_symlink new file mode 120000 index 000000000..aa8e45f12 --- /dev/null +++ b/infer/tests/build_systems/codetoanalyze/linters/tsrc_symlink @@ -0,0 +1 @@ +src/ \ No newline at end of file diff --git a/infer/tests/build_systems/linters/Makefile b/infer/tests/build_systems/linters/Makefile new file mode 100644 index 000000000..cee362017 --- /dev/null +++ b/infer/tests/build_systems/linters/Makefile @@ -0,0 +1,18 @@ +# 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. + +SYM_ROOT = ../codetoanalyze/linters/tsrc_symlink + +TESTS_DIR = ../.. +ANALYZER = linters +CLANG_OPTIONS = -x objective-c++ -std=c++11 -fblocks -c +INFER_OPTIONS = --no-filtering --debug-exceptions --project_root $(SYM_ROOT) +INFERPRINT_OPTIONS = --issues-tests + +SOURCES = $(SYM_ROOT)/main.mm + +include $(TESTS_DIR)/clang.make diff --git a/infer/tests/build_systems/linters/issues.exp b/infer/tests/build_systems/linters/issues.exp new file mode 100644 index 000000000..a9ec4a23c --- /dev/null +++ b/infer/tests/build_systems/linters/issues.exp @@ -0,0 +1 @@ +main.mm, SomeClass_new, 7, MUTABLE_LOCAL_VARIABLE_IN_COMPONENT_FILE, []