Index: source/Plugins/SymbolFile/PDB/PDBASTParser.cpp =================================================================== --- source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -124,6 +124,8 @@ } else if (auto type_def = llvm::dyn_cast(&type)) { lldb_private::Type *target_type = m_ast.GetSymbolFile()->ResolveTypeUID(type_def->getTypeId()); + if (!target_type) + return nullptr; std::string name = type_def->getName(); uint64_t bytes = type_def->getLength(); if (!target_type) @@ -179,6 +181,8 @@ lldb_private::Type *element_type = m_ast.GetSymbolFile()->ResolveTypeUID(element_uid); + if (!element_type) + return nullptr; CompilerType element_ast_type = element_type->GetFullCompilerType(); CompilerType array_ast_type = m_ast.CreateArrayType(element_ast_type, num_elements, false); Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h =================================================================== --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h @@ -172,7 +172,8 @@ const llvm::pdb::PDBSymbolCompiland &cu, llvm::DenseMap &index_map) const; - void FindTypesByRegex(const std::string ®ex, uint32_t max_matches, + void FindTypesByRegex(const lldb_private::RegularExpression ®ex, + uint32_t max_matches, lldb_private::TypeMap &types); void FindTypesByName(const std::string &name, uint32_t max_matches, Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp =================================================================== --- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -251,7 +251,8 @@ return nullptr; lldb::TypeSP result = pdb->CreateLLDBTypeFromPDBType(*pdb_type); - m_types.insert(std::make_pair(type_uid, result)); + if (result.get()) + m_types.insert(std::make_pair(type_uid, result)); return result.get(); } @@ -389,23 +390,17 @@ // If this might be a regex, we have to return EVERY symbol and process them // one by one, which is going to destroy performance on large PDB files. So // try really hard not to use a regex match. - bool is_regex = false; - if (name_str.find_first_of("[]?*.-+\\") != std::string::npos) { - // Trying to compile an invalid regex could throw an exception. - // Only search by regex when it's valid. - lldb_private::RegularExpression name_regex(name_str); - is_regex = name_regex.IsValid(); - } - if (is_regex) - FindTypesByRegex(name_str, max_matches, types); + if (name_str.find_first_of("[]?*.-+\\") != std::string::npos) + FindTypesByRegex(RegularExpression(name_str), max_matches, types); else FindTypesByName(name_str, max_matches, types); return types.GetSize(); } -void SymbolFilePDB::FindTypesByRegex(const std::string ®ex, - uint32_t max_matches, - lldb_private::TypeMap &types) { +void +SymbolFilePDB::FindTypesByRegex(const lldb_private::RegularExpression ®ex, + uint32_t max_matches, + lldb_private::TypeMap &types) { // When searching by regex, we need to go out of our way to limit the search // space as much as possible since this searches EVERYTHING in the PDB, // manually doing regex comparisons. PDB library isn't optimized for regex @@ -417,8 +412,6 @@ auto global = m_session_up->getGlobalScope(); std::unique_ptr results; - std::regex re(regex); - uint32_t matches = 0; for (auto tag : tags_to_search) { @@ -441,7 +434,7 @@ continue; } - if (!std::regex_match(type_name, re)) + if (!regex.Execute(type_name)) continue; // This should cause the type to get cached and stored in the `m_types`