[Bug 35654] New: LLDB Does not print the correct value for a variable (suspect NRVO alias issue)

Bug ID 35654
Summary LLDB Does not print the correct value for a variable (suspect NRVO alias issue)
Product lldb
Version unspecified
Hardware Macintosh
OS MacOS X
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter chris.m.hartman@gmail.com
CC llvm-bugs@lists.llvm.org

labath@google.com changed bug 35654

What Removed Added
Assignee lldb-dev@lists.llvm.org jingham@apple.com

Comment # 6 on bug 35654 from labath@google.com

Thanks for the binaries.

This here seems to be the key (diff of output of llvm-dwarfdump on main.o):
 0x0000006e:     DW_TAG_variable
                   DW_AT_location       (0x00000000
-                     0x0000000000000028 - 0x0000000000000041: DW_OP_breg6
RBP-24)
+                     0x0000000000000028 - 0x0000000000000041: DW_OP_breg6
RBP-24, DW_OP_deref)
                   DW_AT_name   ("r")

(the - is your file, the + is the file generated by my clang).

It seems that the xcode clang forgot to add the OP_deref opcode to the location
of the r variable. This means lldb will go looking for in in the wrong place
and display garbage.

Since the behavior is correct on older clangs as well as on current master, I
assume that the Xcode branched clang off of some revision that had this broken.
There isn't much we can do about this from the debugger side, but I'll assign
this to our xcode folks, to see if they can do anything about the compiler
itself.