<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - LLDB expressions always error if a C++ local variable is named after a keyword"
href="https://bugs.llvm.org/show_bug.cgi?id=40189">40189</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLDB expressions always error if a C++ local variable is named after a keyword
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jacobly.alt@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>