llvm-project/llvm/unittests/DebugInfo/DWARF
Jonas Devlieghere 3a04bea91a [DebugInfo] Have custom std::reverse_iterator<DWARFDie>
The DWARFDie is a lightweight utility wrapper that stores a pointer to a
compile unit and a debug info entry. Currently, its iterator (used for
walking over its children) stores a DWARFDie and returns a const
reference when dereferencing it.

When the iterator is modified (by incrementing or decrementing it), this
reference becomes invalid. This was happening when calling reverse on
it, because the std::reverse_iterator is keeping a temporary copy of the
iterator (see
https://en.cppreference.com/w/cpp/iterator/reverse_iterator for a good
illustration).

The relevant code in libcxx:

  reference operator*() const {_Iter __tmp = current; return *--__tmp;}

When dereferencing the reverse iterator, we decrement and return a
reference to a DWARFDie stored in the stack frame of this function,
resulting in UB at runtime.

This patch specifies the std::reverse_iterator for DWARFDie to do the
right thing.

Differential revision: https://reviews.llvm.org/D49679

llvm-svn: 338506
2018-08-01 10:24:17 +00:00
..
CMakeLists.txt Inline a few CMake variables into their only uses. 2018-05-14 19:23:31 +00:00
DWARFDebugInfoTest.cpp [DebugInfo] Have custom std::reverse_iterator<DWARFDie> 2018-08-01 10:24:17 +00:00
DWARFDebugLineTest.cpp [DWARF] Refactor callback usage for .debug_line error handling 2018-05-21 15:30:54 +00:00
DWARFFormValueTest.cpp DWARF: Unify form size handling code 2018-03-14 09:39:54 +00:00
DwarfGenerator.cpp dwarfgen: Add support for generating the debug_str_offsets section, take 3 2018-07-26 14:36:07 +00:00
DwarfGenerator.h dwarfgen: Add support for generating the debug_str_offsets section, take 3 2018-07-26 14:36:07 +00:00
DwarfUtils.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
DwarfUtils.h [DWARF] Don't attempt to parse line tables at invalid offsets 2018-03-08 10:53:34 +00:00