[PATCH] D58447: [clangd] Fix a crash in Selection

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 20 11:26:17 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL354507: [clangd] Fix a crash in Selection (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58447?vs=187569&id=187632#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58447/new/

https://reviews.llvm.org/D58447

Files:
  clang-tools-extra/trunk/clangd/Selection.cpp
  clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
           }]]]]
         }
       )cpp",
+      R"cpp(
+          template <class T>
+          struct unique_ptr {};
+          void foo(^$C[[unique_ptr<unique_ptr<$C[[int]]>>]]^ a) {}
+      )cpp",
   };
   for (const char *C : Cases) {
     Annotations Test(C);
Index: clang-tools-extra/trunk/clangd/Selection.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/Selection.cpp
+++ clang-tools-extra/trunk/clangd/Selection.cpp
@@ -198,11 +198,10 @@
       auto E = SM.getDecomposedLoc(R.getEnd());
       if (B.first != SelFile || E.first != SelFile)
         continue;
-      assert(R.isTokenRange());
       // Try to cover up to the next token, spaces between children don't count.
       if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
         E.second = SM.getFileOffset(Tok->getLocation());
-      else
+      else if (R.isTokenRange())
         E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
       ChildRanges.push_back({B.second, E.second});
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58447.187632.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190220/5157e723/attachment.bin>


More information about the cfe-commits mailing list