<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 23, 2016 at 12:16 AM, George Rimar via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">grimar updated this revision to Diff 48785.<br>
grimar added a comment.<br>
<br>
Addressed David's and Rui's review comments.<br>
<span class=""><br>
<br>
<a href="http://reviews.llvm.org/D17499" rel="noreferrer" target="_blank">http://reviews.llvm.org/D17499</a><br>
<br>
Files:<br>
ELF/LinkerScript.cpp<br>
<br>
Index: ELF/LinkerScript.cpp<br>
===================================================================<br>
--- ELF/LinkerScript.cpp<br>
+++ ELF/LinkerScript.cpp<br>
</span>@@ -94,21 +94,11 @@<br>
}<br>
<br>
class elf2::ScriptParser {<br>
+ typedef void (ScriptParser::*Handler)();<br>
<span class="">+<br>
public:<br>
ScriptParser(BumpPtrAllocator *A, StringRef S, bool B)<br>
- : Saver(*A), Tokens(tokenize(S)), IsUnderSysroot(B) {<br>
- Cmd["ENTRY"] = std::mem_fn(&ScriptParser::readEntry);<br>
- Cmd["EXTERN"] = std::mem_fn(&ScriptParser::readExtern);<br>
- Cmd["GROUP"] = std::mem_fn(&ScriptParser::readGroup);<br>
- Cmd["INCLUDE"] = std::mem_fn(&ScriptParser::readInclude);<br>
- Cmd["INPUT"] = std::mem_fn(&ScriptParser::readGroup);<br>
- Cmd["OUTPUT"] = std::mem_fn(&ScriptParser::readOutput);<br>
- Cmd["OUTPUT_ARCH"] = std::mem_fn(&ScriptParser::readOutputArch);<br>
- Cmd["OUTPUT_FORMAT"] = std::mem_fn(&ScriptParser::readOutputFormat);<br>
- Cmd["SEARCH_DIR"] = std::mem_fn(&ScriptParser::readSearchDir);<br>
- Cmd["SECTIONS"] = std::mem_fn(&ScriptParser::readSections);<br>
- Cmd[";"] = [](ScriptParser &) {};<br>
- }<br>
+ : Saver(*A), Tokens(tokenize(S)), IsUnderSysroot(B) {}<br>
<br>
void run();<br>
<br>
</span>@@ -128,6 +118,7 @@<br>
void readExtern();<br>
void readGroup();<br>
void readInclude();<br>
+ void readNothing() {}<br>
void readOutput();<br>
void readOutputArch();<br>
void readOutputFormat();<br>
@@ -139,22 +130,30 @@<br>
<span class=""><br>
StringSaver Saver;<br>
std::vector<StringRef> Tokens;<br>
- llvm::StringMap<std::function<void(ScriptParser &)>> Cmd;<br>
</span>+ const llvm::StringMap<Handler> Cmd{<br></blockquote><div><br></div><div>Presumably static, too (which means you'll need to have a separate definition) - no point having a copy of this in every instance of this class, right?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="">+ {"ENTRY", &ScriptParser::readEntry},<br>
+ {"EXTERN", &ScriptParser::readExtern},<br>
+ {"GROUP", &ScriptParser::readGroup},<br>
+ {"INCLUDE", &ScriptParser::readInclude},<br>
+ {"INPUT", &ScriptParser::readGroup},<br>
+ {"OUTPUT", &ScriptParser::readOutput},<br>
+ {"OUTPUT_ARCH", &ScriptParser::readOutputArch},<br>
+ {"OUTPUT_FORMAT", &ScriptParser::readOutputFormat},<br>
+ {"SEARCH_DIR", &ScriptParser::readSearchDir},<br>
+ {"SECTIONS", &ScriptParser::readSections},<br>
</span>+ {";", &ScriptParser::readNothing}};<br>
<span class=""> size_t Pos = 0;<br>
bool IsUnderSysroot;<br>
bool Error = false;<br>
</span> };<br>
<br>
void ScriptParser::run() {<br>
while (!atEOF()) {<br>
StringRef Tok = next();<br>
- auto It = Cmd.find(Tok);<br>
- if (It != Cmd.end()) {<br>
<span class="">- std::function<void(ScriptParser &)> &Handler = It->second;<br>
- Handler(*this);<br>
</span>- } else {<br>
+ if (Handler Fn = Cmd.lookup(Tok))<br>
+ (this->*Fn)();<br>
+ else<br>
<span class=""> setError("unknown directive: " + Tok);<br>
</span>- }<br>
}<br>
}<br>
<br>
<br>
<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>