[ExpressionParser] Handle llvm::Expected result

This fixes the unchecked-error assertion at runtime.

  Expected<T> must be checked before access or destruction. Expected<T>
  value was in success state. (Note: Expected<T> values in success mode
  must still be checked prior to being destroyed).

llvm-svn: 366853
This commit is contained in:
Jonas Devlieghere 2019-07-23 21:14:41 +00:00
parent 50a3f0e08e
commit b362c976fb
1 changed files with 10 additions and 2 deletions

View File

@ -204,7 +204,11 @@ private:
llvm::DenseSet<clang::Decl *> m_completed;
bool ImportAndCheckCompletable(clang::Decl *decl) {
(void)m_exporter.Import(decl);
llvm::Expected<clang::Decl *> imported_decl = m_exporter.Import(decl);
if (!imported_decl) {
llvm::consumeError(imported_decl.takeError());
return false;
}
if (m_completed.count(decl))
return false;
if (!llvm::isa<DeclContext>(decl))
@ -225,7 +229,11 @@ private:
void Complete(clang::Decl *decl) {
m_completed.insert(decl);
auto *decl_context = llvm::cast<DeclContext>(decl);
(void)m_exporter.Import(decl);
llvm::Expected<clang::Decl *> imported_decl = m_exporter.Import(decl);
if (!imported_decl) {
llvm::consumeError(imported_decl.takeError());
return;
}
m_exporter.CompleteDecl(decl);
for (Decl *child : decl_context->decls())
if (ImportAndCheckCompletable(child))