[llvm-commits] LLD: patch Program Headers

Hemant Kulkarni khemant at codeaurora.org
Mon Nov 5 06:52:32 PST 2012


The call to equal_range is :
> +    sr = std::equal_range(sections.begin(), sections.end(),
> +                          i, ChunkComparator<target_endianness, 
> + is64Bits>());

Where "i"  is an unsigned short integer. If I do overload one more version of () operator in comparator struct, how is that MSVC supposed to pick this particular version unless I call it with the third parameter of equal_range with the integer? If if doe a #if defined ... #else... or just keep all versions of operator () I still need to have the correct parameters to call correct version. Isnt if def the way to do that ? If not suggest me a better way. 

--
Hemant Kulkarni
khemant at codeaurora.org
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation


-----Original Message-----
From: Michael Spencer [mailto:bigcheesegs at gmail.com] 
Sent: Friday, November 02, 2012 6:36 PM
To: Hemant Kulkarni
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] LLD: patch Program Headers

On Fri, Nov 2, 2012 at 3:28 PM, Hemant Kulkarni <khemant at codeaurora.org> wrote:
>
> MSVC doesn't like this in debug mode. The fix is to add:
>
> #if defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL == 2
>   bool operator()(Chunk<target_endianness, is64Bits> *A,
>                   Chunk<target_endianness, is64Bits> *B) {
>     return A->group() < B->group();
>   }
> #endif
>
> If I put a preprocessor to include a certain version of the overloaded operator, I will also need to add a preprocessor and make sure I pass in an object of that type in the equal_range function. Is adding such #ifdef a good idea?
> We could alternatively just keep the both operands chunks version so all compilers build it at all levels. What do you say?
>
> -Hemant
>
>
> --
> Hemant Kulkarni
> khemant at codeaurora.org
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
> hosted by the Linux Foundation

Why would you need to use the preprocessor in this case? equal_range with a value of type int will never require this overload. It's a bug in vc++ that ChunkComparator requires it.

- Michael Spencer





More information about the llvm-commits mailing list