From 96d59317448114a889702cde6f5bd3689ae66eaa Mon Sep 17 00:00:00 2001 From: Rohan Jacob-Rao Date: Thu, 13 Aug 2015 10:15:05 -0700 Subject: [PATCH] Report source file name in error log. --- infer/src/llvm/lTrans.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/infer/src/llvm/lTrans.ml b/infer/src/llvm/lTrans.ml index a33ca0345..e789f3f5b 100644 --- a/infer/src/llvm/lTrans.ml +++ b/infer/src/llvm/lTrans.ml @@ -36,13 +36,18 @@ let rec trans_typ : LAst.typ -> Sil.typ = function | Tlabel -> raise (ImproperTypeError "Tried to generate Sil type from LLVM label type.") | Tmetadata -> raise (ImproperTypeError "Tried to generate Sil type from LLVM metadata type.") +let get_source_filename (metadata : LAst.metadata_map) : DB.source_file = + match MetadataMap.find 1 metadata with + | MetadataVal (MetadataString file_str) :: _ -> DB.source_file_from_string file_str + | _ -> raise (MalformedMetadata "Source file name was expected at head of metadata variable !1.") + let location_of_annotation_option (metadata : LAst.metadata_map) : LAst.annotation option -> Sil.location = function | None -> Sil.dummy_location (* no annotation means no source location *) | Some (Annotation i) -> begin match MetadataMap.find i metadata with | TypOperand (_, Const (Cint line_num)) :: _ -> let open Sil in - { line = line_num; col = -1; file = DB.source_file_empty; nLOC = -1 } + { line = line_num; col = -1; file = get_source_filename metadata; nLOC = -1 } | [] -> raise (MalformedMetadata "Instruction annotation refers to empty metadata node.") | _ -> raise (MalformedMetadata ("Instruction annotation refers to metadata node " ^ "without line number as first component."))