This is a small step to simplify ASTImporter internals and make them more robust. As it was discussed in the mailing lists, the following changes are included:
- Introduced helper methods importNonNull() and importNullable() with LLVM_NODISCARD attribute. These methods are used to avoid redundant casting and to simplify checks for import return result. LLVM_NODISCARD will also print a warning every time a return result of import is unchecked.
- The return result of Import*Decl() methods is changed to Optional<Decl *>. The value of nullptr doesn't signal an error anymore (as it should be); None object are used instead in case of import failure. I hope that the need for dereferencing the result will remind about the need to check it first.
- ASTimporter and its clients are changed to use the new API. The patch for LLDB is coming soon. Some unchecked imports were found and fixed.
Unfortunately, the patch became very big. However, most changes are same. The code became a bit smaller and, as it looks to me, a bit more readable.