[lld] r287901 - Use toString() to report incompatible files.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 24 12:59:44 PST 2016


Author: ruiu
Date: Thu Nov 24 14:59:44 2016
New Revision: 287901

URL: http://llvm.org/viewvc/llvm-project?rev=287901&view=rev
Log:
Use toString() to report incompatible files.

Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/test/ELF/incompatible-ar-first.s
    lld/trunk/test/ELF/incompatible.s

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=287901&r1=287900&r2=287901&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Thu Nov 24 14:59:44 2016
@@ -35,17 +35,18 @@ using namespace lld::elf;
 template <class ELFT> static bool isCompatible(InputFile *F) {
   if (!isa<ELFFileBase<ELFT>>(F) && !isa<BitcodeFile>(F))
     return true;
+
   if (F->EKind == Config->EKind && F->EMachine == Config->EMachine) {
     if (Config->EMachine != EM_MIPS)
       return true;
     if (isMipsN32Abi(F) == Config->MipsN32Abi)
       return true;
   }
-  StringRef A = F->getName();
-  StringRef B = Config->Emulation;
-  if (B.empty())
-    B = Config->FirstElf->getName();
-  error(A + " is incompatible with " + B);
+
+  if (!Config->Emulation.empty())
+    error(toString(F) + " is incompatible with " + Config->Emulation);
+  else
+    error(toString(F) + " is incompatible with " + toString(Config->FirstElf));
   return false;
 }
 

Modified: lld/trunk/test/ELF/incompatible-ar-first.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/incompatible-ar-first.s?rev=287901&r1=287900&r2=287901&view=diff
==============================================================================
--- lld/trunk/test/ELF/incompatible-ar-first.s (original)
+++ lld/trunk/test/ELF/incompatible-ar-first.s Thu Nov 24 14:59:44 2016
@@ -6,6 +6,6 @@
 // We used to crash when
 // * The first object seen by the symbol table is from an archive.
 // * -m was not used.
-// CHECK: a.o is incompatible with {{.*}}b.o
+// CHECK: .a({{.*}}a.o) is incompatible with {{.*}}b.o
 
 // REQUIRES: x86

Modified: lld/trunk/test/ELF/incompatible.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/incompatible.s?rev=287901&r1=287900&r2=287901&view=diff
==============================================================================
--- lld/trunk/test/ELF/incompatible.s (original)
+++ lld/trunk/test/ELF/incompatible.s Thu Nov 24 14:59:44 2016
@@ -50,7 +50,7 @@
 // RUN: llvm-ar rc %t.a %ta.o
 // RUN: llvm-mc -filetype=obj -triple=i686-linux %s -o %tb.o
 // RUN: not ld.lld %t.a %tb.o 2>&1 | FileCheck --check-prefix=ARCHIVE %s
-// ARCHIVE: a.o is incompatible with {{.*}}b.o
+// ARCHIVE: .a({{.*}}a.o) is incompatible with {{.*}}b.o
 .global _start
 _start:
 .data




More information about the llvm-commits mailing list