1 //===-- DIERef.cpp ----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "DIERef.h"
10 #include "DWARFUnit.h"
11 #include "DWARFDebugInfo.h"
12 #include "DWARFFormValue.h"
13 #include "SymbolFileDWARF.h"
14 #include "SymbolFileDWARFDebugMap.h"
15 
16 DIERef::DIERef(const DWARFFormValue &form_value)
17     : cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) {
18   if (form_value.IsValid()) {
19     const DWARFUnit *dwarf_cu = form_value.GetCompileUnit();
20     if (dwarf_cu) {
21       if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
22         cu_offset = dwarf_cu->GetBaseObjOffset();
23       else
24         cu_offset = dwarf_cu->GetOffset();
25     }
26     die_offset = form_value.Reference();
27   }
28 }
29