From ed9d38ffb3e505b247fbf17becc785f10407e34d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 16 Sep 2019 10:16:56 +0000 Subject: [PATCH] [clangd] Fix a crash when renaming operator. Summary: The renamelib uses a tricky way to calculate the end location by relying on decl name, this is incorrect for the overloaded operator (the name is "operator++" instead of "++"), which will cause out-of-file offset. We also disable renaming operator symbol, this case is tricky, and renamelib doesnt handle it properly. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67607 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371971 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h b/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h index 41a448f035..cd230ea18b 100644 --- a/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h +++ b/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h @@ -122,8 +122,7 @@ private: ND, SourceRange(BeginLoc, EndLoc)); } bool visit(const NamedDecl *ND, SourceLocation Loc) { - return visit(ND, Loc, - Loc.getLocWithOffset(ND->getNameAsString().length() - 1)); + return visit(ND, Loc, Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts)); } }; -- 2.50.1