[all-commits] [llvm/llvm-project] cb81e6: [lldb] Reject redefinitions of persistent variables

Raphael Isemann via All-commits all-commits at lists.llvm.org
Wed Oct 14 01:25:21 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: cb81e662a58908913f342520e4c010564a68126a
      https://github.com/llvm/llvm-project/commit/cb81e662a58908913f342520e4c010564a68126a
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2020-10-14 (Wed, 14 Oct 2020)

  Changed paths:
    M lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
    M lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
    M lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
    M lldb/test/API/commands/expression/persistent_variables/TestPersistentVariables.py

  Log Message:
  -----------
  [lldb] Reject redefinitions of persistent variables

Currently one can redefine a persistent variable and LLDB will just silently
ignore the second definition:

```
(lldb) expr int $i = 1
(lldb) expr int $i = 2
(lldb) expr $i
(int) $i = 1
```

This patch makes this an error and rejects the expression with the second
definition.

A nice follow up would be to refactor LLDB's persistent variables to not just be
a pair of type and name, but also contain some way to obtain the original
declaration and source code that declared the variable. That way we could
actually make a full diagnostic as we would get from redefining a variable twice
in the same expression.

Reviewed By: labath, shafik, JDevlieghere

Differential Revision: https://reviews.llvm.org/D89310




More information about the All-commits mailing list