[lld] r241379 - COFF: Don't print warning message for identical /export options.

David Blaikie dblaikie at gmail.com
Fri Jul 3 17:56:39 PDT 2015


On Jul 3, 2015 4:25 PM, "Rui Ueyama" <ruiu at google.com> wrote:
>
> Author: ruiu
> Date: Fri Jul  3 18:23:29 2015
> New Revision: 241379
>
> URL: http://llvm.org/viewvc/llvm-project?rev=241379&view=rev
> Log:
> COFF: Don't print warning message for identical /export options.
>
> Modified:
>     lld/trunk/COFF/Config.h
>     lld/trunk/COFF/DriverUtils.cpp
>     lld/trunk/test/COFF/export.test
>
> Modified: lld/trunk/COFF/Config.h
> URL:
http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=241379&r1=241378&r2=241379&view=diff
>
==============================================================================
> --- lld/trunk/COFF/Config.h (original)
> +++ lld/trunk/COFF/Config.h Fri Jul  3 18:23:29 2015
> @@ -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);

Drop the redundant parens around the expression?

> +  }
>  };
>
>  // Global configuration.
>
> Modified: lld/trunk/COFF/DriverUtils.cpp
> URL:
http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=241379&r1=241378&r2=241379&view=diff
>
==============================================================================
> --- lld/trunk/COFF/DriverUtils.cpp (original)
> +++ lld/trunk/COFF/DriverUtils.cpp Fri Jul  3 18:23:29 2015
> @@ -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));

Use insert (and check the result) to avoid two map lookups (of find+insert)?

> +      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);
>
>
> Modified: lld/trunk/test/COFF/export.test
> URL:
http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/export.test?rev=241379&r1=241378&r2=241379&view=diff
>
==============================================================================
> --- lld/trunk/test/COFF/export.test (original)
> +++ lld/trunk/test/COFF/export.test Fri Jul  3 18:23:29 2015
> @@ -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, at 5 >& %t.log
> +# RUN: FileCheck -check-prefix=CHECK6 %s < %t.log
> +
> +CHECK6:     duplicate /export option: exportfn2
> +CHECK6-NOT: duplicate /export option: exportfn1
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150703/a58285cc/attachment.html>


More information about the llvm-commits mailing list