[Lldb-commits] [PATCH] D157022: Fix the NSIndexSet formatter for macOS Sonoma

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 3 12:48:51 PDT 2023


jingham added inline comments.


================
Comment at: lldb/source/Plugins/Language/ObjC/Cocoa.cpp:278
+          && descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) {
+        count = __builtin_popcountll(payload);
+        break;
----------------
bulbazord wrote:
> 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`.
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.


================
Comment at: lldb/source/Plugins/Language/ObjC/Cocoa.cpp:294
+          // This is the bitfield case.  The bitfield is a uint64_t:
+          count = process_sp->ReadUnsignedIntegerFromMemory(
+              valobj_addr + 2 * ptr_size, 8, 0, error);
----------------
mib wrote:
> Do we want to overwrite the `count` read previously ?
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.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157022/new/

https://reviews.llvm.org/D157022



More information about the lldb-commits mailing list