[Lldb-commits] [lldb] r346783 - [Cocoa] Implement formatter for the new NSDate representation.
Davide Italiano via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 16 11:56:08 PST 2018
I saw you partially fixed this.
I addressed the remaining problem in:
Davides-Mac-Pro:lldb davide$ git llvm push
Pushing 1 commit:
b6fd30d9119 [Cocoa] Prefer llvm::SignExtend64. Pointed out by zturner.
Sending lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
Transmitting file data .done
Committing transaction...
Committed revision 347087.
Committed b6fd30d9119 to svn.
--
Davide
On Fri, Nov 16, 2018 at 10:09 AM Davide Italiano <davide at freebsd.org> wrote:
>
> Sorry Zach, I was sick for the past few days. I'll look into this one now.
>
> --
> Davide
> On Wed, Nov 14, 2018 at 9:16 AM Zachary Turner <zturner at google.com> wrote:
> >
> >
> >
> > On Tue, Nov 13, 2018 at 11:46 AM Davide Italiano via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> >>
> >> Author: davide
> >> Date: Tue Nov 13 11:43:43 2018
> >> New Revision: 346783
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=346783&view=rev
> >> Log:
> >> [Cocoa] Implement formatter for the new NSDate representation.
> >>
> >> <rdar://problem/46002786>
> >>
> >> Modified:
> >> lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
> >>
> >> Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp?rev=346783&r1=346782&r2=346783&view=diff
> >> ==============================================================================
> >> --- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
> >> +++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Tue Nov 13 11:43:43 2018
> >> @@ -742,6 +742,60 @@ bool lldb_private::formatters::NSURLSumm
> >> return false;
> >> }
> >>
> >> +/// Bias value for tagged pointer exponents.
> >> +/// Recommended values:
> >> +/// 0x3e3: encodes all dates between distantPast and distantFuture
> >> +/// except for the range within about 1e-28 second of the reference date.
> >> +/// 0x3ef: encodes all dates for a few million years beyond distantPast and
> >> +/// distantFuture, except within about 1e-25 second of the reference date.
> >> +const int TAGGED_DATE_EXPONENT_BIAS = 0x3ef;
> >> +
> >> +typedef union {
> >> + struct {
> >> + uint64_t fraction:52; // unsigned
> >> + uint64_t exponent:11; // signed
> >> + uint64_t sign:1;
> >> + };
> >> + uint64_t i;
> >> + double d;
> >> +} DoubleBits;
> >> +typedef union {
> >> + struct {
> >> + uint64_t fraction:52; // unsigned
> >> + uint64_t exponent:7; // signed
> >> + uint64_t sign:1;
> >> + uint64_t unused:4; // placeholder for pointer tag bits
> >> + };
> >
> > MSVC gives:
> >
> > warning C4201: nonstandard extension used: nameless struct/union
> >
> >>
> >> + uint64_t i;
> >> +} TaggedDoubleBits;
> >> +
> >> +static uint64_t decodeExponent(uint64_t exp) {
> >> + int64_t exp7 = exp;
> >> + // Tagged exponent field is 7-bit signed. Sign-extend the value to 64 bits
> >> + // before performing arithmetic.
> >> + int64_t exp11 = ((exp7 << 57) >> 57) + TAGGED_DATE_EXPONENT_BIAS;
> >> + return exp11;
> >> +}
> >
> > this should probably be:
> >
> > return llvm::SignExtend64<7>(exp) + TAGGED_DATE_EXPONENT_BIAS;
> >
> >>
> >> +
> >> +static uint64_t decodeTaggedTimeInterval(uint64_t encodedTimeInterval) {
> >> + if (encodedTimeInterval == 0)
> >> + return 0.0;
> >> + if (encodedTimeInterval == std::numeric_limits<uint64_t>::max())
> >> + return -0.0;
> >> +
> >> + TaggedDoubleBits encodedBits = { .i = encodedTimeInterval };
> >
> > Designated initializers are C++20 which are not allowed in LLVM.
>
>
>
> --
> Davide
>
> "There are no solved problems; there are only problems that are more
> or less solved" -- Henri Poincare
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the lldb-commits
mailing list