} else if (auto type_def = llvm::dyn_cast<PDBSymbolTypeTypedef>(&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)
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);
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/TypeMap.h"
+#include "lldb/Utility/RegularExpression.h"
#include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/DebugInfo/PDB/IPDBDataStream.h"
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();
}
std::string name_str = name.AsCString();
- // 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.
- if (name_str.find_first_of("[]?*.-+\\") != std::string::npos)
- FindTypesByRegex(name_str, max_matches, types);
- else
- FindTypesByName(name_str, max_matches, types);
+ // There is an assumption 'name' is not a regex
+ 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
auto global = m_session_up->getGlobalScope();
std::unique_ptr<IPDBEnumSymbols> results;
- std::regex re(regex);
-
uint32_t matches = 0;
for (auto tag : tags_to_search) {
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`
const llvm::pdb::PDBSymbolCompiland &cu,
llvm::DenseMap<uint32_t, uint32_t> &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,
false, 0, searched_files, results);
EXPECT_GT(num_results, 1u);
EXPECT_EQ(num_results, results.GetSize());
+
+ // We expect no exception thrown if the given regex can't be compiled
+ results.Clear();
+ num_results = symfile->FindTypes(sc, ConstString("**"), nullptr,
+ false, 0, searched_files, results);
+ EXPECT_EQ(num_results, 0u);
+ EXPECT_EQ(num_results, results.GetSize());
}
TEST_F(SymbolFilePDBTests, TestMaxMatches) {