[DB] return resolved path when path cannot be made relative

Summary:
This makes it more obvious why infer would force a path to be absolute since we
base that decision on the resolved path. For instance:

```
$ mkdir foo
$ cd foo
$ ln -s ../examples goo
$ infer -- clang -c goo/hello.c
[...]
/home/jul/infer/examples/hello.c:14: error: NULL_DEREFERENCE
```

We see that the path is outside of the current directory clearly, whereas
before infer would report on "goo/hello.c".

Reviewed By: akotulski

Differential Revision: D4409579

fbshipit-source-id: 7172005
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 1891a16f8f
commit c10126d0fd

@ -47,7 +47,7 @@ let from_abs_path fname =
| None -> ( | None -> (
match Utils.filename_to_relative ~root:models_dir_real fname_real with match Utils.filename_to_relative ~root:models_dir_real fname_real with
| Some path -> RelativeInferModel path | Some path -> RelativeInferModel path
| None -> Absolute fname (* fname is absolute already *) | None -> Absolute fname_real (* fname_real is absolute already *)
) )
let curr_encoding = `Enc_crc let curr_encoding = `Enc_crc

@ -13,7 +13,7 @@ CMAKE_ANALYZE_DIR = $(CMAKE_DIR)/_build_infer
ANALYZER = infer ANALYZER = infer
CLEAN_EXTRA = $(CMAKE_BUILD_DIR) $(CMAKE_ANALYZE_DIR) CLEAN_EXTRA = $(CMAKE_BUILD_DIR) $(CMAKE_ANALYZE_DIR)
INFER_OPTIONS = --project-root $(CMAKE_DIR) INFER_OPTIONS = --project-root $(TESTS_DIR)
SOURCES = $(CMAKE_DIR)/hello.c SOURCES = $(CMAKE_DIR)/hello.c
OBJECTS = $(CMAKE_BUILD_DIR)/CMakeFiles/Hello.dir/hello.c.o OBJECTS = $(CMAKE_BUILD_DIR)/CMakeFiles/Hello.dir/hello.c.o
INFERPRINT_OPTIONS = --issues-tests INFERPRINT_OPTIONS = --issues-tests
@ -39,4 +39,4 @@ infer-out/report.json: $(SOURCES) $(CMAKE_DIR)/CMakeLists.txt $(CLANG_DEPS)
$(call silent_on_success,\ $(call silent_on_success,\
$(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -- $(MAKE) -C $(CMAKE_ANALYZE_DIR)) $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -- $(MAKE) -C $(CMAKE_ANALYZE_DIR))
# cmake makes all paths absolute # cmake makes all paths absolute
@sed -i -e 's#$(abspath $(CMAKE_DIR))/##g' $@ @sed -i -e 's#$(abspath $(TESTS_DIR))/##g' $@

@ -1 +1 @@
hello.c, test, 2, NULL_DEREFERENCE, [start of procedure test()] build_systems/codetoanalyze/hello.c, test, 2, NULL_DEREFERENCE, [start of procedure test()]

@ -1 +1 @@
../../../../../examples/hello.c ../hello.c

@ -30,6 +30,7 @@ genrule: $(ROOT_DIR)/buck-out/genruletest/gen/infer/tests/build_systems/genrule/
$(ROOT_DIR)/buck-out/genruletest/gen/infer/tests/build_systems/genrule/module2/module2_infer/infer_out/report.json: \ $(ROOT_DIR)/buck-out/genruletest/gen/infer/tests/build_systems/genrule/module2/module2_infer/infer_out/report.json: \
$(JAVA_DEPS) $(JAVA_SOURCE_FILES) $(JAVA_DEPS) $(JAVA_SOURCE_FILES)
cd $(ROOT_DIR) && \ cd $(ROOT_DIR) && \
$(REMOVE_DIR) buck-out && \
$(call silent_on_success,\ $(call silent_on_success,\
INFER_BIN="$(INFER_BIN)" NO_BUCKD=1 GENERATE_INFER_GENRULES=1 \ INFER_BIN="$(INFER_BIN)" NO_BUCKD=1 GENERATE_INFER_GENRULES=1 \
buck build --config project.buck_out=buck-out/genruletest --no-cache //infer/tests/build_systems/genrule/module2:module2_infer) buck build --config project.buck_out=buck-out/genruletest --no-cache //infer/tests/build_systems/genrule/module2:module2_infer)
@ -38,4 +39,4 @@ $(ROOT_DIR)/buck-out/genruletest/gen/infer/tests/build_systems/genrule/module2/m
infer-out/report.json: $(ROOT_DIR)/buck-out/genruletest/gen/infer/tests/build_systems/genrule/module2/module2_infer/infer_out/report.json infer-out/report.json: $(ROOT_DIR)/buck-out/genruletest/gen/infer/tests/build_systems/genrule/module2/module2_infer/infer_out/report.json
$(MKDIR_P) infer-out $(MKDIR_P) infer-out
# the report contains absolute paths # the report contains absolute paths
@sed -e 's#$(abspath $(ROOT_DIR))/##g' $< > $@ @sed -e 's#$(abspath $(TESTS_DIR))/##g' $< > $@

@ -1 +1 @@
buck-out/genruletest/gen/infer/tests/build_systems/genrule/module2/module2_infer__srcs/Class2.java, void Class2.localNPE2(), 2, NULL_DEREFERENCE, [start of procedure localNPE2()] build_systems/genrule/module2/Class2.java, void Class2.localNPE2(), 2, NULL_DEREFERENCE, [start of procedure localNPE2()]

Loading…
Cancel
Save