<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 1, 2016 at 8:46 PM Tim Northover via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">t.p.northover added inline comments.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: llvm/trunk/lib/MC/MCContext.cpp:263<br class="gmail_msg">
<br class="gmail_msg">
+int MCContext::setSymbolValue(MCStreamer &Streamer, std::string &I) {<br class="gmail_msg">
+    auto Pair = StringRef(I).split('=');<br class="gmail_msg">
----------------<br class="gmail_msg">
grosbach wrote:<br class="gmail_msg">
> echristo wrote:<br class="gmail_msg">
> > mgrang wrote:<br class="gmail_msg">
> > > grosbach wrote:<br class="gmail_msg">
> > > > The error checking shouldn't be in the setter function, but rather in the caller.<br class="gmail_msg">
> > > @grosbach Thanks for your comments.<br class="gmail_msg">
> > ><br class="gmail_msg">
> > > This function is called from llvm-mc as well as from cc1as_main in clang. Is it OK if I create an error checker function here and call it from both the call sites? Otherwise we would end up duplicating the error checking logic in both call sites.<br class="gmail_msg">
> > The applications often have their own error handling. If you want to put something in Support that can be easily handled it's fine, but otherwise it's best if you just duplicate it. Happy to look at code that does either.<br class="gmail_msg">
> That's not the function of MCContext. The diagnostic checking really should be in the callers even if it's duplicated. Consider, for example, that llvm-mc is a development testing tool for LLVM developers and clang is an end-user tool. It is entirely possible that  we would want different checking and behaviours for those use cases.<br class="gmail_msg">
> The diagnostic checking really should be in the callers even if it's duplicated<br class="gmail_msg">
<br class="gmail_msg">
Really, the MC layer shouldn't even be in the business of parsing a user-facing Clang option like this (even if it's guaranteed error-free). Users should provide the symbol and the value separately.<br class="gmail_msg">
<br class="gmail_msg"></blockquote><div><br></div><div>Agreed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
Repository:<br class="gmail_msg">
  rL LLVM<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D26214" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D26214</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>