[llvm-bugs] [Bug 40189] New: LLDB expressions always error if a C++ local variable is named after a keyword

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 30 16:38:47 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=40189

            Bug ID: 40189
           Summary: LLDB expressions always error if a C++ local variable
                    is named after a keyword
           Product: lldb
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: jacobly.alt at gmail.com
                CC: llvm-bugs at lists.llvm.org

This is only triggered by the debug info produced by gcc, not by clang.  It
seems that uses of e.g. __func__ and __PRETTY_FUNCTION__ cause gcc to emit
debug info for a local variable named after the corresponding keyword, where
clang does not emit anything.  I have confirmed this happens with g++ 8.2.0 and
lldb 7.0.0, 7.0.1, and trunk.

Quick repro:
$ echo 'int main(int argc){__func__;}' | g++ -g -x c++ - && lldb -o 'br s -n
main' -o 'pr la' -o 'expr argc' a.out

which produces
error: expected unqualified-id

which occurs because of a syntax error on the line
using $__lldb_local_vars::__func__;

Note that C programs don't generate such using lines, and therefore don't
exhibit this bug.  I encountered this bug while debugging llvm (accidentally
compiled with gcc) in any function that uses assert, e.g. compileModule in
tools/llc/llc.cpp.

I confirmed that a workaround is to add hardcoded exceptions to
AddLocalVariableDecls in tools/lldb/source/Expression/ExpressionSourceCode.cpp,
but I'm not sure if that is the correct way to fix this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181231/6bd440af/attachment.html>


More information about the llvm-bugs mailing list