Make a few changes to the FileEntryRef API in preparation for
propagating it enough to remove FileEntry::getName().
- Allow FileEntryRef to degrade to const FileEntry*. This allows functions currently returning const FileEntry * to be updated to return FileEntryRef without requiring all callers to be updated in the same patch. This helps avoid both (a) massive patches where many fields and locals are updated simultaneously and (b) noisy incremental patches where the first patch adds getFileEntry() at call sites and the second patch removes it.
- Change operator== to compare the underlying FileEntry*, ignoring any difference to the spelling of the name. There were 0 users of the existing function because it's not useful. This avoids adding noisy code where getFileEntry() is used pervasively to compare equality. In case comparing the named reference becomes important, add (and test) the API now called isSameRef.
- Allow operator== with const FileEntry * with matching semantics.
- Customize OptionalStorage<FileEntryRef> to be pointer-sized. Add a private constructor that initializes with nullptr and specialize OptionalStorage to use it.
- Add OptionalFileEntryRefDegradesToFileEntryPtr, a wrapper around Optional<FileEntryRef> that degrades to const FileEntry*, for the same reason as adding it o FileEntryRef itself. After FileEntryRef has been propagated instances of this should be replaced with Optional<FileEntryRef>.
- Remove the const from the return of FileEntryRef::getName.
- Delete the unused FileEntry::isOpenForTests.
Note that there are still FileEntry APIs that aren't wrapped and I
plan to deal with these separately / incrementally, as they are needed.
This broke the build, constexpr could be dropped IMHO.
FileEntry.h(186): error C3615: constexpr function 'llvm::optional_detail::OptionalStorage<clang::FileEntryRef,true>::hasValue' cannot result in a constant expression
FileEntry.h(187): note: failure was caused by call of undefined function or one not declared 'constexpr'
FileEntry.h(187): note: see usage of 'clang::FileEntryRef::hasOptionalValue'