[lld] r265297 - Try to fix the windows build.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 10:37:08 PDT 2016


What error did you get? I'm wondering why this works although StringRef
didn't work.

On Mon, Apr 4, 2016 at 7:31 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rafael
> Date: Mon Apr  4 09:31:20 2016
> New Revision: 265297
>
> URL: http://llvm.org/viewvc/llvm-project?rev=265297&view=rev
> Log:
> Try to fix the windows build.
>
> MSVC doesn't want StringRef in an union.
>
> Modified:
>     lld/trunk/ELF/Symbols.h
>
> Modified: lld/trunk/ELF/Symbols.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=265297&r1=265296&r2=265297&view=diff
>
> ==============================================================================
> --- lld/trunk/ELF/Symbols.h (original)
> +++ lld/trunk/ELF/Symbols.h Mon Apr  4 09:31:20 2016
> @@ -77,7 +77,7 @@ public:
>    // Returns the symbol name.
>    StringRef getName() const {
>      assert(!isLocal());
> -    return Name;
> +    return StringRef(Name.S, Name.Len);
>    }
>    uint32_t getNameOffset() const {
>      assert(isLocal());
> @@ -127,7 +127,8 @@ protected:
>    SymbolBody(Kind K, StringRef Name, uint8_t Binding, uint8_t Other,
>               uint8_t Type)
>        : SymbolKind(K), MustBeInDynSym(false), NeedsCopyOrPltAddr(false),
> -        Type(Type), Binding(Binding), Other(Other), Name(Name) {
> +        Type(Type), Binding(Binding), Other(Other),
> +        Name({Name.data(), Name.size()}) {
>      assert(!isLocal());
>      IsUsedInRegularObj =
>          K != SharedKind && K != LazyKind && K != DefinedBitcodeKind;
> @@ -163,8 +164,12 @@ public:
>    void setVisibility(uint8_t V) { Other = (Other & ~0x3) | V; }
>
>  protected:
> +  struct Str {
> +    const char *S;
> +    size_t Len;
> +  };
>    union {
> -    StringRef Name;
> +    Str Name;
>      uint32_t NameOffset;
>    };
>    Symbol *Backref = nullptr;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160404/7007bae0/attachment-0001.html>


More information about the llvm-commits mailing list