[PATCH] D23829: [ELF] - Use std::regex instead of hand written logic in elf::globMatch()
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 16:40:15 PDT 2016
ruiu added inline comments.
================
Comment at: ELF/LinkerScript.cpp:836-841
@@ -831,8 +835,8 @@
-std::vector<StringRef> ScriptParser::readInputFilePatterns() {
- std::vector<StringRef> V;
+std::vector<std::regex> ScriptParser::readInputFilePatterns() {
+ std::vector<std::regex> V;
while (!Error && !skip(")"))
- V.push_back(next());
+ V.push_back(toRegex(next()));
return V;
}
----------------
This function can return a std::regex instead of a vector of std::regexs by concatenating regexs using `|`.
================
Comment at: ELF/Strings.cpp:29-30
@@ +28,4 @@
+
+// This is a hand-written state machine to convert
+// a glob pattern to a regex.
+std::regex elf::toRegex(StringRef S) {
----------------
This is not a state machine.
================
Comment at: ELF/SymbolTable.cpp:486
@@ -485,3 +485,3 @@
template <class ELFT>
-std::vector<SymbolBody *> SymbolTable<ELFT>::findAll(StringRef Pattern) {
+std::vector<SymbolBody *> SymbolTable<ELFT>::findAll(const std::regex& Pattern) {
std::vector<SymbolBody *> Res;
----------------
clang-format
================
Comment at: ELF/SymbolTable.h:94
@@ -91,3 +93,3 @@
private:
- std::vector<SymbolBody *> findAll(StringRef Pattern);
+ std::vector<SymbolBody *> findAll(const std::regex& Pattern);
std::pair<Symbol *, bool> insert(StringRef &Name);
----------------
clang-format
https://reviews.llvm.org/D23829
More information about the llvm-commits
mailing list