[all-commits] [llvm/llvm-project] 38bdb9: [clangd] Fix rename for explicit destructor calls

Kirill Bobyrev via All-commits all-commits at lists.llvm.org
Mon Jan 20 20:36:11 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 38bdb94120b76f8f79cd27d721892673e573895a
      https://github.com/llvm/llvm-project/commit/38bdb94120b76f8f79cd27d721892673e573895a
  Author: Kirill Bobyrev <kbobyrev at google.com>
  Date:   2020-01-21 (Tue, 21 Jan 2020)

  Changed paths:
    M clang-tools-extra/clangd/FindTarget.cpp
    M clang-tools-extra/clangd/unittests/FindTargetTests.cpp
    M clang-tools-extra/clangd/unittests/RenameTests.cpp

  Log Message:
  -----------
  [clangd] Fix rename for explicit destructor calls

When triggering rename of the class name in the code with explicit destructor
calls, rename fails. Consider the following piece of code:

```
class Foo;

...

Foo f;
f.~/*...*/Foo();
```

`findExplicitReferences` will report two `ReferenceLoc` for destructor call:
one is comming from `MemberExpr` (i.e. destructor call itself) and would point
to the tilde:

```
f.~/*...*/Foo();
  ^
```

And the second one is pointing to the typename and is coming from `TypeLoc`.

```
f.~/*...*/Foo();
          ^
```

This causes rename to produce incorrect textual replacements. This patch
updates `MemberExpr` handler to detect destructor calls and prevents it
from reporting a duplicate reference.

Resolves: https://github.com/clangd/clangd/issues/236

Reviewers: kadircet, hokein

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




More information about the All-commits mailing list