[PATCH] D34744: [DWARF] - Simplify HandleExpectedError implementation in DWARFDebugInfoTest

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 28 02:23:16 PDT 2017


grimar created this revision.
Herald added subscribers: kristof.beyls, aemerson.

Current implementation looks confusing. It looks like it should
report/print something on error, but it does not do that.

HandleExpectedError used to check targets created from triple.
I am not sure what was intended behavior,
current one - it does not print anything if target was not created and assumes
that test pass.

That behavior looks correct for me though, but then implementation can be simplified,
like this patch do. I think current behavior is correct because of next:
I tried to configure LLVM with -DLLVM_TARGETS_TO_BUILD=ARM and debugged the testcase under
windows. Triple I had was "i386-pc-windows-msvc". Testcase uses getHostTripleForAddrSize() to get
target triple. As expected for my configuration no tests were executed. For me it is looks fine in that case.


https://reviews.llvm.org/D34744

Files:
  unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp


Index: unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
===================================================================
--- unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -67,15 +67,10 @@
 /// \returns true if there were errors, false otherwise.
 template <typename T>
 static bool HandleExpectedError(T &Expected) {
-  std::string ErrorMsg;
-  handleAllErrors(Expected.takeError(), [&](const ErrorInfoBase &EI) {
-    ErrorMsg = EI.message();
-  });
-  if (!ErrorMsg.empty()) {
-    ::testing::AssertionFailure() << "error: " << ErrorMsg;
-    return true;
-  }
-  return false;
+  if (Expected)
+    return false;
+  llvm::consumeError(Expected.takeError());
+  return true;
 }
 
 template <uint16_t Version, class AddrType, class RefAddrType>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34744.104361.patch
Type: text/x-patch
Size: 808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170628/6ab61801/attachment.bin>


More information about the llvm-commits mailing list