[Lldb-commits] [PATCH] D83433: Fix how we handle bit-fields for Objective-C when creating an AST

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 9 14:38:39 PDT 2020


shafik added a comment.

@aprantl I think this Objective-C Runtime Programming Guide: Bye Encodings <https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html> entry and this sample program answer the rest of your questions:

  #include <Foundation/Foundation.h>
  #include <objc/runtime.h>
  @interface Bits: NSObject {
    int a: 1;
    int b: 2;
    int c: 3;
    double x;
    int f: 23;
    int e: 4;
  }
  @end
  @implementation Bits @end
  int main() {
    Ivar *ivars = class_copyIvarList([Bits class], NULL);
    for (Ivar *c = ivars; *c; c++) {
      printf("%s %s %ld\n", ivar_getName(*c), ivar_getTypeEncoding(*c), ivar_getOffset(*c));
    }
    free(ivars);
  }

with the following output:

  a b1 8
  b b2 8
  c b3 8
  x d 16
  f b23 24
  e b4 26

a b1 8

  a is a bit-field of size 1 with offset 8 


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

https://reviews.llvm.org/D83433





More information about the lldb-commits mailing list