[clangd] Return earlier when snippet is empty
authorTom Praschan <13141438+tom-anders@users.noreply.github.com>
Sun, 18 Sep 2022 16:48:11 +0000 (18:48 +0200)
committerTom Praschan <13141438+tom-anders@users.noreply.github.com>
Tue, 20 Sep 2022 22:45:26 +0000 (00:45 +0200)
commit60528c690a4c334d2a3a2c22eb97af9e67d7a91d
tree9df0150d3bca40d85c3677068fe9c610de1bc8ad
parentb95c57444a8ac3f81bc33a3d52d0f88b7a592a2f
[clangd] Return earlier when snippet is empty

Fixes github.com/clangd/clangd/issues/1216

If the Snippet string is empty, Snippet.front() would trigger a crash.
Move the Snippet->empty() check up a few lines to avoid this. Should not
break any existing behavior.

Differential Revision: https://reviews.llvm.org/D134137
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp