[lld] r224245 - Replace ReaderError with DynamicError.

Rui Ueyama ruiu at google.com
Mon Dec 15 04:20:13 PST 2014


Author: ruiu
Date: Mon Dec 15 06:20:13 2014
New Revision: 224245

URL: http://llvm.org/viewvc/llvm-project?rev=224245&view=rev
Log:
Replace ReaderError with DynamicError.

ReaderErrorCategory was used only at one place. We now have a
DynamicErrorCategory for this kind of one-time error, so use it.
The calling function doesn't really care the type of an error, so
ReaderErrorCategory was actually dead code.

Modified:
    lld/trunk/include/lld/Core/Error.h
    lld/trunk/lib/Core/Error.cpp
    lld/trunk/lib/Driver/GnuLdDriver.cpp

Modified: lld/trunk/include/lld/Core/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Error.h?rev=224245&r1=224244&r2=224245&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Error.h (original)
+++ lld/trunk/include/lld/Core/Error.h Mon Dec 15 06:20:13 2014
@@ -58,19 +58,6 @@ inline std::error_code make_error_code(L
   return std::error_code(static_cast<int>(e), LinkerScriptReaderCategory());
 }
 
-/// \brief Errors returned by Reader.
-const std::error_category &ReaderErrorCategory();
-
-enum class ReaderError {
-  success = 0,
-  unknown_file_format = 1
-};
-
-inline std::error_code make_error_code(ReaderError e) {
-  return std::error_code(static_cast<int>(e), ReaderErrorCategory());
-}
-
-
 /// Creates an error_code object that has associated with it an arbitrary
 /// error messsage.  The value() of the error_code will always be non-zero
 /// but its value is meaningless. The messsage() will be (a copy of) the 
@@ -88,7 +75,6 @@ struct is_error_code_enum<lld::NativeRea
 template <> struct is_error_code_enum<lld::YamlReaderError> : std::true_type {};
 template <>
 struct is_error_code_enum<lld::LinkerScriptReaderError> : std::true_type {};
-template <> struct is_error_code_enum<lld::ReaderError> : std::true_type {};
 }
 
 #endif

Modified: lld/trunk/lib/Core/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Error.cpp?rev=224245&r1=224244&r2=224245&view=diff
==============================================================================
--- lld/trunk/lib/Core/Error.cpp (original)
+++ lld/trunk/lib/Core/Error.cpp Mon Dec 15 06:20:13 2014
@@ -97,35 +97,9 @@ const std::error_category &lld::LinkerSc
   return o;
 }
 
-class _ReaderErrorCategory : public std::error_category {
-public:
-  const char *name() const LLVM_NOEXCEPT override {
-    return "lld.inputGraph.parse";
-  }
-
-  std::string message(int ev) const override {
-    switch (static_cast<ReaderError>(ev)) {
-    case ReaderError::success:
-      return "Success";
-    case ReaderError::unknown_file_format:
-      return "File format for the input file is not recognized by this flavor";
-    }
-    llvm_unreachable("An enumerator of ReaderError does not have a "
-                     "message defined.");
-  }
-};
-
-const std::error_category &lld::ReaderErrorCategory() {
-  static _ReaderErrorCategory i;
-  return i;
-}
-
-
-
 
 namespace lld {
 
-
 /// Temporary class to enable make_dynamic_error_code() until
 /// llvm::ErrorOr<> is updated to work with error encapsulations 
 /// other than error_code.

Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=224245&r1=224244&r2=224245&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Mon Dec 15 06:20:13 2014
@@ -123,9 +123,8 @@ getFileMagic(StringRef path, llvm::sys::
   case llvm::sys::fs::file_magic::unknown:
     return std::error_code();
   default:
-    break;
+    return make_dynamic_error_code(StringRef("unknown type of object file"));
   }
-  return make_error_code(ReaderError::unknown_file_format);
 }
 
 // Parses an argument of --defsym=<sym>=<number>





More information about the llvm-commits mailing list