Improve LinkModules warnings
authorJF Bastien <jfb@google.com>
Wed, 5 Mar 2014 21:26:42 +0000 (21:26 +0000)
committerJF Bastien <jfb@google.com>
Wed, 5 Mar 2014 21:26:42 +0000 (21:26 +0000)
Provide triple and data layout as well as module names (or empty string) when there's a mismatch.

Differential Revision: http://llvm-reviews.chandlerc.com/D2971

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203009 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp

index e8f2b3bb6f84918d92a1df323b878007a66d1735..a0ce497dd4732f109270ce2fa7fc66011f1a167a 100644 (file)
@@ -1210,16 +1210,20 @@ bool ModuleLinker::run() {
   if (SrcM->getDataLayout() && DstM->getDataLayout() &&
       *SrcM->getDataLayout() != *DstM->getDataLayout()) {
     if (!SuppressWarnings) {
-      errs() << "WARNING: Linking two modules of different data layouts!\n";
+      errs() << "WARNING: Linking two modules of different data layouts: '"
+             << SrcM->getModuleIdentifier() << "' is '"
+             << SrcM->getDataLayoutStr() << "' whereas '"
+             << DstM->getModuleIdentifier() << "' is '"
+             << DstM->getDataLayoutStr() << "'\n";
     }
   }
   if (!SrcM->getTargetTriple().empty() &&
       DstM->getTargetTriple() != SrcM->getTargetTriple()) {
     if (!SuppressWarnings) {
-      errs() << "WARNING: Linking two modules of different target triples: ";
-      if (!SrcM->getModuleIdentifier().empty())
-        errs() << SrcM->getModuleIdentifier() << ": ";
-      errs() << "'" << SrcM->getTargetTriple() << "' and '"
+      errs() << "WARNING: Linking two modules of different target triples: "
+             << SrcM->getModuleIdentifier() << "' is '"
+             << SrcM->getTargetTriple() << "' whereas '"
+             << DstM->getModuleIdentifier() << "' is '"
              << DstM->getTargetTriple() << "'\n";
     }
   }