Fix expression parser to not accept any type whose basename matches for a type that must exist at root level

This patch fixes an issue where we weren't looking for exact matches in the expression parser and also fixed the type lookup logic in the Module.cpp. Tests added to make sure we don't regress.

Differential Revision: https://reviews.llvm.org/D46128

llvm-svn: 331227
This commit is contained in:
Greg Clayton
2018-04-30 21:06:30 +00:00
parent dab8515370
commit c485f056b7
5 changed files with 173 additions and 5 deletions

View File

@@ -1004,16 +1004,22 @@ size_t Module::FindTypes(
} else {
// The type is not in a namespace/class scope, just search for it by
// basename
if (type_class != eTypeClassAny) {
if (type_class != eTypeClassAny && !type_basename.empty()) {
// The "type_name_cstr" will have been modified if we have a valid type
// class prefix (like "struct", "class", "union", "typedef" etc).
FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
max_matches, searched_symbol_files, typesmap);
typesmap.RemoveMismatchedTypes(type_class);
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
num_matches = typesmap.GetSize();
} else {
num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches,
searched_symbol_files, typesmap);
if (exact_match) {
std::string name_str(name.AsCString(""));
typesmap.RemoveMismatchedTypes(type_scope, name_str, type_class,
exact_match);
}
}
}
if (num_matches > 0)