Synchronize LLVM and clang's ObjCDeclSpec::ObjCPropertyAttributeKind.
authorAdrian Prantl <aprantl@apple.com>
Thu, 14 Jul 2016 00:41:18 +0000 (00:41 +0000)
committerAdrian Prantl <aprantl@apple.com>
Thu, 14 Jul 2016 00:41:18 +0000 (00:41 +0000)
This adds Clang-specific DWARF constants for nullability and ObjC
class properties that are already generated by clang. This patch adds
dwarfdump support and a more comprehensive testcase.

<rdar://problem/27335745>

llvm-svn: 275354

llvm/docs/SourceLevelDebugging.rst
llvm/include/llvm/Support/Dwarf.h
llvm/lib/Support/Dwarf.cpp
llvm/test/DebugInfo/Inputs/dwarfdump-objc.m
llvm/test/DebugInfo/Inputs/dwarfdump-objc.x86_64.o
llvm/test/DebugInfo/dwarfdump-accel.test
llvm/test/DebugInfo/dwarfdump-objc.test

index fb70745..1815ee3 100644 (file)
@@ -681,7 +681,13 @@ New DWARF Constants
 | DW_APPLE_PROPERTY_strong             | 0x400 |
 +--------------------------------------+-------+
 | DW_APPLE_PROPERTY_unsafe_unretained  | 0x800 |
-+--------------------------------+-----+-------+
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_nullability        | 0x1000|
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_null_resettable    | 0x2000|
++--------------------------------------+-------+
+| DW_APPLE_PROPERTY_class              | 0x4000|
++--------------------------------------+-------+
 
 Name Accelerator Tables
 -----------------------
index 79731ae..86b1967 100644 (file)
@@ -538,7 +538,7 @@ enum LocationListEntry : unsigned char {
   DW_LLE_offset_pair_entry
 };
 
-/// Contstants for the DW_APPLE_PROPERTY_attributes attribute.
+/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
 /// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind.
 enum ApplePropertyAttributes {
   // Apple Objective-C Property Attributes
@@ -553,7 +553,10 @@ enum ApplePropertyAttributes {
   DW_APPLE_PROPERTY_atomic = 0x100,
   DW_APPLE_PROPERTY_weak =   0x200,
   DW_APPLE_PROPERTY_strong = 0x400,
-  DW_APPLE_PROPERTY_unsafe_unretained = 0x800
+  DW_APPLE_PROPERTY_unsafe_unretained = 0x800,
+  DW_APPLE_PROPERTY_nullability = 0x1000,
+  DW_APPLE_PROPERTY_null_resettable = 0x2000,
+  DW_APPLE_PROPERTY_class = 0x4000
 };
 
 // Constants for the DWARF5 Accelerator Table Proposal
index 230a3da..7aea05d 100644 (file)
@@ -545,6 +545,12 @@ const char *llvm::dwarf::ApplePropertyString(unsigned Prop) {
     return "DW_APPLE_PROPERTY_strong";
   case DW_APPLE_PROPERTY_unsafe_unretained:
     return "DW_APPLE_PROPERTY_unsafe_unretained";
+  case DW_APPLE_PROPERTY_nullability:
+    return "DW_APPLE_PROPERTY_nullability";
+  case DW_APPLE_PROPERTY_null_resettable:
+    return "DW_APPLE_PROPERTY_null_resettable";
+  case DW_APPLE_PROPERTY_class:
+    return "DW_APPLE_PROPERTY_class";
   }
   return nullptr;
 }
index 54fbee2..805384c 100644 (file)
 @property (retain) NSObject *Retain;
 @property (copy) NSObject *Copy;
 @property (nonatomic) int NonAtomic;
+@property (atomic) int Atomic;
+@property (strong) NSObject *Strong;
+@property (unsafe_unretained) id UnsafeUnretained;
+@property (nullable) NSObject *Nullability;
+@property (null_resettable) NSObject *NullResettable;
+@property (class) int ClassProperty;
 @end
 
 @implementation TestInterface
index 6b55d38..8c0dcd5 100644 (file)
Binary files a/llvm/test/DebugInfo/Inputs/dwarfdump-objc.x86_64.o and b/llvm/test/DebugInfo/Inputs/dwarfdump-objc.x86_64.o differ
index 7c18388..c6a971a 100644 (file)
@@ -21,28 +21,30 @@ CHECK: .apple_names contents:
 CHECK: Magic = 0x48415348
 CHECK: Version = 0x0001
 CHECK: Hash function = 0x00000000
-CHECK: Bucket count = 11
-CHECK: Hashes count = 22
+CHECK: Bucket count = 21
+CHECK: Hashes count = 42
 CHECK: HeaderData length = 12
 CHECK: DIE offset base = 0
 CHECK: Number of atoms = 1
 CHECK: Atom[0]  Type: DW_ATOM_die_offset Form: DW_FORM_data4
 
+Check that the accelerators point to the right DIEs.
+CHECK:     Name:{{.*}}"-[TestInterface ReadOnly]"
+CHECK-NOT: Name
+CHECK:     {Atom[0]: [[READONLY]]}
+
 Check that empty buckets are handled correctly.
-CHECK: Bucket[2]
-CHECK:   EMPTY
 CHECK: Bucket[3]
+CHECK:   EMPTY
+CHECK: Bucket[4]
 
 Check that the accelerators point to the right DIEs.
-CHECK:     Name:{{.*}}"-[TestInterface ReadOnly]"
+CHECK:     Name:{{.*}}"-[TestInterface Assign]"
 CHECK-NOT: Name
-CHECK:     {Atom[0]: [[READONLY]]}
+CHECK:     {Atom[0]: [[ASSIGN]]}
 CHECK:     Name:{{.*}}"-[TestInterface setAssign:]"
 CHECK-NOT: Name
 CHECK:     {Atom[0]: [[SETASSIGN]]}
-CHECK:     Name:{{.*}}"-[TestInterface Assign]"
-CHECK-NOT: Name
-CHECK:     {Atom[0]: [[ASSIGN]]}
 
 Check that types are referenced correctly.
 CHECK: .apple_types contents:
@@ -50,7 +52,7 @@ CHECK:     Name{{.*}}"TestInterface"
 CHECK-NOT: Name
 CHECK:     {Atom[0]: [[TESTINTERFACE]]}
 
-Check that an empty ecceleratorsection is handled correctly.
+Check that an empty accelerator section is handled correctly.
 CHECK: .apple_namespaces contents:
 CHECK-NOT: Magic
 
index 6890c3a..60d0d2f 100644 (file)
@@ -6,35 +6,70 @@ CHECK: DW_TAG_APPLE_property
 CHECK-NOT: TAG
 CHECK:    DW_AT_APPLE_property_name {{.*}} "ReadOnly"
 CHECK-NOT: TAG
-CHECK:    DW_AT_APPLE_property_attribute {{.*}} (0x01 (DW_APPLE_PROPERTY_readonly))
+CHECK:    DW_AT_APPLE_property_attribute {{.*}} (0x0101 (DW_APPLE_PROPERTY_readonly, DW_APPLE_PROPERTY_atomic))
 
 CHECK: DW_TAG_APPLE_property
 CHECK-NOT: TAG
 CHECK:   DW_AT_APPLE_property_name {{.*}} "Assign"
 CHECK-NOT: TAG
-CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x0c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite))
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x090c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained))
 
 CHECK: DW_TAG_APPLE_property
 CHECK-NOT: TAG
 CHECK:   DW_AT_APPLE_property_name {{.*}} "ReadWrite"
 CHECK-NOT: TAG
-CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x0c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite))
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x090c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained))
 
 CHECK: DW_TAG_APPLE_property
 CHECK-NOT: TAG
 CHECK:   DW_AT_APPLE_property_name {{.*}} "Retain"
 CHECK-NOT: TAG
-CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x18 (DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_retain))
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x0118 (DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_retain, DW_APPLE_PROPERTY_atomic))
 
 CHECK: DW_TAG_APPLE_property
 CHECK-NOT: TAG
 CHECK:   DW_AT_APPLE_property_name {{.*}} "Copy"
 CHECK-NOT: TAG
-CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x28 (DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_copy))
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x0128 (DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_copy, DW_APPLE_PROPERTY_atomic))
 
 CHECK: DW_TAG_APPLE_property
 CHECK-NOT: TAG
 CHECK:   DW_AT_APPLE_property_name {{.*}} "NonAtomic"
 CHECK-NOT: TAG
-CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x4c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_nonatomic))
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x084c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_nonatomic, DW_APPLE_PROPERTY_unsafe_unretained))
 
+CHECK: DW_TAG_APPLE_property
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_name {{.*}} "Atomic"
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x090c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained))
+
+CHECK: DW_TAG_APPLE_property
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_name {{.*}} "Strong"
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x0508 (DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_strong))
+
+CHECK: DW_TAG_APPLE_property
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_name {{.*}} "UnsafeUnretained"
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x090c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained))
+
+CHECK: DW_TAG_APPLE_property
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_name {{.*}} "Nullability"
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x190c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained, DW_APPLE_PROPERTY_nullability))
+
+CHECK: DW_TAG_APPLE_property
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_name {{.*}} "NullResettable"
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x390c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained, DW_APPLE_PROPERTY_nullability, DW_APPLE_PROPERTY_null_resettable))
+
+CHECK: DW_TAG_APPLE_property
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_name {{.*}} "ClassProperty"
+CHECK-NOT: TAG
+CHECK:   DW_AT_APPLE_property_attribute {{.*}} (0x490c (DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained, DW_APPLE_PROPERTY_class))