[C++] Create notion of generic procname, it will be used to store specs of generic models

Summary:
Initial version of naming, required for generic models. It's simply non mangled name stripped from any template arguments.
This makes it impossible to have two generic models with
1. different template arguments
2. different overloads (function with same name, but different types of arguments)

Reviewed By: jberdine

Differential Revision: D4826358

fbshipit-source-id: 42ac763
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 899cfadfbd
commit a90525f627

@ -22,6 +22,11 @@ let extract_last =
| [last, ...rest] => Some (last, rest)
| [] => None;
let strip_template_args quals => {
let no_template_name s => List.hd_exn (String.split on::'<' s);
List.map f::no_template_name quals
};
let to_list = List.rev;
let to_rev_list = ident;
@ -72,12 +77,9 @@ let module Match = {
let of_fuzzy_qual_names fuzzy_qual_names =>
List.map fuzzy_qual_names f::qualifiers_of_fuzzy_qual_name |> qualifiers_list_matcher;
let match_qualifiers matcher quals => {
let normalized_qualifiers = {
/* qual_name may have qualifiers with template parameters - drop them to whitelist all
instantiations */
let no_template_name s => List.hd_exn (String.split on::'<' s);
List.map f::no_template_name quals
};
/* qual_name may have qualifiers with template parameters - drop them to whitelist all
instantiations */
let normalized_qualifiers = strip_template_args quals;
Str.string_match matcher (to_separated_string sep::matching_separator normalized_qualifiers) 0
};
};

@ -33,6 +33,12 @@ let append_qualifier: t => qual::string => t;
let extract_last: t => option (string, t);
/** returns qualified name without template arguments. For example:
input: std::shared_ptr<int>::shared_ptr<long>
output: std::shared_ptr::shared_ptr */
let strip_template_args: t => t;
/** returns list of qualifers */
let to_list: t => list string;

@ -901,7 +901,7 @@ let module Procname = {
};
/** Convert a proc name to a filename */
let to_filename pname => {
let to_concrete_filename pname => {
/* filenames for clang procs are REVERSED qualifiers with '#' as separator */
let get_qual_name_str pname =>
get_qualifiers pname |> QualifiedCppName.to_rev_list |> String.concat sep::"#";
@ -915,6 +915,13 @@ let module Procname = {
};
Escape.escape_filename @@ SourceFile.append_crc_cutoff proc_id
};
let to_generic_filename pname => {
let proc_id =
get_qualifiers pname |> QualifiedCppName.strip_template_args |> QualifiedCppName.to_rev_list |>
String.concat sep::"#";
Escape.escape_filename @@ SourceFile.append_crc_cutoff proc_id
};
let to_filename = to_concrete_filename;
};

Loading…
Cancel
Save