[Lldb-commits] [PATCH] D41086: [lldb] Check that a regex is valid before searching by regex for a symbol in a pdb.

Aaron Smith via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 18 20:47:18 PST 2017

asmith added inline comments.

Comment at: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp:393
   // 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);
clayborg wrote:
> I would rather not sniff the string passed in to see if this could be a regex and add a new FindTypesByRegex() call to lldb_private::SymbolFile that anyone can use. Do we have PDB tests that are using this functionality?
The error can be reproduced with:

image lookup -t char*



More information about the lldb-commits mailing list