Summary: Some compilation databases give relatives paths for the `"file"` field. This is not ambiguous as there is also a `"dir"` field, so use that to make the path absolute when needed. Reviewed By: dulmarod Differential Revision: D4559145 fbshipit-source-id: be36a16master
parent
f3c181f204
commit
08aad39050
@ -0,0 +1,34 @@
|
|||||||
|
# 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 = infer
|
||||||
|
INFER_OPTIONS = --report-custom-error --developer-mode
|
||||||
|
SOURCES = \
|
||||||
|
../codetoanalyze/hello.c ../codetoanalyze/hello2.c ../codetoanalyze/hello3.c \
|
||||||
|
../codetoanalyze/path\ with\ spaces/hel\ lo.c
|
||||||
|
OBJECTS = $(SOURCES:.c=.o)
|
||||||
|
CLEAN_EXTRA = compile_commands.json ../codetoanalyze/path\ with\ spaces
|
||||||
|
INFERPRINT_OPTIONS = --issues-tests
|
||||||
|
|
||||||
|
include $(TESTS_DIR)/base.make
|
||||||
|
|
||||||
|
../codetoanalyze/path\ with\ spaces/hel\ lo.c: ../codetoanalyze/path_with_spaces/hel_lo.c
|
||||||
|
# make does not want to interpret "$(@D)" in the right way here...
|
||||||
|
$(MKDIR_P) ../codetoanalyze/path\ with\ spaces/
|
||||||
|
@cp "$<" "$@"
|
||||||
|
@touch "$@"
|
||||||
|
|
||||||
|
compile_commands.json: compile_commands.json.in
|
||||||
|
sed -e 's#%pwd%#$(CURDIR)#g' $< > $@ || $(REMOVE) $@
|
||||||
|
|
||||||
|
infer-out/report.json: compile_commands.json $(SOURCES) Makefile \
|
||||||
|
../codetoanalyze/path\ with\ spaces/hel\ lo.c
|
||||||
|
$(call silent_on_success,\
|
||||||
|
$(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) --project-root $(TESTS_DIR) \
|
||||||
|
--clang-compilation-db-files $<)
|
@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"command" : "clang -c hello.c",
|
||||||
|
"directory" : "%pwd%/../codetoanalyze",
|
||||||
|
"file" : "hello.c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory" : "%pwd%/../codetoanalyze/path with spaces",
|
||||||
|
"file" : "hel lo.c",
|
||||||
|
"command" : "clang -c hel\\ lo.c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"directory" : "%pwd%/../codetoanalyze",
|
||||||
|
"file" : "hello2.c",
|
||||||
|
"command" : "clang -c hello2.c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command" : "clang -c hello3.c",
|
||||||
|
"directory" : "%pwd%/../codetoanalyze",
|
||||||
|
"file" : "hello3.c"
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,4 @@
|
|||||||
|
build_systems/codetoanalyze/hello.c, test, 2, NULL_DEREFERENCE, [start of procedure test()]
|
||||||
|
build_systems/codetoanalyze/hello2.c, test2, 2, NULL_DEREFERENCE, [start of procedure test2()]
|
||||||
|
build_systems/codetoanalyze/hello3.c, test3, 2, NULL_DEREFERENCE, [start of procedure test3()]
|
||||||
|
build_systems/codetoanalyze/path with spaces/hel lo.c, test_hel_lo, 2, NULL_DEREFERENCE, [start of procedure test_hel_lo()]
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 - 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void test_hel_lo() {
|
||||||
|
int* s = NULL;
|
||||||
|
*s = 42;
|
||||||
|
}
|
Loading…
Reference in new issue