diff options
author | Rui Ueyama <ruiu@google.com> | 2015-07-04 02:23:29 +0300 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2015-07-04 02:23:29 +0300 |
commit | 4b8cdd20fb4d1c30b52d22898e5728353c56ffc1 (patch) | |
tree | 5404be30548b9313b210322775363b6aff48880c /lld | |
parent | 1e7b08b68d3ca4616e62f742b660d9ffcdd3836c (diff) |
COFF: Don't print warning message for identical /export options.
llvm-svn: 241379
Diffstat (limited to 'lld')
-rw-r--r-- | lld/COFF/Config.h | 6 | ||||
-rw-r--r-- | lld/COFF/DriverUtils.cpp | 13 | ||||
-rw-r--r-- | lld/test/COFF/export.test | 7 |
3 files changed, 22 insertions, 4 deletions
diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h index e3e77ad3f3d5..578152ed8243 100644 --- a/lld/COFF/Config.h +++ b/lld/COFF/Config.h @@ -33,6 +33,12 @@ struct Export { bool Noname = false; bool Data = false; bool Private = false; + + bool operator==(const Export &E) { + return (Name == E.Name && ExtName == E.ExtName && + Ordinal == E.Ordinal && Noname == E.Noname && + Data == E.Data && Private == E.Private); + } }; // Global configuration. diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp index 598228550014..451dcd49cb77 100644 --- a/lld/COFF/DriverUtils.cpp +++ b/lld/COFF/DriverUtils.cpp @@ -396,14 +396,19 @@ std::error_code fixupExports() { } // Uniquefy by name. - std::set<StringRef> Names; + std::map<StringRef, Export *> Map; std::vector<Export> V; for (Export &E : Config->Exports) { - if (!Names.insert(E.Name).second) { - llvm::errs() << "warning: duplicate /export option: " << E.Name << "\n"; + auto It = Map.find(E.Name); + if (It == Map.end()) { + Map.insert(It, std::make_pair(E.Name, &E)); + V.push_back(E); continue; } - V.push_back(E); + if (E == *It->second) + continue; + llvm::errs() << "warning: duplicate /export option: " << E.Name << "\n"; + continue; } Config->Exports = std::move(V); diff --git a/lld/test/COFF/export.test b/lld/test/COFF/export.test index 8440cb7fb988..aa6343dab340 100644 --- a/lld/test/COFF/export.test +++ b/lld/test/COFF/export.test @@ -63,3 +63,10 @@ CHECK5-NEXT: 1 0 CHECK5-NEXT: 2 0x1010 fn2 CHECK5-NEXT: 3 0x1008 exportfn1 CHECK5-NEXT: 4 0x1010 exportfn3 + +# RUN: lld -flavor link2 /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 \ +# RUN: /export:exportfn1 /export:exportfn2,@5 >& %t.log +# RUN: FileCheck -check-prefix=CHECK6 %s < %t.log + +CHECK6: duplicate /export option: exportfn2 +CHECK6-NOT: duplicate /export option: exportfn1 |