Comments (4)
It can be reproduced with the following test case:
TEST_F(ClangdVFSTest, TestRandom) {
MockFSProvider FS;
ErrorCheckingDiagConsumer DiagConsumer;
MockCompilationDatabase CDB;
ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
auto FooCpp = testPath("foo.cpp");
Annotations Code(R"cpp(
struct Foo{};
Foo test() {
F^oo x;
return x;
}
)cpp");
runAddDocument(Server, FooCpp, Code.code());
auto X = runRename(Server, FooCpp, Code.point(), "new_name");
ASSERT_TRUE(!!X);
size_t PrevOffset = -1;
for (const auto &T : X.get()) {
EXPECT_NE(PrevOffset, T.getOffset());
PrevOffset = T.getOffset();
}
}
Unfortunately issue seems to be rather related to clang api we use, https://github.com/llvm/llvm-project/blob/master/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp#L84
Because visitor itself returns duplicate entries for the return type of function test()
from clangd.
Another case this happens:
void foo() {
if(auto add_xxx = 5) {
add_xxx = 3;
}
}
try renaming add_xxx
to added_xxx
(either of them results in same breakage). Which simply fails on vscode by saying "overlapping edits" and results in malformed text in vim like added_xxxxx
.
from clangd.
Ycmd can cope with this as long as the old and new name have the same length, otherwise a duplicated edit does make a mess. Requesting a RefactorRename foo_bar
would correctly replace the text.
from clangd.
Fixed in r360116.
from clangd.
Related Issues (20)
- Add a fixit for inserting the matching closing brace HOT 3
- Clangd and -ffreestanding
- refactor: missing class identifier after moving desctructor implementation HOT 2
- Clangd using clangd fallback even after loading compilation database HOT 4
- Clangd always chooses debug config compile commands with Ninja Multi-Config HOT 5
- Clangd crashes while parsing invalid code HOT 3
- Weekly snapshot releases are not being published again, since 20240421
- Don`t work in vs code with qt6 HOT 1
- clangd-indexer aborts while creating index file HOT 2
- Add header-insertion: never option to .clangd config HOT 3
- Template arguments in placeholder's type-constraint are not selected correctly. HOT 2
- clangd do not recognise headers located in pch HOT 2
- Call hierarchy points to an empty line HOT 3
- Issue with Clang Tools on Windows using Cygwin64 for a C++17 project with <mutex> HOT 8
- Unused header warning for placement new
- headers from pch are not recognized inside project HOT 8
- clangd does not detect C++17 or newer features when compiled with CMake 3.28 + Ninja on Windows HOT 8
- omit `self` when clangd compltes member function with explicit self HOT 4
- Include Cleaner fails for symbols forward-declared and aliased
- Include cleaner recommends removing includes needed for casts to related types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clangd.