<div dir="ltr">Oh, sorry - I see, you meant the macro that enables checking in llvm::Error, right.<br><br>The thing is it doesn't respect your checking an Expected<T>, just checking the llvm::Error.<br><br>So something like this. Actually, I think you don't even need the boolean return:<br><br>  handleAllErrors(Expecte.takeError(), [](const llvm::ErrorInfoBase &EI) {<br>    FAIL() << EI.message();<br>  });<br><br>This should produce a fatal failure, which terminates gtest execution (with an exception or otherwise), so the code after this shouldn't need to conditionally return or anything - the fact that this function returns at all is sufficient. I can double check this for you if you like - but pretty sure that's how the gtest documentation reads. (FAIL is like ASSERT_TRUE(false) - assertions are fatal checks, terminating execution of the test)<br><br><a href="https://github.com/google/googletest/blob/master/googletest/docs/Primer.md">https://github.com/google/googletest/blob/master/googletest/docs/Primer.md</a> <br><a href="https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md">https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md</a><br><br>(at this point, maybe the 3 lines are short enough you could put them inline ratehr than having a separate function - but maybe not? Up to you)<br><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 12, 2016 at 2:38 PM Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg">
> On Dec 12, 2016, at 2:30 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="gmail_msg" target="_blank">dblaikie@gmail.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> On Mon, Dec 12, 2016 at 2:05 PM Greg Clayton <<a href="mailto:gclayton@apple.com" class="gmail_msg" target="_blank">gclayton@apple.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> > On Dec 12, 2016, at 1:59 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="gmail_msg" target="_blank">dblaikie@gmail.com</a>> wrote:<br class="gmail_msg">
> ><br class="gmail_msg">
> ><br class="gmail_msg">
> ><br class="gmail_msg">
> > On Wed, Dec 7, 2016 at 6:21 PM Greg Clayton via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br class="gmail_msg">
> > Author: gclayton<br class="gmail_msg">
> > Date: Wed Dec  7 20:11:03 2016<br class="gmail_msg">
> > New Revision: 289017<br class="gmail_msg">
> ><br class="gmail_msg">
> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=289017&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=289017&view=rev</a><br class="gmail_msg">
> > Log:<br class="gmail_msg">
> > Unbreak buildbots where the debug info test was crashing due to unchecked error.<br class="gmail_msg">
> ><br class="gmail_msg">
> ><br class="gmail_msg">
> > Modified:<br class="gmail_msg">
> >     llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp<br class="gmail_msg">
> ><br class="gmail_msg">
> > Modified: llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp<br class="gmail_msg">
> > URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp?rev=289017&r1=289016&r2=289017&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp?rev=289017&r1=289016&r2=289017&view=diff</a><br class="gmail_msg">
> > ==============================================================================<br class="gmail_msg">
> > --- llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp (original)<br class="gmail_msg">
> > +++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp Wed Dec  7 20:11:03 2016<br class="gmail_msg">
> > @@ -51,14 +51,15 @@ Triple getHostTripleForAddrSize(uint8_t<br class="gmail_msg">
> >  /// \returns true if there were errors, false otherwise.<br class="gmail_msg">
> >  template <typename T><br class="gmail_msg">
> >  static bool HandleExpectedError(T &Expected) {<br class="gmail_msg">
> > -  if (!Expected)<br class="gmail_msg">
> > -    return false;<br class="gmail_msg">
> >    std::string ErrorMsg;<br class="gmail_msg">
> >    handleAllErrors(Expected.takeError(), [&](const llvm::ErrorInfoBase &EI) {<br class="gmail_msg">
> >      ErrorMsg = EI.message();<br class="gmail_msg">
> >    });<br class="gmail_msg">
> > -  ::testing::AssertionFailure() << "error: " << ErrorMsg;<br class="gmail_msg">
> > -  return true;<br class="gmail_msg">
> > +  if (!ErrorMsg.empty()) {<br class="gmail_msg">
> > +    ::testing::AssertionFailure() << "error: " << ErrorMsg;<br class="gmail_msg">
> > +    return true;<br class="gmail_msg">
> > +  }<br class="gmail_msg">
> > +  return false;<br class="gmail_msg">
> ><br class="gmail_msg">
> > I think this could be written a bit simpler and without relying on the error string being non-empty, etc.<br class="gmail_msg">
> ><br class="gmail_msg">
> > Oh, huh - Lang, any ideas?<br class="gmail_msg">
> ><br class="gmail_msg">
> > It'd be nice if handleAllErrors could return a value (if all handlers returned the same/compatibible) - though I guess then it'd need a default value.<br class="gmail_msg">
> ><br class="gmail_msg">
> > Lang, would it be more idiomatic here to test the error for non-failure ,return false, otherwise then handleAllErrors and return true.<br class="gmail_msg">
> ><br class="gmail_msg">
><br class="gmail_msg">
> As you can see I was testing the error and returning false, but that was crashing some buildbots with some extra API macro defined.<br class="gmail_msg">
><br class="gmail_msg">
> Got a link/quote of a buildbot failure - that sounds like a rather different problem from what this code would address, so I'm probably not picturing what sort of failure you're describing.<br class="gmail_msg">
<br class="gmail_msg">
without the extra API define, the initial code works fine. With the extra API define, we get an error stating no one checked the error.<br class="gmail_msg">
<br class="gmail_msg">
><br class="gmail_msg">
> I have been looking for Lang around here but he is on vacation. As soon as he gets back I will check with him and make this work, but for now I didn't want buildbots to be broken.<br class="gmail_msg">
><br class="gmail_msg">
> Greg<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div>