[C++] Fix matching of qualified cpp names

Summary: Now procnames/types have qualified cpp names. Fix matching on them.

Reviewed By: jberdine

Differential Revision: D4762063

fbshipit-source-id: 179b7e2
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent 0f70ca02e3
commit 5cfde325fd

@ -20,23 +20,26 @@ let to_list quals => quals;
let of_list quals => quals;
let cpp_separator = "::";
/* This is simplistic and will give the wrong answer in some cases, eg
"foo<bar::baz<goo>>::someMethod" will get parsed as ["foo<bar", "baz<goo>>",
"someMethod"]. Ideally, we would keep the list of qualifiers in the procname, which would save us
from having to properly parse them. */
"someMethod"]. Avoid using it if possible */
let of_qual_string = {
let class_sep_regex = Str.regexp_string "::";
let class_sep_regex = Str.regexp_string cpp_separator;
/* wait until here to define the function so that [class_sep_regex] is only computed once */
Str.split class_sep_regex
};
let to_qual_string = String.concat sep::"::";
let to_qual_string = String.concat sep::cpp_separator;
let pp fmt quals => Format.fprintf fmt "%s" (to_qual_string quals);
let module Match = {
type quals_matcher = Str.regexp;
let regexp_string_of_qualifiers quals => Str.quote (String.concat sep::"::" quals) ^ "$";
let matching_separator = "#";
let regexp_string_of_qualifiers quals =>
Str.quote (String.concat sep::matching_separator quals) ^ "$";
let qualifiers_list_matcher quals_list =>
(
if (List.is_empty quals_list) {
@ -63,6 +66,6 @@ let module Match = {
let no_template_name s => List.hd_exn (String.split on::'<' s);
List.map f::no_template_name quals
};
Str.string_match matcher (String.concat sep::"::" normalized_qualifiers) 0
Str.string_match matcher (String.concat sep::matching_separator normalized_qualifiers) 0
};
};

@ -249,7 +249,7 @@ let whitelisted_cpp_methods = [
let whitelisted_cpp_classes = [
"std::__less";
"std::__wrap_iter"; (* libc++ internal name of vector iterator *)
"std::__normal_iterator"; (* libstdc++ internal name of vector iterator *)
"__gnu_cxx::__normal_iterator"; (* libstdc++ internal name of vector iterator *)
]
type dynamic_dispatch_policy = [

@ -24,7 +24,6 @@ int possible_npe(std::vector<X> in) {
return 1;
}
/* FIXME: this test doesn't work with stdlibc++ headers
int impossible_npe(std::vector<X> in) {
int* x = nullptr;
for (auto iter = in.begin(); iter != in.end(); ++iter) {
@ -34,5 +33,4 @@ int impossible_npe(std::vector<X> in) {
}
return 1;
}
*/
}

Loading…
Cancel
Save