[PATCH] D89834: FileManager: Improve the FileEntryRef API and customize Optional<FileEntryRef>

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 28 11:18:23 PDT 2020


dexonsmith added a comment.

In D89834#2357910 <https://reviews.llvm.org/D89834#2357910>, @dexonsmith wrote:

> Dropped `MaybeFileEntryRef`, instead customizing `Optional<FileEntryRef>`.

As @arphaman pointed out offline, we can actually `OptionalStorage` instead, by adding add a private constructor to `FileEntryRef` that `nullptr`-initializes and only `OptionalStorage` calls.

The reason I think customizing `Optional` is better is the ability to add `operator const FileEntry *`. This avoids having to update large swaths of code like this in an incremental patch:

  // old code
  lvalue = rvalue;
  // new code
  auto F = rvalue;
  lvalue = F ? &F->getFileEntry() : nullptr;

just to revert it back in a later incremental patch once `FileEntryRef` has made it further.

This was one the primary reasons I originally added `MaybeFileEntryRef`.


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

https://reviews.llvm.org/D89834



More information about the cfe-commits mailing list