## This test checks that DW_OP_addrx expression operand
## is correctly recognized and converted into the DW_OP_addr
## operand or just preserved in case --update.
## cat dwarf5-dw-op-addrx.c
## char arr[40];
## char arr2[40];
## char arr3[40];
## char arr4[40];
## char arr5[40];
## char arr6[40];
## char arr7[40];
## char arr8[40];
## char arr9[40];
## int main() { return 0;}
## $ clang -gdwarf-5 dwarf5-dw-op-addrx.c -c -O2 -o dwarf5-dw-op-addrx.o
#RUN: dsymutil -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK
#RUN: dsymutil --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK
#RUN: dsymutil --linker parallel -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix DWARF-CHECK
#RUN: dsymutil --linker parallel --update -oso-prepend-path %p/../Inputs -y %s -o %t.dSYM
#RUN: llvm-dwarfdump --verify %t.dSYM | FileCheck %s
#RUN: llvm-dwarfdump -a --verbose %t.dSYM | FileCheck %s --check-prefix UPD-DWARF-CHECK
#CHECK: No errors.
#DWARF-CHECK: DW_TAG_compile_unit
#DWARF-CHECK: DW_AT_name {{.*}}"dwarf5-dw-op-addrx.c"
#DWARF-CHECK: DW_AT_low_pc {{.*}}0x0000000100000fb0
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100001000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr2"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100002000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr3"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100003000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr4"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100004000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr5"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100005000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr6"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100006000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr7"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100007000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr8"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100008000)
#DWARF-CHECK: DW_TAG_variable
#DWARF-CHECK: DW_AT_name {{.*}}"arr9"
#DWARF-CHECK: DW_AT_location {{.*}}(DW_OP_addr 0x100009000)
#UPD-DWARF-CHECK: DW_TAG_compile_unit
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"dwarf5-dw-op-addrx.c"
#UPD-DWARF-CHECK: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000009) address = 0x0000000000000000)
#UPD-DWARF-CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000008)
#UPD-DWARF-CHECK: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x0)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr2"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x1)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr3"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x2)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr4"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x3)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr5"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x4)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr6"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x5)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr7"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x6)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr8"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x7)
#UPD-DWARF-CHECK: DW_TAG_variable
#UPD-DWARF-CHECK: DW_AT_name {{.*}}"arr9"
#UPD-DWARF-CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addrx 0x8)
#UPD-DWARF-CHECK: .debug_addr contents:
#UPD-DWARF-CHECK: 0x00000000: Address table header: length = 0x00000054, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
#UPD-DWARF-CHECK: 0x0000000000000000
---
triple: 'x86_64-apple-darwin'
objects:
- filename: 'dwarf5-dw-op-addrx.o'
timestamp: 1676048242
symbols:
- { sym: _main, objAddr: 0x0000000000000000, binAddr: 0x0000000100000FB0, size: 0x00000008 }
- { sym: _arr, binAddr: 0x0000000100001000, size: 0x00000008 }
- { sym: _arr2, binAddr: 0x0000000100002000, size: 0x00000008 }
- { sym: _arr3, binAddr: 0x0000000100003000, size: 0x00000008 }
- { sym: _arr4, binAddr: 0x0000000100004000, size: 0x00000008 }
- { sym: _arr5, binAddr: 0x0000000100005000, size: 0x00000008 }
- { sym: _arr6, binAddr: 0x0000000100006000, size: 0x00000008 }
- { sym: _arr7, binAddr: 0x0000000100007000, size: 0x00000008 }
- { sym: _arr8, binAddr: 0x0000000100008000, size: 0x00000008 }
- { sym: _arr9, binAddr: 0x0000000100009000, size: 0x00000008 }