diff --git a/src/kernel_services/ast_queries/json_compilation_database.ok.ml b/src/kernel_services/ast_queries/json_compilation_database.ok.ml index 3c93f7eac0c997f2ab1b2f508a04282dbbfe7a96..6ae9e02ee25d6cdd5f5b409eebf0acedb0d45063 100644 --- a/src/kernel_services/ast_queries/json_compilation_database.ok.ml +++ b/src/kernel_services/ast_queries/json_compilation_database.ok.ml @@ -128,7 +128,7 @@ let quote_define_argument arg = Format.sprintf "%S" arg let parse_entry ?(cwd=Sys.getcwd()) (r : Yojson.Basic.json) = let open Yojson.Basic.Util in let filename = r |> member "file" |> to_string in - let dirname = r |> member "directory" |> to_string in + let dirname = r |> member "directory" |> to_string_option |> Extlib.opt_conv "" in let path = Datatype.Filepath.of_string ~base_name:dirname filename in (* get the list of arguments, and a flag indicating if the arguments diff --git a/tests/jcdb/compile_commands.json b/tests/jcdb/compile_commands.json index 4e2de9499f1dbb67517964f3363f5dcae6e38b35..dc47faa00ea9db4540ab33453afbd21de9f5e388 100644 --- a/tests/jcdb/compile_commands.json +++ b/tests/jcdb/compile_commands.json @@ -10,5 +10,9 @@ { "directory": "tests/jcdb", "command": "/usr/bin/clang++ -D'MSG=\"a \\\" \\\"b\"' -D'SINGLE_DOUBLE(a)=\"a \\\"with spaces and tab \"' -DSOMEDEF=\"With spaces, quotes and \\-es.\" -D\"DOUBLE_SINGLE(a)=a \\\"macro with spaces and non-escaped \\\\'\\\"\" -DEMPTY='' -DEMPTY2= -DTEST=42 -D'MACRO_FOR_INCR(s)=s+1' -DTOUNDEF -UTOUNDEF", "file": "jcdb.c" + }, + { + "command": "testing entry without 'directory' key", + "file": "jcdb.c" } ]