[PATCH] D23829: [ELF] - Use std::regex instead of hand written logic in elf::globMatch()

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 04:26:52 PDT 2016


grimar added inline comments.

================
Comment at: ELF/Config.h:47-49
@@ -38,3 +46,5 @@
+
   llvm::StringRef Name;
   bool IsExternCpp;
+  std::regex Wildcard;
 };
----------------
grimar wrote:
> ruiu wrote:
> > I wouldn't think that this class is designed well. `Name` and `Wildcard` are mutually exclusive, and if `hasWildcard(Sym.Name)` is false, you need to use `Sym.Wildcard`. That's not easy to understand.
> That is because I am trying not to use regex matching when it is unnessecary, like in next case:
> SymbolTable.cpp(linke 646)
> ```
> SymbolBody *B = Sym.IsExternCpp ? Demangled[Sym.Name] : find(Sym.Name);
> ```
> 
> I can probably introduce some helper method hiding this logic.
> 
I think we do not need that new field at all. It can be created on demand since only used in scanVersionScript(). I removed it.

================
Comment at: ELF/Strings.cpp:46
@@ +45,3 @@
+// Returns true if S matches T.
+bool elf::globMatch(const std::regex& S, StringRef T) {
+  return std::regex_match(T.begin(), T.end(), S);
----------------
ruiu wrote:
> You need to remove this function. This is not even a "glob" match anymore.
Done.


https://reviews.llvm.org/D23829





More information about the llvm-commits mailing list