[clangd] Handle errors before checking for cancelltion
authorIlya Biryukov <ibiryukov@google.com>
Mon, 3 Sep 2018 14:39:34 +0000 (14:39 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Mon, 3 Sep 2018 14:39:34 +0000 (14:39 +0000)
To avoid hitting assertions in llvm::Expected destructor.

llvm-svn: 341319

clang-tools-extra/clangd/ClangdServer.cpp

index 6bdd082..7f0b29d 100644 (file)
@@ -191,11 +191,10 @@ TaskHandle ClangdServer::codeComplete(PathRef File, Position Pos,
   auto Task = [PCHs, Pos, FS, CodeCompleteOpts,
                this](Path File, Callback<CodeCompleteResult> CB,
                      llvm::Expected<InputsAndPreamble> IP) {
-    if (isCancelled())
-      return CB(llvm::make_error<CancelledError>());
-
     if (!IP)
       return CB(IP.takeError());
+    if (isCancelled())
+      return CB(llvm::make_error<CancelledError>());
 
     auto PreambleData = IP->Preamble;