llvm.org GIT mirror llvm / e9db5e2
Introduce support to encode Objective-C property information in debugging information generated for an interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129624 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 9 years ago
7 changed file(s) with 133 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
550550 i64, ;; Size in bits
551551 i64, ;; Alignment in bits
552552 i64, ;; Offset in bits
553 metadata ;; Reference to type derived from
553 metadata, ;; Reference to type derived from
554 metadata, ;; (optional) Name of the Objective C property assoicated with
555 ;; Objective-C an ivar
556 metadata, ;; (optional) Name of the Objective C property getter selector.
557 metadata, ;; (optional) Name of the Objective C property setter selector.
558 i32 ;; (optional) Objective C property attributes.
554559 }
555560
556561
144144 unsigned LineNo, uint64_t SizeInBits,
145145 uint64_t AlignInBits, uint64_t OffsetInBits,
146146 unsigned Flags, DIType Ty);
147
148 /// createObjCIVar - Create debugging information entry for Objective-C
149 /// instance variable.
150 /// @param Name Member name.
151 /// @param File File where this member is defined.
152 /// @param LineNo Line number.
153 /// @param SizeInBits Member size.
154 /// @param AlignInBits Member alignment.
155 /// @param OffsetInBits Member offset.
156 /// @param Flags Flags to encode member attribute, e.g. private
157 /// @param Ty Parent type.
158 /// @param PropertyName Name of the Objective C property assoicated with
159 /// this ivar.
160 /// @param GetterName Name of the Objective C property getter selector.
161 /// @param SetterName Name of the Objective C property setter selector.
162 /// @param PropertyAttributes Objective C property attributes.
163 DIType createObjCIVar(StringRef Name, DIFile File,
164 unsigned LineNo, uint64_t SizeInBits,
165 uint64_t AlignInBits, uint64_t OffsetInBits,
166 unsigned Flags, DIType Ty,
167 StringRef PropertyName = StringRef(),
168 StringRef PropertyGetterName = StringRef(),
169 StringRef PropertySetterName = StringRef(),
170 unsigned PropertyAttributes = 0);
147171
148172 /// createClassType - Create debugging information entry for a class.
149173 /// @param Scope Scope in which this class is defined.
331331 /// return base type size.
332332 uint64_t getOriginalTypeSize() const;
333333
334 StringRef getObjCPropertyName() const { return getStringField(10); }
335 StringRef getObjCPropertyGetterName() const {
336 return getStringField(11);
337 }
338 StringRef getObjCPropertySetterName() const {
339 return getStringField(12);
340 }
341 bool isReadOnlyObjCProperty() {
342 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
343 }
344 bool isReadWriteObjCProperty() {
345 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
346 }
347 bool isAssignObjCProperty() {
348 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
349 }
350 bool isRetainObjCProperty() {
351 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
352 }
353 bool isCopyObjCProperty() {
354 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
355 }
356 bool isNonAtomicObjCProperty() {
357 return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
358 }
359
334360 /// Verify - Verify that a derived type descriptor is well formed.
335361 bool Verify() const;
336362
230230 DW_AT_APPLE_major_runtime_vers = 0x3fe5,
231231 DW_AT_APPLE_runtime_class = 0x3fe6,
232232 DW_AT_APPLE_omit_frame_ptr = 0x3fe7,
233 DW_AT_APPLE_property_name = 0x3fe8,
234 DW_AT_APPLE_property_getter = 0x3fe9,
235 DW_AT_APPLE_property_setter = 0x3fea,
236 DW_AT_APPLE_property_attribute = 0x3feb,
233237
234238 // Attribute form encodings
235239 DW_FORM_addr = 0x01,
583587 DW_EH_PE_datarel = 0x30,
584588 DW_EH_PE_funcrel = 0x40,
585589 DW_EH_PE_aligned = 0x50,
586 DW_EH_PE_indirect = 0x80
590 DW_EH_PE_indirect = 0x80,
591
592 // Apple Objective-C Property Attributes
593 DW_APPLE_PROPERTY_readonly = 0x01,
594 DW_APPLE_PROPERTY_readwrite = 0x02,
595 DW_APPLE_PROPERTY_assign = 0x04,
596 DW_APPLE_PROPERTY_retain = 0x08,
597 DW_APPLE_PROPERTY_copy = 0x10,
598 DW_APPLE_PROPERTY_nonatomic = 0x20
587599 };
588600
589601 /// TagString - Return the string for the specified tag.
231231 ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
232232 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
233233 Ty
234 };
235 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
236 }
237
238 /// createObjCIVar - Create debugging information entry for Objective-C
239 /// instance variable.
240 DIType DIBuilder::createObjCIVar(StringRef Name,
241 DIFile File, unsigned LineNumber,
242 uint64_t SizeInBits, uint64_t AlignInBits,
243 uint64_t OffsetInBits, unsigned Flags,
244 DIType Ty, StringRef PropertyName,
245 StringRef GetterName, StringRef SetterName,
246 unsigned PropertyAttributes) {
247 // TAG_member is encoded in DIDerivedType format.
248 Value *Elts[] = {
249 GetTagConstant(VMContext, dwarf::DW_TAG_member),
250 File, // Or TheCU ? Ty ?
251 MDString::get(VMContext, Name),
252 File,
253 ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
254 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
255 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
256 ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
257 ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
258 Ty,
259 MDString::get(VMContext, PropertyName),
260 MDString::get(VMContext, GetterName),
261 MDString::get(VMContext, SetterName),
262 ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes)
234263 };
235264 return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)));
236265 }
968968 if (DT.isVirtual())
969969 addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_flag,
970970 dwarf::DW_VIRTUALITY_virtual);
971
972 // Objective-C properties.
973 StringRef PropertyName = DT.getObjCPropertyName();
974 if (!PropertyName.empty()) {
975 addString(MemberDie, dwarf::DW_AT_APPLE_property_name, dwarf::DW_FORM_string,
976 PropertyName);
977 StringRef GetterName = DT.getObjCPropertyGetterName();
978 if (!GetterName.empty())
979 addString(MemberDie, dwarf::DW_AT_APPLE_property_getter,
980 dwarf::DW_FORM_string, GetterName);
981 StringRef SetterName = DT.getObjCPropertySetterName();
982 if (!SetterName.empty())
983 addString(MemberDie, dwarf::DW_AT_APPLE_property_setter,
984 dwarf::DW_FORM_string, SetterName);
985 unsigned PropertyAttributes = 0;
986 if (DT.isReadOnlyObjCProperty())
987 PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_readonly;
988 if (DT.isReadWriteObjCProperty())
989 PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_readwrite;
990 if (DT.isAssignObjCProperty())
991 PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_assign;
992 if (DT.isRetainObjCProperty())
993 PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_retain;
994 if (DT.isCopyObjCProperty())
995 PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_copy;
996 if (DT.isNonAtomicObjCProperty())
997 PropertyAttributes |= dwarf::DW_APPLE_PROPERTY_nonatomic;
998 if (PropertyAttributes)
999 addUInt(MemberDie, dwarf::DW_AT_APPLE_property_attribute, 0,
1000 PropertyAttributes);
1001 }
9711002 return MemberDie;
9721003 }
202202 case DW_AT_APPLE_major_runtime_vers: return "DW_AT_APPLE_major_runtime_vers";
203203 case DW_AT_APPLE_runtime_class: return "DW_AT_APPLE_runtime_class";
204204 case DW_AT_APPLE_omit_frame_ptr: return "DW_AT_APPLE_omit_frame_ptr";
205 case DW_AT_APPLE_property_name: return "DW_AT_APPLE_property_name";
206 case DW_AT_APPLE_property_getter: return "DW_AT_APPLE_property_getter";
207 case DW_AT_APPLE_property_setter: return "DW_AT_APPLE_property_setter";
208 case DW_AT_APPLE_property_attribute: return "DW_AT_APPLE_property_attribute";
205209 }
206210 return 0;
207211 }