<div dir="ltr">Please update the example in the ErrorOr class comment to reflect this new recommended usage pattern. Also, it seems like most real uses end up returning the error_code rather than calling a "handleError(error_code ec)" function so it might be good to change that in the example too.<div>
<br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 8, 2014 at 3:00 PM, Rafael Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Wed Jan  8 16:00:09 2014<br>
New Revision: 198797<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=198797&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=198797&view=rev</a><br>
Log:<br>
Use getError instead of the error_code operator.<br>
<br>
Modified:<br>
    lld/trunk/include/lld/Driver/CoreInputGraph.h<br>
    lld/trunk/include/lld/Driver/DarwinInputGraph.h<br>
    lld/trunk/lib/Core/InputGraph.cpp<br>
    lld/trunk/lib/Core/LinkingContext.cpp<br>
    lld/trunk/lib/Core/Resolver.cpp<br>
    lld/trunk/lib/Driver/GnuLdInputGraph.cpp<br>
    lld/trunk/lib/Driver/WinLinkInputGraph.cpp<br>
    lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h<br>
    lld/trunk/lib/ReaderWriter/ELF/File.h<br>
    lld/trunk/lib/ReaderWriter/ELF/Reader.cpp<br>
    lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp<br>
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp<br>
    lld/trunk/unittests/DriverTests/InputGraphTest.cpp<br>
<br>
Modified: lld/trunk/include/lld/Driver/CoreInputGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/CoreInputGraph.h?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/CoreInputGraph.h?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/include/lld/Driver/CoreInputGraph.h (original)<br>
+++ lld/trunk/include/lld/Driver/CoreInputGraph.h Wed Jan  8 16:00:09 2014<br>
@@ -40,8 +40,7 @@ public:<br>
   /// \brief Parse the input file to lld::File.<br>
   error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {<br>
     ErrorOr<StringRef> filePath = getPath(ctx);<br>
-    if (!filePath &&<br>
-        error_code(filePath) == llvm::errc::no_such_file_or_directory)<br>
+    if (filePath.getError() == llvm::errc::no_such_file_or_directory)<br>
       return make_error_code(llvm::errc::no_such_file_or_directory);<br>
<br>
     // Create a memory buffer<br>
<br>
Modified: lld/trunk/include/lld/Driver/DarwinInputGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/DarwinInputGraph.h?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/include/lld/Driver/DarwinInputGraph.h (original)<br>
+++ lld/trunk/include/lld/Driver/DarwinInputGraph.h Wed Jan  8 16:00:09 2014<br>
@@ -40,8 +40,8 @@ public:<br>
   /// \brief Parse the input file to lld::File.<br>
   error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {<br>
     ErrorOr<StringRef> filePath = getPath(ctx);<br>
-    if (!filePath)<br>
-      return error_code(filePath);<br>
+    if (error_code ec = filePath.getError())<br>
+      return ec;<br>
<br>
     if (error_code ec = getBuffer(*filePath))<br>
       return ec;<br>
<br>
Modified: lld/trunk/lib/Core/InputGraph.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/Core/InputGraph.cpp (original)<br>
+++ lld/trunk/lib/Core/InputGraph.cpp Wed Jan  8 16:00:09 2014<br>
@@ -202,7 +202,7 @@ ErrorOr<File &> Group::getNextFile() {<br>
     auto file = _elements[_nextElementIndex]->getNextFile();<br>
     // Move on to the next element if we have finished processing all<br>
     // the files in the input element<br>
-    if (error_code(file) == InputGraphError::no_more_files) {<br>
+    if (file.getError() == InputGraphError::no_more_files) {<br>
       _nextElementIndex++;<br>
       continue;<br>
     }<br>
<br>
Modified: lld/trunk/lib/Core/LinkingContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/LinkingContext.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/Core/LinkingContext.cpp (original)<br>
+++ lld/trunk/lib/Core/LinkingContext.cpp Wed Jan  8 16:00:09 2014<br>
@@ -91,7 +91,7 @@ ErrorOr<File &> LinkingContext::nextFile<br>
   // initialized. Initialize it with the first element of the input graph.<br>
   if (_currentInputElement == nullptr) {<br>
     ErrorOr<InputElement *> elem = inputGraph().getNextInputElement();<br>
-    if (error_code(elem) == InputGraphError::no_more_elements)<br>
+    if (elem.getError() == InputGraphError::no_more_elements)<br>
       return make_error_code(InputGraphError::no_more_files);<br>
     _currentInputElement = *elem;<br>
   }<br>
@@ -102,11 +102,11 @@ ErrorOr<File &> LinkingContext::nextFile<br>
   // graph.<br>
   for (;;) {<br>
     ErrorOr<File &> nextFile = _currentInputElement->getNextFile();<br>
-    if (error_code(nextFile) != InputGraphError::no_more_files)<br>
+    if (nextFile.getError() != InputGraphError::no_more_files)<br>
       return std::move(nextFile);<br>
<br>
     ErrorOr<InputElement *> elem = inputGraph().getNextInputElement();<br>
-    if (error_code(elem) == InputGraphError::no_more_elements ||<br>
+    if (elem.getError() == InputGraphError::no_more_elements ||<br>
         *elem == nullptr)<br>
       return make_error_code(InputGraphError::no_more_files);<br>
     _currentInputElement = *elem;<br>
<br>
Modified: lld/trunk/lib/Core/Resolver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/Core/Resolver.cpp (original)<br>
+++ lld/trunk/lib/Core/Resolver.cpp Wed Jan  8 16:00:09 2014<br>
@@ -266,11 +266,12 @@ bool Resolver::resolveUndefines() {<br>
   for (;;) {<br>
     ErrorOr<File &> file = _context.nextFile();<br>
     _context.setResolverState(Resolver::StateNoChange);<br>
-    if (error_code(file) == InputGraphError::no_more_files)<br>
+    error_code ec = file.getError();<br>
+    if (ec == InputGraphError::no_more_files)<br>
       return true;<br>
     if (!file) {<br>
       llvm::errs() << "Error occurred in nextFile: "<br>
-                   << error_code(file).message() << "\n";<br>
+                   << ec.message() << "\n";<br>
       return false;<br>
     }<br>
<br>
<br>
Modified: lld/trunk/lib/Driver/GnuLdInputGraph.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdInputGraph.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdInputGraph.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/Driver/GnuLdInputGraph.cpp (original)<br>
+++ lld/trunk/lib/Driver/GnuLdInputGraph.cpp Wed Jan  8 16:00:09 2014<br>
@@ -16,8 +16,8 @@ using namespace lld;<br>
 error_code ELFFileNode::parse(const LinkingContext &ctx,<br>
                               raw_ostream &diagnostics) {<br>
   ErrorOr<StringRef> filePath = getPath(ctx);<br>
-  if (!filePath)<br>
-    return error_code(filePath);<br>
+  if (error_code ec = filePath.getError())<br>
+    return ec;<br>
<br>
   if (error_code ec = getBuffer(*filePath))<br>
     return ec;<br>
@@ -51,8 +51,8 @@ error_code ELFFileNode::parse(const Link<br>
 error_code GNULdScript::parse(const LinkingContext &ctx,<br>
                               raw_ostream &diagnostics) {<br>
   ErrorOr<StringRef> filePath = getPath(ctx);<br>
-  if (!filePath)<br>
-    return error_code(filePath);<br>
+  if (error_code ec = filePath.getError())<br>
+    return ec;<br>
<br>
   if (error_code ec = getBuffer(*filePath))<br>
     return ec;<br>
<br>
Modified: lld/trunk/lib/Driver/WinLinkInputGraph.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkInputGraph.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkInputGraph.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/Driver/WinLinkInputGraph.cpp (original)<br>
+++ lld/trunk/lib/Driver/WinLinkInputGraph.cpp Wed Jan  8 16:00:09 2014<br>
@@ -15,9 +15,9 @@ namespace lld {<br>
 error_code PECOFFFileNode::parse(const LinkingContext &ctx,<br>
                                  raw_ostream &diagnostics) {<br>
   ErrorOr<StringRef> filePath = getPath(ctx);<br>
-  if (!filePath) {<br>
+  if (error_code ec = filePath.getError()) {<br>
     diagnostics << "File not found: " << _path << "\n";<br>
-    return error_code(filePath);<br>
+    return ec;<br>
   }<br>
<br>
   if (error_code ec = getBuffer(*filePath)) {<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h Wed Jan  8 16:00:09 2014<br>
@@ -48,8 +48,8 @@ public:<br>
               e = obj.end_dynamic_symbols();<br>
          i != e; ++i) {<br>
       auto name = obj.getSymbolName(i);<br>
-      if (!name)<br>
-        return error_code(name);<br>
+      if (error_code ec = name.getError())<br>
+        return ec;<br>
<br>
       // TODO: Add absolute symbols<br>
       if (i->st_shndx == llvm::ELF::SHN_ABS)<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/File.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Wed Jan  8 16:00:09 2014<br>
@@ -208,8 +208,8 @@ public:<br>
         auto sHdr = _objFile->getSection(section->sh_info);<br>
<br>
         auto sectionName = _objFile->getSectionName(sHdr);<br>
-        if (!sectionName)<br>
-          return error_code(sectionName);<br>
+        if (error_code ec = sectionName.getError())<br>
+          return ec;<br>
<br>
         auto rai(_objFile->begin_rela(section));<br>
         auto rae(_objFile->end_rela(section));<br>
@@ -222,8 +222,8 @@ public:<br>
         auto sHdr = _objFile->getSection(section->sh_info);<br>
<br>
         auto sectionName = _objFile->getSectionName(sHdr);<br>
-        if (!sectionName)<br>
-          return error_code(sectionName);<br>
+        if (error_code ec = sectionName.getError())<br>
+          return ec;<br>
<br>
         auto ri(_objFile->begin_rel(section));<br>
         auto re(_objFile->end_rel(section));<br>
@@ -246,12 +246,12 @@ public:<br>
     std::vector<MergeString *> tokens;<br>
     for (const Elf_Shdr *msi : _mergeStringSections) {<br>
       auto sectionName = _objFile->getSectionName(msi);<br>
-      if (!sectionName)<br>
-        return error_code(sectionName);<br>
+      if (error_code ec = sectionName.getError())<br>
+        return ec;<br>
<br>
       auto sectionContents = _objFile->getSectionContents(msi);<br>
-      if (!sectionContents)<br>
-        return error_code(sectionContents);<br>
+      if (error_code ec = sectionContents.getError())<br>
+        return ec;<br>
<br>
       StringRef secCont(<br>
           reinterpret_cast<const char *>(sectionContents->begin()),<br>
@@ -300,8 +300,8 @@ public:<br>
       const Elf_Shdr *section = _objFile->getSection(&*SymI);<br>
<br>
       auto symbolName = _objFile->getSymbolName(SymI);<br>
-      if (!symbolName)<br>
-        return error_code(symbolName);<br>
+      if (error_code ec = symbolName.getError())<br>
+        return ec;<br>
<br>
       if (SymI->st_shndx == llvm::ELF::SHN_ABS) {<br>
         // Create an absolute atom.<br>
@@ -358,16 +358,16 @@ public:<br>
<br>
       auto sectionName = section ? _objFile->getSectionName(section)<br>
                                  : StringRef();<br>
-      if (!sectionName)<br>
-        return error_code(sectionName);<br>
+      if (error_code ec = sectionName.getError())<br>
+        return ec;<br>
<br>
       auto sectionContents =<br>
           (section && section->sh_type != llvm::ELF::SHT_NOBITS)<br>
               ? _objFile->getSectionContents(section)<br>
               : ArrayRef<uint8_t>();<br>
<br>
-      if (!sectionContents)<br>
-        return error_code(sectionContents);<br>
+      if (error_code ec = sectionContents.getError())<br>
+        return ec;<br>
<br>
       StringRef secCont(<br>
           reinterpret_cast<const char *>(sectionContents->begin()),<br>
@@ -391,8 +391,8 @@ public:<br>
         StringRef symbolName = "";<br>
         if (symbol->getType() != llvm::ELF::STT_SECTION) {<br>
           auto symName = _objFile->getSymbolName(symbol);<br>
-          if (!symName)<br>
-            return error_code(symName);<br>
+          if (error_code ec = symName.getError())<br>
+            return ec;<br>
           symbolName = *symName;<br>
         }<br>
<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/Reader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Reader.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Reader.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/Reader.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/Reader.cpp Wed Jan  8 16:00:09 2014<br>
@@ -120,8 +120,8 @@ public:<br>
         1ULL << llvm::countTrailingZeros(uintptr_t(mb->getBufferStart()));<br>
     auto f = createELF<DynamicFileCreateELFTraits>(<br>
         getElfArchType(&*mb), maxAlignment, std::move(mb), _useUndefines);<br>
-    if (!f)<br>
-      return f;<br>
+    if (error_code ec = f.getError())<br>
+      return ec;<br>
     result.push_back(std::move(*f));<br>
     return error_code::success();<br>
   }<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp Wed Jan  8 16:00:09 2014<br>
@@ -36,8 +36,8 @@ public:<br>
     // Construct empty normalized file from atoms.<br>
     ErrorOr<std::unique_ptr<NormalizedFile>> nFile =<br>
                                 normalized::normalizedFromAtoms(file, _context);<br>
-    if (!nFile)<br>
-      return nFile;<br>
+    if (error_code ec = nFile.getError())<br>
+      return ec;<br>
<br>
     // For debugging, write out yaml form of normalized file.<br>
     //writeYaml(*nFile->get(), llvm::errs());<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Wed Jan  8 16:00:09 2014<br>
@@ -805,8 +805,8 @@ public:<br>
             std::vector<std::unique_ptr<File>> &result) const {<br>
     // Convert RC file to COFF<br>
     ErrorOr<std::string> coffPath = convertResourceFileToCOFF(std::move(mb));<br>
-    if (!coffPath)<br>
-      return error_code(coffPath);<br>
+    if (error_code ec = coffPath.getError())<br>
+      return ec;<br>
     llvm::FileRemover coffFileRemover(*coffPath);<br>
<br>
     // Read and parse the COFF<br>
@@ -852,8 +852,8 @@ private:<br>
   convertResourceFileToCOFF(std::unique_ptr<MemoryBuffer> mb) {<br>
     // Write the resource file to a temporary file.<br>
     ErrorOr<std::string> inFilePath = writeResToTemporaryFile(std::move(mb));<br>
-    if (!inFilePath)<br>
-      return error_code(inFilePath);<br>
+    if (error_code ec = inFilePath.getError())<br>
+      return ec;<br>
     llvm::FileRemover inFileRemover(*inFilePath);<br>
<br>
     // Create an output file path.<br>
<br>
Modified: lld/trunk/unittests/DriverTests/InputGraphTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/InputGraphTest.cpp?rev=198797&r1=198796&r2=198797&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/InputGraphTest.cpp?rev=198797&r1=198796&r2=198797&view=diff</a><br>

==============================================================================<br>
--- lld/trunk/unittests/DriverTests/InputGraphTest.cpp (original)<br>
+++ lld/trunk/unittests/DriverTests/InputGraphTest.cpp Wed Jan  8 16:00:09 2014<br>
@@ -144,7 +144,7 @@ protected:<br>
 TEST_F(InputGraphTest, Basic) {<br>
   EXPECT_EQ(0, inputFileCount());<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_EQ(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError());<br>
 }<br>
<br>
 TEST_F(InputGraphTest, AddAFile) {<br>
@@ -152,13 +152,13 @@ TEST_F(InputGraphTest, AddAFile) {<br>
   EXPECT_EQ(true, inputGraph().addInputElement(std::move(myfile)));<br>
   EXPECT_EQ(1, inputFileCount());<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   StringRef path = fileNode->getUserPath();<br>
   EXPECT_EQ(0, path.compare("file1"));<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_EQ(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError());<br>
 }<br>
<br>
 TEST_F(InputGraphTest, AddAFileWithLLDFiles) {<br>
@@ -172,7 +172,7 @@ TEST_F(InputGraphTest, AddAFileWithLLDFi<br>
   EXPECT_EQ(true, inputGraph().addInputElement(std::move(myfile)));<br>
   EXPECT_EQ(1, inputFileCount());<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
<br>
@@ -180,24 +180,24 @@ TEST_F(InputGraphTest, AddAFileWithLLDFi<br>
   EXPECT_EQ(0, path.compare("multi_files"));<br>
<br>
   ErrorOr<File &> objfile = fileNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile1", (*objfile).path());<br>
<br>
   objfile = fileNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile2", (*objfile).path());<br>
<br>
   objfile = fileNode->getNextFile();<br>
-  EXPECT_EQ(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_EQ(InputGraphError::no_more_files, objfile.getError());<br>
<br>
   fileNode->resetNextIndex();<br>
<br>
   objfile = fileNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile1", (*objfile).path());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_EQ(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError());<br>
 }<br>
<br>
 TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) {<br>
@@ -247,7 +247,7 @@ TEST_F(InputGraphTest, AddNodeWithFilesA<br>
   EXPECT_EQ(2, inputFileCount());<br>
<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
<br>
@@ -255,15 +255,15 @@ TEST_F(InputGraphTest, AddNodeWithFilesA<br>
   EXPECT_EQ(0, path.compare("multi_files1"));<br>
<br>
   ErrorOr<File &> objfile = fileNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile1", (*objfile).path());<br>
<br>
   objfile = fileNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile2", (*objfile).path());<br>
<br>
   objfile = fileNode->getNextFile();<br>
-  EXPECT_EQ(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_EQ(InputGraphError::no_more_files, objfile.getError());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
   EXPECT_EQ(InputElement::Kind::Control, (*nextElement)->kind());<br>
@@ -272,23 +272,23 @@ TEST_F(InputGraphTest, AddNodeWithFilesA<br>
   EXPECT_EQ(ControlNode::ControlKind::Group, controlNode->controlKind());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile_1", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile_2", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("group_objfile1", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("group_objfile2", (*objfile).path());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_EQ(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError());<br>
 }<br>
<br>
 // Iterate through the group<br>
@@ -339,7 +339,7 @@ TEST_F(InputGraphTest, AddNodeWithGroupI<br>
   EXPECT_EQ(2, inputFileCount());<br>
<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
<br>
@@ -347,15 +347,15 @@ TEST_F(InputGraphTest, AddNodeWithGroupI<br>
   EXPECT_EQ(0, path.compare("multi_files1"));<br>
<br>
   ErrorOr<File &> objfile = fileNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile1", (*objfile).path());<br>
<br>
   objfile = fileNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile2", (*objfile).path());<br>
<br>
   objfile = fileNode->getNextFile();<br>
-  EXPECT_EQ(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_EQ(InputGraphError::no_more_files, objfile.getError());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
   EXPECT_EQ(InputElement::Kind::Control, (*nextElement)->kind());<br>
@@ -364,37 +364,37 @@ TEST_F(InputGraphTest, AddNodeWithGroupI<br>
   EXPECT_EQ(ControlNode::ControlKind::Group, controlNode->controlKind());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile_1", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile_2", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("group_objfile1", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("group_objfile2", (*objfile).path());<br>
<br>
   controlNode->setResolveState(Resolver::StateNewDefinedAtoms);<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile_1", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("objfile_2", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("group_objfile1", (*objfile).path());<br>
<br>
   objfile = controlNode->getNextFile();<br>
-  EXPECT_NE(InputGraphError::no_more_files, error_code(objfile));<br>
+  EXPECT_NE(InputGraphError::no_more_files, objfile.getError());<br>
   EXPECT_EQ("group_objfile2", (*objfile).path());<br>
 }<br>
<br>
@@ -443,37 +443,37 @@ TEST_F(InputGraphTest, ExpandInputGraphN<br>
   inputGraph().normalize();<br>
<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("multi_files1", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("expand_file1", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("expand_file2", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("expand_node", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("obj_after_expand", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_EQ(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError());<br>
 }<br>
<br>
 // Node expansion tests.<br>
@@ -521,31 +521,31 @@ TEST_F(InputGraphTest, ExpandAndReplaceI<br>
   inputGraph().normalize();<br>
<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("multi_files1", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("expand_file1", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("expand_file2", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("obj_after_expand", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_EQ(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError());<br>
 }<br>
<br>
 // Hidden Node tests<br>
@@ -593,31 +593,31 @@ TEST_F(InputGraphTest, HiddenNodeTests)<br>
   inputGraph().normalize();<br>
<br>
   ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("multi_files1", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("expand_file1", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("expand_file2", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_NE(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());<br>
   EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind());<br>
   fileNode = llvm::dyn_cast<FileNode>(*nextElement);<br>
   EXPECT_EQ("obj_after_expand", (*fileNode).getUserPath());<br>
<br>
   nextElement = inputGraph().getNextInputElement();<br>
-  EXPECT_EQ(InputGraphError::no_more_elements, error_code(nextElement));<br>
+  EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError());<br>
 }<br>
<br>
 }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>