[PATCH] D61438: [ASTImporter] Use llvm::Expected and Error in the importer API

Adrian Prantl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 8 09:27:43 PDT 2019


aprantl added inline comments.


================
Comment at: clang/lib/AST/ASTImporter.cpp:5039
+          if (!ToOrErr)
+            // FIXME: return the error?
+            consumeError(ToOrErr.takeError());
----------------
We don't typically commit FIXME's into LLVM code. Why not just deal with the error properly from the start?


================
Comment at: lldb/source/Symbol/ClangASTImporter.cpp:65
 
-  if (delegate_sp)
-    return delegate_sp->Import(type);
+  if (delegate_sp) {
+    if (llvm::Expected<QualType> ret_or_error = delegate_sp->Import(type)) {
----------------
```
 if (!delegate_sp)
  return {};
```


================
Comment at: lldb/source/Symbol/ClangASTImporter.cpp:68
+      return *ret_or_error;
+    } else {
+      Log *log =
----------------
The `else` is redundant.


================
Comment at: lldb/source/Symbol/ClangASTImporter.cpp:139
+
+      llvm::consumeError(result.takeError());
+
----------------
Can you convert this to an early return instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61438





More information about the cfe-commits mailing list