From b57ac1fe49c9a8b4414618cb1682f65403cad20b Mon Sep 17 00:00:00 2001 From: Dulma Rodriguez Date: Wed, 17 Jun 2015 11:19:55 -0100 Subject: [PATCH] [clang] Make the script create the absolute path rather than Ocaml. Fixes issues with symbolic links --- infer/lib/clang/clang_general_wrapper | 1 + infer/src/clang/cLocation.ml | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/infer/lib/clang/clang_general_wrapper b/infer/lib/clang/clang_general_wrapper index 906cadd24..64c9b73c9 100755 --- a/infer/lib/clang/clang_general_wrapper +++ b/infer/lib/clang/clang_general_wrapper @@ -131,6 +131,7 @@ if [ -n "$ATTACH_PLUGIN" ]; then if [ -n "$LANGUAGE" ]; then INFER_FRONTEND_ARGS+=("-x" "$LANGUAGE"); fi if [ "$FOBJC_ARC_FLAG" == 0 ]; then INFER_FRONTEND_ARGS+=("-fobjc-arc"); fi + [[ "$SOURCE_FILE" = /* ]] || { SOURCE_FILE="${CWD}/$SOURCE_FILE"; } INFERCLANG_CMD=( "${BIN_DIR}/InferClang" "-c" "$SOURCE_FILE" diff --git a/infer/src/clang/cLocation.ml b/infer/src/clang/cLocation.ml index 99bf3e877..723b6db95 100644 --- a/infer/src/clang/cLocation.ml +++ b/infer/src/clang/cLocation.ml @@ -20,20 +20,18 @@ let init_curr_source_file source_file = current_source_file := source_file let source_file_from_path path = - let path = Utils.filename_to_absolute path in + if Filename.is_relative path then + (Logging.out + "ERROR: Path %s is relative. Please pass an absolute path in the -c argument.@." + path; + exit 1); match !Config.project_root with | Some root -> (try DB.rel_source_file_from_abs_path root path with DB.Path_not_prefix_root -> DB.source_file_from_string path) - | None -> - if (Filename.is_relative path) then - (Logging.out - "ERROR: Path %s is relative. Please pass either a project root or an absolute path in the -c argument.@." - path; - exit(1)) - else (DB.source_file_from_string path) + | None -> DB.source_file_from_string path let choose_sloc sloc1 sloc2 prefer_first = let sloc_bad sloc =