Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NFC] Cleanup the overload of ASTImporter::import()
This patch aims to address the comment of a previous review: https://reviews.llvm.org/D109237#inline-1040678 The original problem was the following: `T` is substituted by `clang::Type` Expected<T *> import(T *From) { auto ToOrErr = Importer.Import(From); // ^^^^^^^^^^^^^^^^^^^^^ if (!ToOrErr) return ToOrErr.takeError(); return cast_or_null<T>(*ToOrErr); // ^^^^^^^^^^^^^^^^^^^^^^^^^ } `Importer.Import()` operates on `const Type *`, thus returns `const Type *`. Later, at the return statement, we will try to construct an `Expected<Type*>` from a `const Type *`, which failed with a miserable error message. In all other cases `importer.Import()` results in a non-const version, so everything works out just fine, but for `clang::type`s, we should really return a const version. So, in case of `T` is a subclass of `clang::Type`, it will return a `Exprected<const T*>` instead. Reviewed By: martong Differential Revision: https://reviews.llvm.org/D109269
- Loading branch information
Balazs Benics
committed
Sep 30, 2021
1 parent
230a6ed
commit e5e0e00
Showing
1 changed file
with
24 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters