r371971 - [clangd] Fix a crash when renaming operator.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 16 03:16:56 PDT 2019
Author: hokein
Date: Mon Sep 16 03:16:56 2019
New Revision: 371971
URL: http://llvm.org/viewvc/llvm-project?rev=371971&view=rev
Log:
[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
Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
Modified: cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h?rev=371971&r1=371970&r2=371971&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h Mon Sep 16 03:16:56 2019
@@ -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));
}
};
More information about the cfe-commits
mailing list