llvm-project/clang-tools-extra/clangd
Kirill Bobyrev 38bdb94120
[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
2020-01-21 05:33:39 +01:00
..
benchmarks Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
clients/clangd-vscode NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
fuzzer [clang-tools-extra] [cmake] Link against libclang-cpp whenever possible 2019-10-04 20:30:02 +00:00
include-mapping [clangd] Add include-mapping for C symbols. 2019-06-21 13:32:18 +00:00
index [clangd] Add xref for macros to FileIndex. 2020-01-08 08:27:50 +01:00
indexer Revert "Use InitLLVM to setup a pretty stack printer" 2019-11-25 21:06:56 -05:00
refactor [clangd] Avoid redundant testcases in rename unittest, NFC. 2020-01-20 17:01:05 +01:00
test [clangd] Rearrange type, returntype and parameters in hover card 2020-01-15 15:55:46 +01:00
tool [clangd] Add path mappings functionality 2020-01-07 12:40:51 +01:00
unittests [clangd] Fix rename for explicit destructor calls 2020-01-21 05:33:39 +01:00
xpc Get ClangdXPC.framework building (barely) with CMake's Xcode generator 2019-10-11 01:23:56 +00:00
AST.cpp [clangd] Replace shortenNamespace with getQualification 2020-01-03 09:05:30 +01:00
AST.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
CMakeLists.txt [clangd] Add path mappings functionality 2020-01-07 12:40:51 +01:00
CSymbolMap.inc [clangd] Add include-mapping for C symbols. 2019-06-21 13:32:18 +00:00
Cancellation.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Cancellation.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ClangdLSPServer.cpp Revert "Revert "[clangd] Implement "textDocument/documentLink" protocol support"" 2020-01-02 16:36:21 +01:00
ClangdLSPServer.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
ClangdServer.cpp Revert "Revert "[clangd] Implement "textDocument/documentLink" protocol support"" 2020-01-02 16:36:21 +01:00
ClangdServer.h Revert "Revert "[clangd] Implement "textDocument/documentLink" protocol support"" 2020-01-02 16:36:21 +01:00
CodeComplete.cpp NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
CodeComplete.h Fix trivial typos in comments; NFC 2020-01-02 13:41:43 -05:00
CodeCompletionStrings.cpp Code completion should not ignore default parameters in functions. 2019-08-07 16:52:21 +00:00
CodeCompletionStrings.h [clangd] Place cursor better after completing patterns 2019-05-28 15:33:37 +00:00
CollectMacros.h [clangd] Inactive regions support as an extension to semantic highlighting 2019-11-21 19:40:55 -05:00
CompileCommands.cpp [clangd] Respect `--sysroot` argument if it is set 2020-01-09 11:02:58 -05:00
CompileCommands.h [clangd] Try to fix CompileCommandsTests on windows. NFC 2019-12-06 12:28:01 +01:00
Compiler.cpp [clangd] Log cc1 args at verbose level. 2019-11-29 11:00:01 +01:00
Compiler.h [clangd] Log cc1 args at verbose level. 2019-11-29 11:00:01 +01:00
Context.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Context.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
Diagnostics.cpp [clangd] Adjust diagnostic range to be inside main file 2020-01-09 18:02:33 +01:00
Diagnostics.h [NFC] Fix typos in Clangd and Clang 2019-12-16 10:54:40 +01:00
DraftStore.cpp [clangd] Fix error message with incorrect TextDocumentcontentChangeEvent.rangeLength 2019-08-05 08:14:13 +00:00
DraftStore.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ExpectedTypes.cpp [clangd] Reland b5135a86e0476: Fix a crash in expected types 2019-11-21 09:46:40 +01:00
ExpectedTypes.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FS.cpp [clangd] Get rid of dots and dotsdots within GlobalCompilationDatabase 2019-07-18 16:13:23 +00:00
FS.h [clangd] Get rid of dots and dotsdots within GlobalCompilationDatabase 2019-07-18 16:13:23 +00:00
FSProvider.cpp [clangd] Unlink VFS working dir from OS working dir. Reland of r351051 2019-02-15 11:04:25 +00:00
FSProvider.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Features.inc.in [clangd] XPC transport layer 2019-01-16 00:24:22 +00:00
FileDistance.cpp [clangd] Save an unnecessary copy, NFC. 2019-09-24 13:25:38 +00:00
FileDistance.h Move endian constant from Host.h to SwapByteOrder.h, prune include 2019-10-19 00:48:11 +00:00
FindSymbols.cpp [clangd] Fix DocumentOutline for concepts 2020-01-20 20:20:27 +01:00
FindSymbols.h [clangd] Type hierarchy subtypes 2019-06-16 02:31:37 +00:00
FindTarget.cpp [clangd] Fix rename for explicit destructor calls 2020-01-21 05:33:39 +01:00
FindTarget.h [clangd] targetDecl() returns only NamedDecls. 2020-01-03 18:18:40 +01:00
Format.cpp [clangd] Fix gcc warning by removing extra ";" 2019-06-11 06:02:01 +00:00
Format.h [clangd] Revamp textDocument/onTypeFormatting. 2019-06-10 14:26:21 +00:00
FormattedString.cpp [clangd] Add a ruler after header in hover 2020-01-15 15:54:38 +01:00
FormattedString.h [clangd] Add a ruler after header in hover 2020-01-15 15:54:38 +01:00
Function.h [clangd] Remove Bind, use C++14 lambda captures instead. NFC 2019-08-16 09:20:01 +00:00
FuzzyMatch.cpp [clangd] Tune the fuzzy-matching algorithm 2019-03-15 14:00:49 +00:00
FuzzyMatch.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
GlobalCompilationDatabase.cpp [clangd] (take 2) Try harder to find a plausible `clang` as argv0, particularly on Mac. 2019-12-06 09:47:03 +01:00
GlobalCompilationDatabase.h [clangd] (take 2) Try harder to find a plausible `clang` as argv0, particularly on Mac. 2019-12-06 09:47:03 +01:00
HeaderSourceSwitch.cpp [clangd] NFC, add getLangOpts helper to ParsedAST 2019-12-04 16:55:25 -08:00
HeaderSourceSwitch.h [clangd] Implement a smart version of HeaderSource switch. 2019-09-30 10:48:02 +00:00
Headers.cpp [clang-tools-extra] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:52:23 +00:00
Headers.h [clangd][NFC] Typo in comment 2019-07-30 20:39:39 +00:00
Hover.cpp [clangd] Add workaround for GCC5 host compilers. NFC. 2020-01-16 16:05:22 -05:00
Hover.h [clangd] Introduce paragraph, the first part of new rendering structs 2019-12-13 09:58:55 +01:00
IncludeFixer.cpp NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
IncludeFixer.h [clangd] Compute scopes eagerly in IncludeFixer 2019-08-06 11:37:50 +00:00
JSONTransport.cpp [clangd] Shutdown cleanly on signals. 2019-11-27 12:38:49 +01:00
Logger.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Logger.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ParsedAST.cpp Fix naming style. NFC. 2019-12-12 17:00:57 +01:00
ParsedAST.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
Path.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PathMapping.cpp [clangd] Add path mappings functionality 2020-01-07 12:40:51 +01:00
PathMapping.h [clangd] Add path mappings functionality 2020-01-07 12:40:51 +01:00
Preamble.cpp [clangd] Improve long and confusing preamble log message. 2019-11-16 17:13:02 +01:00
Preamble.h [clangd] Collect macros in the preamble region of the main file 2019-09-24 11:14:06 +00:00
Protocol.cpp Revert "Revert "[clangd] Implement "textDocument/documentLink" protocol support"" 2020-01-02 16:36:21 +01:00
Protocol.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
Quality.cpp [clangd] cleanup: unify the implemenation of checking a location is inside main file. 2019-07-19 08:33:39 +00:00
Quality.h [clangd] Remove unused signature help quality signal. NFC 2019-06-06 08:32:25 +00:00
QueryDriverDatabase.cpp [clang-tools-extra] Migrate llvm::make_unique to std::make_unique 2019-08-14 23:52:23 +00:00
RIFF.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RIFF.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Selection.cpp [clangd] Include expression in DecltypeTypeLoc sourcerange while building SelectionTree 2020-01-13 20:33:13 +01:00
Selection.h Revert "[clangd] Reapply b60896fad9 Fall back to selecting token-before-cursor if token-after-cursor fails." 2019-12-16 19:07:49 +01:00
SemanticHighlighting.cpp [clangd] Highlighting dependent types in more contexts 2019-12-05 14:30:53 -05:00
SemanticHighlighting.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
SemanticSelection.cpp Revert "[clangd] Reapply b60896fad9 Fall back to selecting token-before-cursor if token-after-cursor fails." 2019-12-16 19:07:49 +01:00
SemanticSelection.h Implement semantic selections. 2019-09-16 11:29:35 +00:00
Shutdown.cpp [clangd] Shutdown cleanly on signals. 2019-11-27 12:38:49 +01:00
Shutdown.h [clangd] Shutdown cleanly on signals. 2019-11-27 12:38:49 +01:00
SourceCode.cpp [clangd] Simplify code using findName. NFC 2019-12-10 10:22:43 +01:00
SourceCode.h [clangd] Simplify code using findName. NFC 2019-12-10 10:22:43 +01:00
StdSymbolMap.inc [clangd] Add include-mapping for C symbols. 2019-06-21 13:32:18 +00:00
TUScheduler.cpp [NFC] Fix typos in Clangd and Clang 2019-12-16 10:54:40 +01:00
TUScheduler.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
Threading.cpp [clangd] Use llvm::set_thread_priority in background-index 2019-04-18 13:46:40 +00:00
Threading.h [clangd] Remove obsolete includes. NFC 2019-09-04 10:01:05 +00:00
Trace.cpp [clangd] Remove obsolete includes. NFC 2019-09-04 10:01:05 +00:00
Trace.h NFC: Fix trivial typos in comments 2020-01-04 10:28:41 -05:00
Transport.h [NFC] Fix typos in Clangd and Clang 2019-12-16 10:54:40 +01:00
URI.cpp [clangd] Simplify the callside of URI::resolve, NFC. 2019-09-23 14:39:37 +00:00
URI.h [clangd] Simplify the callside of URI::resolve, NFC. 2019-09-23 14:39:37 +00:00
XRefs.cpp [clangd] Publish xref for macros from Index and AST. 2020-01-13 11:11:18 +01:00
XRefs.h Revert "Revert "[clangd] Implement "textDocument/documentLink" protocol support"" 2020-01-02 16:36:21 +01:00