This is an archive of the discontinued LLVM Phabricator instance.

Fix the NSIndexSet formatter for macOS Sonoma
AcceptedPublic

Authored by jingham on Aug 3 2023, 11:26 AM.

Details

Summary

Just mutatis mutandis for the Foundation changes. The current NSIndexSet test fails on Sonoma w/o this patch and exercise the different forms, so no new tests are required.

Diff Detail

Event Timeline

jingham created this revision.Aug 3 2023, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 11:26 AM
Herald added a subscriber: arphaman. · View Herald Transcript
jingham requested review of this revision.Aug 3 2023, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 11:26 AM
mib added inline comments.Aug 3 2023, 11:36 AM
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
294

Do we want to overwrite the count read previously ?

bulbazord added inline comments.Aug 3 2023, 12:16 PM
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
278

I'm pretty sure __builtin_popcount and friends are GNU extensions not supported by MSVC. You'll probably need to abstract this out with C preprocessor macro guards.

Alternatively, I think llvm has its own popcount implementation with llvm::popcount in include/llvm/ADT/bit.h.

jingham updated this revision to Diff 546976.Aug 3 2023, 12:47 PM
jingham marked an inline comment as done.

Use llvm::popcount instead of using the builtin directly.

jingham added inline comments.Aug 3 2023, 12:48 PM
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
278

Good catch. The llvm one is just a wrapper for the builtin when available and a by-hand version otherwise, so might as well use that one.

294

This code was originally written by Sean, who loved to write any code with complex logic in the form:

do {

/// Complex Logic here

} while (0);

so that he could exit the whole construct with a "break". After we get the bit mask value from the tagged pointer we break which sends us immediately to line 343. So that setting and this one are on non-intersecting code paths.

It would be nice if we could clean up what mode is. There's a lot of bit-wise operations and setting it to 1 and 2 and it's not clear what each one might mean in each case... Some kind of enum or semantic meaning for each number would be nice. Either way, I think I'm on board with the logic in general. Just one question though.

lldb/source/Plugins/Language/ObjC/Cocoa.cpp
303

This clobbers the previously set count on line 294. What of that count?

jingham updated this revision to Diff 547048.Aug 3 2023, 4:39 PM

Remove redundant code

jingham marked an inline comment as done.Aug 3 2023, 4:40 PM
jingham added inline comments.
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
303

Oh, that's me saying it was bad to use a variable called count when it should be bitfield, adding the new one and then forgetting to delete the count version.

bulbazord accepted this revision.Aug 3 2023, 4:40 PM
This revision is now accepted and ready to land.Aug 3 2023, 4:40 PM