[lld] r244216 - Move the error handling functions to Error.h. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 08:08:24 PDT 2015


Author: rafael
Date: Thu Aug  6 10:08:23 2015
New Revision: 244216

URL: http://llvm.org/viewvc/llvm-project?rev=244216&view=rev
Log:
Move the error handling functions to Error.h. NFC.

Added:
    lld/trunk/ELF/Error.cpp
    lld/trunk/ELF/Error.h
Modified:
    lld/trunk/ELF/CMakeLists.txt
    lld/trunk/ELF/Chunks.cpp
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Driver.h
    lld/trunk/ELF/DriverUtils.cpp
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/CMakeLists.txt?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/CMakeLists.txt (original)
+++ lld/trunk/ELF/CMakeLists.txt Thu Aug  6 10:08:23 2015
@@ -6,6 +6,7 @@ add_llvm_library(lldELF2
   Chunks.cpp
   Driver.cpp
   DriverUtils.cpp
+  Error.cpp
   InputFiles.cpp
   SymbolTable.cpp
   Symbols.cpp

Modified: lld/trunk/ELF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Chunks.cpp?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/Chunks.cpp (original)
+++ lld/trunk/ELF/Chunks.cpp Thu Aug  6 10:08:23 2015
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Chunks.h"
-#include "Driver.h"
+#include "Error.h"
 
 using namespace llvm;
 using namespace llvm::ELF;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Aug  6 10:08:23 2015
@@ -7,8 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Config.h"
 #include "Driver.h"
+#include "Config.h"
+#include "Error.h"
 #include "InputFiles.h"
 #include "SymbolTable.h"
 #include "Writer.h"
@@ -32,22 +33,6 @@ void link(ArrayRef<const char *> Args) {
   Driver->link(Args.slice(1));
 }
 
-void error(Twine Msg) {
-  errs() << Msg << "\n";
-  exit(1);
-}
-
-void error(std::error_code EC, Twine Prefix) {
-  if (!EC)
-    return;
-  error(Prefix + ": " + EC.message());
-}
-
-void error(std::error_code EC) {
-  if (!EC)
-    return;
-  error(EC.message());
-}
 }
 }
 

Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Thu Aug  6 10:08:23 2015
@@ -24,14 +24,6 @@ class InputFile;
 // Entry point of the ELF linker.
 void link(ArrayRef<const char *> Args);
 
-LLVM_ATTRIBUTE_NORETURN void error(Twine Msg);
-void error(std::error_code EC, Twine Prefix);
-void error(std::error_code EC);
-template <typename T> void error(const ErrorOr<T> &V, Twine Prefix) {
-  error(V.getError(), Prefix);
-}
-template <typename T> void error(const ErrorOr<T> &V) { error(V.getError()); }
-
 class ArgParser {
 public:
   // Parses command line options.

Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Thu Aug  6 10:08:23 2015
@@ -14,6 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Driver.h"
+#include "Error.h"
 #include "llvm/ADT/STLExtras.h"
 
 using namespace llvm;

Added: lld/trunk/ELF/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=244216&view=auto
==============================================================================
--- lld/trunk/ELF/Error.cpp (added)
+++ lld/trunk/ELF/Error.cpp Thu Aug  6 10:08:23 2015
@@ -0,0 +1,36 @@
+//===- Error.cpp ----------------------------------------------------------===//
+//
+//                             The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Error.h"
+
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace lld {
+namespace elf2 {
+
+void error(const Twine &Msg) {
+  llvm::errs() << Msg << "\n";
+  exit(1);
+}
+
+void error(std::error_code EC, const Twine &Prefix) {
+  if (!EC)
+    return;
+  error(Prefix + ": " + EC.message());
+}
+
+void error(std::error_code EC) {
+  if (!EC)
+    return;
+  error(EC.message());
+}
+
+} // namespace elf2
+} // namespace lld

Added: lld/trunk/ELF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=244216&view=auto
==============================================================================
--- lld/trunk/ELF/Error.h (added)
+++ lld/trunk/ELF/Error.h Thu Aug  6 10:08:23 2015
@@ -0,0 +1,30 @@
+//===- Error.h ------------------------------------------------------------===//
+//
+//                             The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLD_COFF_ERROR_H
+#define LLD_COFF_ERROR_H
+
+#include "lld/Core/LLVM.h"
+
+namespace lld {
+namespace elf2 {
+
+LLVM_ATTRIBUTE_NORETURN void error(const Twine &Msg);
+void error(std::error_code EC, const Twine &Prefix);
+void error(std::error_code EC);
+
+template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) {
+  error(V.getError(), Prefix);
+}
+template <typename T> void error(const ErrorOr<T> &V) { error(V.getError()); }
+
+} // namespace elf2
+} // namespace lld
+
+#endif

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Aug  6 10:08:23 2015
@@ -9,8 +9,8 @@
 
 #include "InputFiles.h"
 #include "Chunks.h"
+#include "Error.h"
 #include "Symbols.h"
-#include "Driver.h"
 #include "llvm/ADT/STLExtras.h"
 
 using namespace llvm::ELF;

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Thu Aug  6 10:08:23 2015
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "SymbolTable.h"
-#include "Driver.h"
+#include "Error.h"
 #include "Symbols.h"
 
 using namespace llvm;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=244216&r1=244215&r2=244216&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Aug  6 10:08:23 2015
@@ -9,7 +9,7 @@
 
 #include "Chunks.h"
 #include "Config.h"
-#include "Driver.h"
+#include "Error.h"
 #include "SymbolTable.h"
 #include "Writer.h"
 #include "llvm/ADT/DenseMap.h"




More information about the llvm-commits mailing list