[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/clang-tools-extra/trunk@371971 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clangd/refactor/Rename.cpp b/clangd/refactor/Rename.cpp
index 770064f..3c6119a 100644
--- a/clangd/refactor/Rename.cpp
+++ b/clangd/refactor/Rename.cpp
@@ -74,6 +74,10 @@
                                                    const SymbolIndex *Index) {
   if (llvm::isa<NamespaceDecl>(&RenameDecl))
     return ReasonToReject::UnsupportedSymbol;
+  if (const auto *FD = llvm::dyn_cast<FunctionDecl>(&RenameDecl)) {
+    if (FD->isOverloadedOperator())
+      return ReasonToReject::UnsupportedSymbol;
+  }
   auto &ASTCtx = RenameDecl.getASTContext();
   const auto &SM = ASTCtx.getSourceManager();
   bool MainFileIsHeader = ASTCtx.getLangOpts().IsHeaderFile;
diff --git a/clangd/unittests/RenameTests.cpp b/clangd/unittests/RenameTests.cpp
index 99e07e2..91d9c0f 100644
--- a/clangd/unittests/RenameTests.cpp
+++ b/clangd/unittests/RenameTests.cpp
@@ -136,6 +136,13 @@
        )cpp",
           "not a supported kind", HeaderFile},
 
+      {
+
+          R"cpp(
+        struct X { X operator++(int) {} };
+        void f(X x) {x+^+;})cpp",
+          "not a supported kind", HeaderFile},
+
       {R"cpp(// foo is declared outside the file.
         void fo^o() {}
       )cpp", "used outside main file", !HeaderFile/*cc file*/},