Support: Add dwarf::getOperationEncoding()
[oota-llvm.git] / lib / Support / Dwarf.cpp
1 //===-- llvm/Support/Dwarf.cpp - Dwarf Framework ----------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains support for generic dwarf information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Support/Dwarf.h"
15 #include "llvm/ADT/StringSwitch.h"
16 #include "llvm/Support/ErrorHandling.h"
17
18 using namespace llvm;
19 using namespace dwarf;
20
21 const char *llvm::dwarf::TagString(unsigned Tag) {
22   switch (Tag) {
23   default: return nullptr;
24 #define HANDLE_DW_TAG(ID, NAME)                                                \
25   case DW_TAG_##NAME:                                                          \
26     return "DW_TAG_" #NAME;
27 #include "llvm/Support/Dwarf.def"
28   }
29 }
30
31 unsigned llvm::dwarf::getTag(StringRef TagString) {
32   return StringSwitch<unsigned>(TagString)
33 #define HANDLE_DW_TAG(ID, NAME) .Case("DW_TAG_" #NAME, DW_TAG_##NAME)
34 #include "llvm/Support/Dwarf.def"
35       .Default(DW_TAG_invalid);
36 }
37
38 const char *llvm::dwarf::ChildrenString(unsigned Children) {
39   switch (Children) {
40   case DW_CHILDREN_no:                   return "DW_CHILDREN_no";
41   case DW_CHILDREN_yes:                  return "DW_CHILDREN_yes";
42   }
43   return nullptr;
44 }
45
46 const char *llvm::dwarf::AttributeString(unsigned Attribute) {
47   switch (Attribute) {
48   case DW_AT_sibling:                    return "DW_AT_sibling";
49   case DW_AT_location:                   return "DW_AT_location";
50   case DW_AT_name:                       return "DW_AT_name";
51   case DW_AT_ordering:                   return "DW_AT_ordering";
52   case DW_AT_byte_size:                  return "DW_AT_byte_size";
53   case DW_AT_bit_offset:                 return "DW_AT_bit_offset";
54   case DW_AT_bit_size:                   return "DW_AT_bit_size";
55   case DW_AT_stmt_list:                  return "DW_AT_stmt_list";
56   case DW_AT_low_pc:                     return "DW_AT_low_pc";
57   case DW_AT_high_pc:                    return "DW_AT_high_pc";
58   case DW_AT_language:                   return "DW_AT_language";
59   case DW_AT_discr:                      return "DW_AT_discr";
60   case DW_AT_discr_value:                return "DW_AT_discr_value";
61   case DW_AT_visibility:                 return "DW_AT_visibility";
62   case DW_AT_import:                     return "DW_AT_import";
63   case DW_AT_string_length:              return "DW_AT_string_length";
64   case DW_AT_common_reference:           return "DW_AT_common_reference";
65   case DW_AT_comp_dir:                   return "DW_AT_comp_dir";
66   case DW_AT_const_value:                return "DW_AT_const_value";
67   case DW_AT_containing_type:            return "DW_AT_containing_type";
68   case DW_AT_default_value:              return "DW_AT_default_value";
69   case DW_AT_inline:                     return "DW_AT_inline";
70   case DW_AT_is_optional:                return "DW_AT_is_optional";
71   case DW_AT_lower_bound:                return "DW_AT_lower_bound";
72   case DW_AT_producer:                   return "DW_AT_producer";
73   case DW_AT_prototyped:                 return "DW_AT_prototyped";
74   case DW_AT_return_addr:                return "DW_AT_return_addr";
75   case DW_AT_start_scope:                return "DW_AT_start_scope";
76   case DW_AT_bit_stride:                 return "DW_AT_bit_stride";
77   case DW_AT_upper_bound:                return "DW_AT_upper_bound";
78   case DW_AT_abstract_origin:            return "DW_AT_abstract_origin";
79   case DW_AT_accessibility:              return "DW_AT_accessibility";
80   case DW_AT_address_class:              return "DW_AT_address_class";
81   case DW_AT_artificial:                 return "DW_AT_artificial";
82   case DW_AT_base_types:                 return "DW_AT_base_types";
83   case DW_AT_calling_convention:         return "DW_AT_calling_convention";
84   case DW_AT_count:                      return "DW_AT_count";
85   case DW_AT_data_member_location:       return "DW_AT_data_member_location";
86   case DW_AT_decl_column:                return "DW_AT_decl_column";
87   case DW_AT_decl_file:                  return "DW_AT_decl_file";
88   case DW_AT_decl_line:                  return "DW_AT_decl_line";
89   case DW_AT_declaration:                return "DW_AT_declaration";
90   case DW_AT_discr_list:                 return "DW_AT_discr_list";
91   case DW_AT_encoding:                   return "DW_AT_encoding";
92   case DW_AT_external:                   return "DW_AT_external";
93   case DW_AT_frame_base:                 return "DW_AT_frame_base";
94   case DW_AT_friend:                     return "DW_AT_friend";
95   case DW_AT_identifier_case:            return "DW_AT_identifier_case";
96   case DW_AT_macro_info:                 return "DW_AT_macro_info";
97   case DW_AT_namelist_item:              return "DW_AT_namelist_item";
98   case DW_AT_priority:                   return "DW_AT_priority";
99   case DW_AT_segment:                    return "DW_AT_segment";
100   case DW_AT_specification:              return "DW_AT_specification";
101   case DW_AT_static_link:                return "DW_AT_static_link";
102   case DW_AT_type:                       return "DW_AT_type";
103   case DW_AT_use_location:               return "DW_AT_use_location";
104   case DW_AT_variable_parameter:         return "DW_AT_variable_parameter";
105   case DW_AT_virtuality:                 return "DW_AT_virtuality";
106   case DW_AT_vtable_elem_location:       return "DW_AT_vtable_elem_location";
107   case DW_AT_allocated:                  return "DW_AT_allocated";
108   case DW_AT_associated:                 return "DW_AT_associated";
109   case DW_AT_data_location:              return "DW_AT_data_location";
110   case DW_AT_byte_stride:                return "DW_AT_byte_stride";
111   case DW_AT_entry_pc:                   return "DW_AT_entry_pc";
112   case DW_AT_use_UTF8:                   return "DW_AT_use_UTF8";
113   case DW_AT_extension:                  return "DW_AT_extension";
114   case DW_AT_ranges:                     return "DW_AT_ranges";
115   case DW_AT_trampoline:                 return "DW_AT_trampoline";
116   case DW_AT_call_column:                return "DW_AT_call_column";
117   case DW_AT_call_file:                  return "DW_AT_call_file";
118   case DW_AT_call_line:                  return "DW_AT_call_line";
119   case DW_AT_description:                return "DW_AT_description";
120   case DW_AT_binary_scale:               return "DW_AT_binary_scale";
121   case DW_AT_decimal_scale:              return "DW_AT_decimal_scale";
122   case DW_AT_small:                      return "DW_AT_small";
123   case DW_AT_decimal_sign:               return "DW_AT_decimal_sign";
124   case DW_AT_digit_count:                return "DW_AT_digit_count";
125   case DW_AT_picture_string:             return "DW_AT_picture_string";
126   case DW_AT_mutable:                    return "DW_AT_mutable";
127   case DW_AT_threads_scaled:             return "DW_AT_threads_scaled";
128   case DW_AT_explicit:                   return "DW_AT_explicit";
129   case DW_AT_object_pointer:             return "DW_AT_object_pointer";
130   case DW_AT_endianity:                  return "DW_AT_endianity";
131   case DW_AT_elemental:                  return "DW_AT_elemental";
132   case DW_AT_pure:                       return "DW_AT_pure";
133   case DW_AT_recursive:                  return "DW_AT_recursive";
134   case DW_AT_signature:                  return "DW_AT_signature";
135   case DW_AT_main_subprogram:            return "DW_AT_main_subprogram";
136   case DW_AT_data_bit_offset:            return "DW_AT_data_bit_offset";
137   case DW_AT_const_expr:                 return "DW_AT_const_expr";
138   case DW_AT_enum_class:                 return "DW_AT_enum_class";
139   case DW_AT_linkage_name:               return "DW_AT_linkage_name";
140   case DW_AT_string_length_bit_size:     return "DW_AT_string_length_bit_size";
141   case DW_AT_string_length_byte_size:    return "DW_AT_string_length_byte_size";
142   case DW_AT_rank:                       return "DW_AT_rank";
143   case DW_AT_str_offsets_base:           return "DW_AT_str_offsets_base";
144   case DW_AT_addr_base:                  return "DW_AT_addr_base";
145   case DW_AT_ranges_base:                return "DW_AT_ranges_base";
146   case DW_AT_dwo_id:                     return "DW_AT_dwo_id";
147   case DW_AT_dwo_name:                   return "DW_AT_dwo_name";
148   case DW_AT_reference:                  return "DW_AT_reference";
149   case DW_AT_rvalue_reference:           return "DW_AT_rvalue_reference";
150   case DW_AT_MIPS_loop_begin:            return "DW_AT_MIPS_loop_begin";
151   case DW_AT_MIPS_tail_loop_begin:       return "DW_AT_MIPS_tail_loop_begin";
152   case DW_AT_MIPS_epilog_begin:          return "DW_AT_MIPS_epilog_begin";
153   case DW_AT_MIPS_loop_unroll_factor:    return "DW_AT_MIPS_loop_unroll_factor";
154   case DW_AT_MIPS_software_pipeline_depth:
155     return "DW_AT_MIPS_software_pipeline_depth";
156   case DW_AT_MIPS_linkage_name:          return "DW_AT_MIPS_linkage_name";
157   case DW_AT_MIPS_stride:                return "DW_AT_MIPS_stride";
158   case DW_AT_MIPS_abstract_name:         return "DW_AT_MIPS_abstract_name";
159   case DW_AT_MIPS_clone_origin:          return "DW_AT_MIPS_clone_origin";
160   case DW_AT_MIPS_has_inlines:           return "DW_AT_MIPS_has_inlines";
161   case DW_AT_MIPS_stride_byte:           return "DW_AT_MIPS_stride_byte";
162   case DW_AT_MIPS_stride_elem:           return "DW_AT_MIPS_stride_elem";
163   case DW_AT_MIPS_ptr_dopetype:          return "DW_AT_MIPS_ptr_dopetype";
164   case DW_AT_MIPS_allocatable_dopetype:
165     return "DW_AT_MIPS_allocatable_dopetype";
166   case DW_AT_MIPS_assumed_shape_dopetype:
167     return "DW_AT_MIPS_assumed_shape_dopetype";
168   case DW_AT_sf_names:                   return "DW_AT_sf_names";
169   case DW_AT_src_info:                   return "DW_AT_src_info";
170   case DW_AT_mac_info:                   return "DW_AT_mac_info";
171   case DW_AT_src_coords:                 return "DW_AT_src_coords";
172   case DW_AT_body_begin:                 return "DW_AT_body_begin";
173   case DW_AT_body_end:                   return "DW_AT_body_end";
174   case DW_AT_GNU_vector:                 return "DW_AT_GNU_vector";
175   case DW_AT_GNU_template_name:          return "DW_AT_GNU_template_name";
176   case DW_AT_GNU_odr_signature:          return "DW_AT_GNU_odr_signature";
177   case DW_AT_MIPS_assumed_size:          return "DW_AT_MIPS_assumed_size";
178   case DW_AT_lo_user:                    return "DW_AT_lo_user";
179   case DW_AT_hi_user:                    return "DW_AT_hi_user";
180   case DW_AT_APPLE_optimized:            return "DW_AT_APPLE_optimized";
181   case DW_AT_APPLE_flags:                return "DW_AT_APPLE_flags";
182   case DW_AT_APPLE_isa:                  return "DW_AT_APPLE_isa";
183   case DW_AT_APPLE_block:                return "DW_AT_APPLE_block";
184   case DW_AT_APPLE_major_runtime_vers:   return "DW_AT_APPLE_major_runtime_vers";
185   case DW_AT_APPLE_runtime_class:        return "DW_AT_APPLE_runtime_class";
186   case DW_AT_APPLE_omit_frame_ptr:       return "DW_AT_APPLE_omit_frame_ptr";
187   case DW_AT_APPLE_property_name:        return "DW_AT_APPLE_property_name";
188   case DW_AT_APPLE_property_getter:      return "DW_AT_APPLE_property_getter";
189   case DW_AT_APPLE_property_setter:      return "DW_AT_APPLE_property_setter";
190   case DW_AT_APPLE_property_attribute:   return "DW_AT_APPLE_property_attribute";
191   case DW_AT_APPLE_property:             return "DW_AT_APPLE_property";
192   case DW_AT_APPLE_objc_complete_type:   return "DW_AT_APPLE_objc_complete_type";
193
194     // DWARF5 Fission Extension Attribute
195   case DW_AT_GNU_dwo_name:               return "DW_AT_GNU_dwo_name";
196   case DW_AT_GNU_dwo_id:                 return "DW_AT_GNU_dwo_id";
197   case DW_AT_GNU_ranges_base:            return "DW_AT_GNU_ranges_base";
198   case DW_AT_GNU_addr_base:              return "DW_AT_GNU_addr_base";
199   case DW_AT_GNU_pubnames:               return "DW_AT_GNU_pubnames";
200   case DW_AT_GNU_pubtypes:               return "DW_AT_GNU_pubtypes";
201   }
202   return nullptr;
203 }
204
205 const char *llvm::dwarf::FormEncodingString(unsigned Encoding) {
206   switch (Encoding) {
207   case DW_FORM_addr:                     return "DW_FORM_addr";
208   case DW_FORM_block2:                   return "DW_FORM_block2";
209   case DW_FORM_block4:                   return "DW_FORM_block4";
210   case DW_FORM_data2:                    return "DW_FORM_data2";
211   case DW_FORM_data4:                    return "DW_FORM_data4";
212   case DW_FORM_data8:                    return "DW_FORM_data8";
213   case DW_FORM_string:                   return "DW_FORM_string";
214   case DW_FORM_block:                    return "DW_FORM_block";
215   case DW_FORM_block1:                   return "DW_FORM_block1";
216   case DW_FORM_data1:                    return "DW_FORM_data1";
217   case DW_FORM_flag:                     return "DW_FORM_flag";
218   case DW_FORM_sdata:                    return "DW_FORM_sdata";
219   case DW_FORM_strp:                     return "DW_FORM_strp";
220   case DW_FORM_udata:                    return "DW_FORM_udata";
221   case DW_FORM_ref_addr:                 return "DW_FORM_ref_addr";
222   case DW_FORM_ref1:                     return "DW_FORM_ref1";
223   case DW_FORM_ref2:                     return "DW_FORM_ref2";
224   case DW_FORM_ref4:                     return "DW_FORM_ref4";
225   case DW_FORM_ref8:                     return "DW_FORM_ref8";
226   case DW_FORM_ref_udata:                return "DW_FORM_ref_udata";
227   case DW_FORM_indirect:                 return "DW_FORM_indirect";
228   case DW_FORM_sec_offset:               return "DW_FORM_sec_offset";
229   case DW_FORM_exprloc:                  return "DW_FORM_exprloc";
230   case DW_FORM_flag_present:             return "DW_FORM_flag_present";
231   case DW_FORM_ref_sig8:                 return "DW_FORM_ref_sig8";
232
233     // DWARF5 Fission Extension Forms
234   case DW_FORM_GNU_addr_index:           return "DW_FORM_GNU_addr_index";
235   case DW_FORM_GNU_str_index:            return "DW_FORM_GNU_str_index";
236   }
237   return nullptr;
238 }
239
240 const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
241   switch (Encoding) {
242   default: return nullptr;
243 #define HANDLE_DW_OP(ID, NAME)                                                 \
244   case DW_OP_##NAME:                                                           \
245     return "DW_OP_" #NAME;
246 #include "llvm/Support/Dwarf.def"
247   }
248 }
249
250 unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
251   return StringSwitch<unsigned>(OperationEncodingString)
252 #define HANDLE_DW_OP(ID, NAME) .Case("DW_OP_" #NAME, DW_OP_##NAME)
253 #include "llvm/Support/Dwarf.def"
254       .Default(0);
255 }
256
257 const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
258   switch (Encoding) {
259   default: return nullptr;
260 #define HANDLE_DW_ATE(ID, NAME)                                                \
261   case DW_ATE_##NAME:                                                          \
262     return "DW_ATE_" #NAME;
263 #include "llvm/Support/Dwarf.def"
264   }
265 }
266
267 unsigned llvm::dwarf::getAttributeEncoding(StringRef EncodingString) {
268   return StringSwitch<unsigned>(EncodingString)
269 #define HANDLE_DW_ATE(ID, NAME) .Case("DW_ATE_" #NAME, DW_ATE_##NAME)
270 #include "llvm/Support/Dwarf.def"
271       .Default(0);
272 }
273
274 const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
275   switch (Sign) {
276   case DW_DS_unsigned:                   return "DW_DS_unsigned";
277   case DW_DS_leading_overpunch:          return "DW_DS_leading_overpunch";
278   case DW_DS_trailing_overpunch:         return "DW_DS_trailing_overpunch";
279   case DW_DS_leading_separate:           return "DW_DS_leading_separate";
280   case DW_DS_trailing_separate:          return "DW_DS_trailing_separate";
281   }
282   return nullptr;
283 }
284
285 const char *llvm::dwarf::EndianityString(unsigned Endian) {
286   switch (Endian) {
287   case DW_END_default:                   return "DW_END_default";
288   case DW_END_big:                       return "DW_END_big";
289   case DW_END_little:                    return "DW_END_little";
290   case DW_END_lo_user:                   return "DW_END_lo_user";
291   case DW_END_hi_user:                   return "DW_END_hi_user";
292   }
293   return nullptr;
294 }
295
296 const char *llvm::dwarf::AccessibilityString(unsigned Access) {
297   switch (Access) {
298   // Accessibility codes
299   case DW_ACCESS_public:                 return "DW_ACCESS_public";
300   case DW_ACCESS_protected:              return "DW_ACCESS_protected";
301   case DW_ACCESS_private:                return "DW_ACCESS_private";
302   }
303   return nullptr;
304 }
305
306 const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
307   switch (Visibility) {
308   case DW_VIS_local:                     return "DW_VIS_local";
309   case DW_VIS_exported:                  return "DW_VIS_exported";
310   case DW_VIS_qualified:                 return "DW_VIS_qualified";
311   }
312   return nullptr;
313 }
314
315 const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
316   switch (Virtuality) {
317   default:
318     return nullptr;
319 #define HANDLE_DW_VIRTUALITY(ID, NAME)                                         \
320   case DW_VIRTUALITY_##NAME:                                                   \
321     return "DW_VIRTUALITY_" #NAME;
322 #include "llvm/Support/Dwarf.def"
323   }
324 }
325
326 unsigned llvm::dwarf::getVirtuality(StringRef VirtualityString) {
327   return StringSwitch<unsigned>(VirtualityString)
328 #define HANDLE_DW_VIRTUALITY(ID, NAME)                                         \
329   .Case("DW_VIRTUALITY_" #NAME, DW_VIRTUALITY_##NAME)
330 #include "llvm/Support/Dwarf.def"
331       .Default(DW_VIRTUALITY_invalid);
332 }
333
334 const char *llvm::dwarf::LanguageString(unsigned Language) {
335   switch (Language) {
336   default:
337     return nullptr;
338 #define HANDLE_DW_LANG(ID, NAME)                                               \
339   case DW_LANG_##NAME:                                                         \
340     return "DW_LANG_" #NAME;
341 #include "llvm/Support/Dwarf.def"
342   }
343 }
344
345 unsigned llvm::dwarf::getLanguage(StringRef LanguageString) {
346   return StringSwitch<unsigned>(LanguageString)
347 #define HANDLE_DW_LANG(ID, NAME) .Case("DW_LANG_" #NAME, DW_LANG_##NAME)
348 #include "llvm/Support/Dwarf.def"
349       .Default(0);
350 }
351
352 const char *llvm::dwarf::CaseString(unsigned Case) {
353   switch (Case) {
354   case DW_ID_case_sensitive:             return "DW_ID_case_sensitive";
355   case DW_ID_up_case:                    return "DW_ID_up_case";
356   case DW_ID_down_case:                  return "DW_ID_down_case";
357   case DW_ID_case_insensitive:           return "DW_ID_case_insensitive";
358   }
359   return nullptr;
360 }
361
362 const char *llvm::dwarf::ConventionString(unsigned Convention) {
363    switch (Convention) {
364    case DW_CC_normal:                     return "DW_CC_normal";
365    case DW_CC_program:                    return "DW_CC_program";
366    case DW_CC_nocall:                     return "DW_CC_nocall";
367    case DW_CC_lo_user:                    return "DW_CC_lo_user";
368    case DW_CC_hi_user:                    return "DW_CC_hi_user";
369   }
370   return nullptr;
371 }
372
373 const char *llvm::dwarf::InlineCodeString(unsigned Code) {
374   switch (Code) {
375   case DW_INL_not_inlined:               return "DW_INL_not_inlined";
376   case DW_INL_inlined:                   return "DW_INL_inlined";
377   case DW_INL_declared_not_inlined:      return "DW_INL_declared_not_inlined";
378   case DW_INL_declared_inlined:          return "DW_INL_declared_inlined";
379   }
380   return nullptr;
381 }
382
383 const char *llvm::dwarf::ArrayOrderString(unsigned Order) {
384   switch (Order) {
385   case DW_ORD_row_major:                 return "DW_ORD_row_major";
386   case DW_ORD_col_major:                 return "DW_ORD_col_major";
387   }
388   return nullptr;
389 }
390
391 const char *llvm::dwarf::DiscriminantString(unsigned Discriminant) {
392   switch (Discriminant) {
393   case DW_DSC_label:                     return "DW_DSC_label";
394   case DW_DSC_range:                     return "DW_DSC_range";
395   }
396   return nullptr;
397 }
398
399 const char *llvm::dwarf::LNStandardString(unsigned Standard) {
400   switch (Standard) {
401   case DW_LNS_copy:                      return "DW_LNS_copy";
402   case DW_LNS_advance_pc:                return "DW_LNS_advance_pc";
403   case DW_LNS_advance_line:              return "DW_LNS_advance_line";
404   case DW_LNS_set_file:                  return "DW_LNS_set_file";
405   case DW_LNS_set_column:                return "DW_LNS_set_column";
406   case DW_LNS_negate_stmt:               return "DW_LNS_negate_stmt";
407   case DW_LNS_set_basic_block:           return "DW_LNS_set_basic_block";
408   case DW_LNS_const_add_pc:              return "DW_LNS_const_add_pc";
409   case DW_LNS_fixed_advance_pc:          return "DW_LNS_fixed_advance_pc";
410   case DW_LNS_set_prologue_end:          return "DW_LNS_set_prologue_end";
411   case DW_LNS_set_epilogue_begin:        return "DW_LNS_set_epilogue_begin";
412   case DW_LNS_set_isa:                   return "DW_LNS_set_isa";
413   }
414   return nullptr;
415 }
416
417 const char *llvm::dwarf::LNExtendedString(unsigned Encoding) {
418   switch (Encoding) {
419   // Line Number Extended Opcode Encodings
420   case DW_LNE_end_sequence:              return "DW_LNE_end_sequence";
421   case DW_LNE_set_address:               return "DW_LNE_set_address";
422   case DW_LNE_define_file:               return "DW_LNE_define_file";
423   case DW_LNE_set_discriminator:         return "DW_LNE_set_discriminator";
424   case DW_LNE_lo_user:                   return "DW_LNE_lo_user";
425   case DW_LNE_hi_user:                   return "DW_LNE_hi_user";
426   }
427   return nullptr;
428 }
429
430 const char *llvm::dwarf::MacinfoString(unsigned Encoding) {
431   switch (Encoding) {
432   // Macinfo Type Encodings
433   case DW_MACINFO_define:                return "DW_MACINFO_define";
434   case DW_MACINFO_undef:                 return "DW_MACINFO_undef";
435   case DW_MACINFO_start_file:            return "DW_MACINFO_start_file";
436   case DW_MACINFO_end_file:              return "DW_MACINFO_end_file";
437   case DW_MACINFO_vendor_ext:            return "DW_MACINFO_vendor_ext";
438   }
439   return nullptr;
440 }
441
442 const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
443   switch (Encoding) {
444   case DW_CFA_nop:                       return "DW_CFA_nop";
445   case DW_CFA_advance_loc:               return "DW_CFA_advance_loc";
446   case DW_CFA_offset:                    return "DW_CFA_offset";
447   case DW_CFA_restore:                   return "DW_CFA_restore";
448   case DW_CFA_set_loc:                   return "DW_CFA_set_loc";
449   case DW_CFA_advance_loc1:              return "DW_CFA_advance_loc1";
450   case DW_CFA_advance_loc2:              return "DW_CFA_advance_loc2";
451   case DW_CFA_advance_loc4:              return "DW_CFA_advance_loc4";
452   case DW_CFA_offset_extended:           return "DW_CFA_offset_extended";
453   case DW_CFA_restore_extended:          return "DW_CFA_restore_extended";
454   case DW_CFA_undefined:                 return "DW_CFA_undefined";
455   case DW_CFA_same_value:                return "DW_CFA_same_value";
456   case DW_CFA_register:                  return "DW_CFA_register";
457   case DW_CFA_remember_state:            return "DW_CFA_remember_state";
458   case DW_CFA_restore_state:             return "DW_CFA_restore_state";
459   case DW_CFA_def_cfa:                   return "DW_CFA_def_cfa";
460   case DW_CFA_def_cfa_register:          return "DW_CFA_def_cfa_register";
461   case DW_CFA_def_cfa_offset:            return "DW_CFA_def_cfa_offset";
462   case DW_CFA_def_cfa_expression:        return "DW_CFA_def_cfa_expression";
463   case DW_CFA_expression:                return "DW_CFA_expression";
464   case DW_CFA_offset_extended_sf:        return "DW_CFA_offset_extended_sf";
465   case DW_CFA_def_cfa_sf:                return "DW_CFA_def_cfa_sf";
466   case DW_CFA_def_cfa_offset_sf:         return "DW_CFA_def_cfa_offset_sf";
467   case DW_CFA_val_offset:                return "DW_CFA_val_offset";
468   case DW_CFA_val_offset_sf:             return "DW_CFA_val_offset_sf";
469   case DW_CFA_val_expression:            return "DW_CFA_val_expression";
470   case DW_CFA_MIPS_advance_loc8:         return "DW_CFA_MIPS_advance_loc8";
471   case DW_CFA_GNU_window_save:           return "DW_CFA_GNU_window_save";
472   case DW_CFA_GNU_args_size:             return "DW_CFA_GNU_args_size";
473   case DW_CFA_lo_user:                   return "DW_CFA_lo_user";
474   case DW_CFA_hi_user:                   return "DW_CFA_hi_user";
475   }
476   return nullptr;
477 }
478
479 const char *llvm::dwarf::ApplePropertyString(unsigned Prop) {
480   switch (Prop) {
481   case DW_APPLE_PROPERTY_readonly:
482     return "DW_APPLE_PROPERTY_readonly";
483   case DW_APPLE_PROPERTY_getter:
484     return "DW_APPLE_PROPERTY_getter";
485   case DW_APPLE_PROPERTY_assign:
486     return "DW_APPLE_PROPERTY_assign";
487   case DW_APPLE_PROPERTY_readwrite:
488     return "DW_APPLE_PROPERTY_readwrite";
489   case DW_APPLE_PROPERTY_retain:
490     return "DW_APPLE_PROPERTY_retain";
491   case DW_APPLE_PROPERTY_copy:
492     return "DW_APPLE_PROPERTY_copy";
493   case DW_APPLE_PROPERTY_nonatomic:
494     return "DW_APPLE_PROPERTY_nonatomic";
495   case DW_APPLE_PROPERTY_setter:
496     return "DW_APPLE_PROPERTY_setter";
497   case DW_APPLE_PROPERTY_atomic:
498     return "DW_APPLE_PROPERTY_atomic";
499   case DW_APPLE_PROPERTY_weak:
500     return "DW_APPLE_PROPERTY_weak";
501   case DW_APPLE_PROPERTY_strong:
502     return "DW_APPLE_PROPERTY_strong";
503   case DW_APPLE_PROPERTY_unsafe_unretained:
504     return "DW_APPLE_PROPERTY_unsafe_unretained";
505   }
506   return nullptr;
507 }
508
509 const char *llvm::dwarf::AtomTypeString(unsigned AT) {
510   switch (AT) {
511   case dwarf::DW_ATOM_null:
512     return "DW_ATOM_null";
513   case dwarf::DW_ATOM_die_offset:
514     return "DW_ATOM_die_offset";
515   case DW_ATOM_cu_offset:
516     return "DW_ATOM_cu_offset";
517   case DW_ATOM_die_tag:
518     return "DW_ATOM_die_tag";
519   case DW_ATOM_type_flags:
520     return "DW_ATOM_type_flags";
521   }
522   return nullptr;
523 }
524
525 const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
526   switch (Kind) {
527   case GIEK_NONE:
528     return "NONE";
529   case GIEK_TYPE:
530     return "TYPE";
531   case GIEK_VARIABLE:
532     return "VARIABLE";
533   case GIEK_FUNCTION:
534     return "FUNCTION";
535   case GIEK_OTHER:
536     return "OTHER";
537   case GIEK_UNUSED5:
538     return "UNUSED5";
539   case GIEK_UNUSED6:
540     return "UNUSED6";
541   case GIEK_UNUSED7:
542     return "UNUSED7";
543   }
544   llvm_unreachable("Unknown GDBIndexEntryKind value");
545 }
546
547 const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
548   switch (Linkage) {
549   case GIEL_EXTERNAL:
550     return "EXTERNAL";
551   case GIEL_STATIC:
552     return "STATIC";
553   }
554   llvm_unreachable("Unknown GDBIndexEntryLinkage value");
555 }
556
557 const char *llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
558   switch (Attr) {
559   case DW_AT_accessibility:
560     return AccessibilityString(Val);
561   case DW_AT_virtuality:
562     return VirtualityString(Val);
563   case DW_AT_language:
564     return LanguageString(Val);
565   case DW_AT_encoding:
566     return AttributeEncodingString(Val);
567   case DW_AT_decimal_sign:
568     return DecimalSignString(Val);
569   case DW_AT_endianity:
570     return EndianityString(Val);
571   case DW_AT_visibility:
572     return VisibilityString(Val);
573   case DW_AT_identifier_case:
574     return CaseString(Val);
575   case DW_AT_calling_convention:
576     return ConventionString(Val);
577   case DW_AT_inline:
578     return InlineCodeString(Val);
579   case DW_AT_ordering:
580     return ArrayOrderString(Val);
581   case DW_AT_discr_value:
582     return DiscriminantString(Val);
583   }
584
585   return nullptr;
586 }