Skip to content

Commit c4b94da

Browse files
authored
flambda-backend: DWARF inlined frames support (#1754)
1 parent ba455b4 commit c4b94da

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

utils/compilation_unit.ml

+8-7
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,14 @@ let create_child parent name_ =
245245

246246
let of_string str =
247247
let for_pack_prefix, name =
248-
match String.rindex_opt str '.' with
249-
| None -> Prefix.empty, Name.of_string str
250-
| Some 0 ->
251-
(* See [Name.check_as_path_component]; this allows ".cinaps" as a
252-
compilation unit *)
253-
Prefix.empty, Name.of_string str
254-
| Some _ -> Misc.fatal_errorf "[of_string] does not parse qualified names"
248+
(* Also see [Name.check_as_path_component] *)
249+
if String.equal str ".cinaps" || String.equal str "(.cinaps)"
250+
then Prefix.empty, Name.of_string str
251+
else
252+
match String.rindex_opt str '.' with
253+
| None -> Prefix.empty, Name.of_string str
254+
| Some _ ->
255+
Misc.fatal_errorf "[of_string] does not parse qualified names: %s" str
255256
in
256257
create for_pack_prefix name
257258

utils/misc.ml

+21
Original file line numberDiff line numberDiff line change
@@ -1443,3 +1443,24 @@ end
14431443
module type T4 = sig
14441444
type ('a, 'b, 'c, 'd) t
14451445
end
1446+
1447+
let remove_double_underscores s =
1448+
let len = String.length s in
1449+
let buf = Buffer.create len in
1450+
let skip = ref false in
1451+
let rec loop i =
1452+
if i < len
1453+
then (
1454+
let c = String.get s i in
1455+
if c = '.' then skip := true;
1456+
if (not !skip) && c = '_' && i + 1 < len && String.get s (i + 1) = '_'
1457+
then (
1458+
Buffer.add_char buf '.';
1459+
skip := true;
1460+
loop (i + 2))
1461+
else (
1462+
Buffer.add_char buf c;
1463+
loop (i + 1)))
1464+
in
1465+
loop 0;
1466+
Buffer.contents buf

utils/misc.mli

+2
Original file line numberDiff line numberDiff line change
@@ -895,3 +895,5 @@ end
895895
type filepath = string
896896

897897
type alerts = string Stdlib.String.Map.t
898+
899+
val remove_double_underscores : string -> string

0 commit comments

Comments
 (0)