llvm.org GIT mirror llvm / 22942f7
[llvm-link] Use WithColor for printing errors Use convenience helpers in WithColor to print errors and warnings. Differential revision: https://reviews.llvm.org/D45667 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330261 91177308-0d34-0410-b5e6-96231b3b80d8 Jonas Devlieghere 2 years ago
6 changed file(s) with 29 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
1010 ; warnings are issued when the Triples differ only in version numbers.
1111
1212 ; CHECK1: target triple = "x86_64-apple-macosx10.10.0"
13 ; WARN1-NOT: WARNING
13 ; WARN1-NOT: warning
1414 ; CHECK2: target triple = "x86_64-apple-macosx10.9.0"
15 ; WARN2-NOT: WARNING
15 ; WARN2-NOT: warning
1616
1717 ; i386 and x86_64 map to different ArchType enums.
18 ; WARN3: WARNING: Linking two modules of different target triples
18 ; WARN3: warning: Linking two modules of different target triples
1919
2020 ; x86_64h and x86_64 map to the same ArchType enum.
21 ; WARN4-NOT: WARNING
21 ; WARN4-NOT: warning
2222
2323 target triple = "x86_64-apple-macosx10.9.0"
77 target datalayout = "e"
88
99
10 ; WARN-A-NOT: WARNING
10 ; WARN-A-NOT: warning
1111
12 ; WARN-B: WARNING: Linking two modules of different data layouts:
12 ; WARN-B: warning: Linking two modules of different data layouts:
22 ;; drop-debug.bc was created from "void f(void) {}" with clang 3.5 and
33 ; -gline-tables-only, so it contains old debug info.
44
5 ; CHECK: WARNING: ignoring debug info with an invalid version (1) in {{.*}}/Inputs/drop-debug.bc
5 ; CHECK: warning: ignoring debug info with an invalid version (1) in {{.*}}/Inputs/drop-debug.bc
11 ; in different modules.
22 ; RUN: not llvm-link %s %s -o %t.bc 2>&1 | FileCheck %s
33 ; RUN: not llvm-link %s %S/Inputs/redefinition.ll -o %t.bc 2>&1 | FileCheck %s
4 ; CHECK: ERROR: Linking globals named 'foo': symbol multiply defined!
4 ; CHECK: error: Linking globals named 'foo': symbol multiply defined!
55 define void @foo() { ret void }
1212
1313 ; CHECK: target triple = "x86_64-unknown-linux-gnu"
1414
15 ; WARN-A-NOT: WARNING
15 ; WARN-A-NOT: warning
1616
1717 ; i386 and x86_64 map to different ArchType enums.
18 ; WARN-B: WARNING: Linking two modules of different target triples:
18 ; WARN-B: warning: Linking two modules of different target triples:
1919
2020 ; x86_64h and x86_64 map to the same ArchType enum.
21 ; WARN-C-NOT: WARNING
21 ; WARN-C-NOT: warning
3030 #include "llvm/Support/SourceMgr.h"
3131 #include "llvm/Support/SystemUtils.h"
3232 #include "llvm/Support/ToolOutputFile.h"
33 #include "llvm/Support/WithColor.h"
3334 #include "llvm/Transforms/IPO/FunctionImport.h"
3435 #include "llvm/Transforms/IPO/Internalize.h"
3536 #include "llvm/Transforms/Utils/FunctionImportUtils.h"
117118 LLVMContext &Context,
118119 bool MaterializeMetadata = true) {
119120 SMDiagnostic Err;
120 if (Verbose) errs() << "Loading '" << FN << "'\n";
121 if (Verbose)
122 errs() << "Loading '" << FN << "'\n";
121123 std::unique_ptr Result;
122124 if (DisableLazyLoad)
123125 Result = parseIRFile(FN, Err, Context);
185187 unsigned Severity = DI.getSeverity();
186188 switch (Severity) {
187189 case DS_Error:
188 errs() << "ERROR: ";
190 WithColor::error();
189191 break;
190192 case DS_Warning:
191193 if (SuppressWarnings)
192194 return true;
193 errs() << "WARNING: ";
195 WithColor::warning();
194196 break;
195197 case DS_Remark:
196198 case DS_Note:
235237 auto &SrcModule = ModuleLoaderCache(argv0, FileName);
236238
237239 if (verifyModule(SrcModule, &errs())) {
238 errs() << argv0 << ": " << FileName
239 << ": error: input module is broken!\n";
240 errs() << argv0 << ": " << FileName;
241 WithColor::error() << "input module is broken!\n";
240242 return false;
241243 }
242244
280282 for (const auto &File : Files) {
281283 std::unique_ptr M = loadFile(argv0, File, Context);
282284 if (!M.get()) {
283 errs() << argv0 << ": error loading file '" << File << "'\n";
285 errs() << argv0 << ": ";
286 WithColor::error() << " loading file '" << File << "'\n";
284287 return false;
285288 }
286289
288291 // doing that debug metadata in the src module might already be pointing to
289292 // the destination.
290293 if (DisableDITypeMap && verifyModule(*M, &errs())) {
291 errs() << argv0 << ": " << File << ": error: input module is broken!\n";
294 errs() << argv0 << ": " << File << ": ";
295 WithColor::error() << "input module is broken!\n";
292296 return false;
293297 }
294298
373377 if (!importFunctions(argv[0], *Composite))
374378 return 1;
375379
376 if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite;
380 if (DumpAsm)
381 errs() << "Here's the assembly:\n" << *Composite;
377382
378383 std::error_code EC;
379384 ToolOutputFile Out(OutputFilename, EC, sys::fs::F_None);
380385 if (EC) {
381 errs() << EC.message() << '\n';
386 WithColor::error() << EC.message() << '\n';
382387 return 1;
383388 }
384389
385390 if (verifyModule(*Composite, &errs())) {
386 errs() << argv[0] << ": error: linked module is broken!\n";
391 errs() << argv[0] << ": ";
392 WithColor::error() << "linked module is broken!\n";
387393 return 1;
388394 }
389395
390 if (Verbose) errs() << "Writing bitcode...\n";
396 if (Verbose)
397 errs() << "Writing bitcode...\n";
391398 if (OutputAssembly) {
392399 Composite->print(Out.os(), nullptr, PreserveAssemblyUseListOrder);
393400 } else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true))