diff --git a/infer/src/IR/QualifiedCppName.re b/infer/src/IR/QualifiedCppName.re index c2bc454b7..d9b9edacf 100644 --- a/infer/src/IR/QualifiedCppName.re +++ b/infer/src/IR/QualifiedCppName.re @@ -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>::someMethod" will get parsed as ["foo>", - "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 }; }; diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index d40be42b0..75ae99be4 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -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 = [ diff --git a/infer/tests/codetoanalyze/cpp/errors/vector/iterator_access.cpp b/infer/tests/codetoanalyze/cpp/errors/vector/iterator_access.cpp index 4d0817c95..dc0dcb663 100644 --- a/infer/tests/codetoanalyze/cpp/errors/vector/iterator_access.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/vector/iterator_access.cpp @@ -24,7 +24,6 @@ int possible_npe(std::vector in) { return 1; } -/* FIXME: this test doesn't work with stdlibc++ headers int impossible_npe(std::vector in) { int* x = nullptr; for (auto iter = in.begin(); iter != in.end(); ++iter) { @@ -34,5 +33,4 @@ int impossible_npe(std::vector in) { } return 1; } -*/ }