diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-10-21 23:38:12 -0400 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-11-30 14:04:48 -0800 |
commit | ac40a2d8f16b8a8c68fc811d67f647740e965cb8 (patch) | |
tree | a1abc18b93bd7bf85a608ead3e4677bb2bd5744e /clang/lib/Basic/SourceManager.cpp | |
parent | 9615890db576721fbd73ae77d81d39435e83b4b4 (diff) | |
download | llvm-ac40a2d8f16b8a8c68fc811d67f647740e965cb8.zip llvm-ac40a2d8f16b8a8c68fc811d67f647740e965cb8.tar.gz llvm-ac40a2d8f16b8a8c68fc811d67f647740e965cb8.tar.bz2 |
Serialization: Change InputFile to use FileEntryRef and add getVirtualFileRef, NFC
Change the `InputFile` class to store `Optional<FileEntryRef>` instead
of `FileEntry*`. This paged in a few API changes:
- Added `FileManager::getVirtualFileRef`, and converted `getVirtualFile`
to a wrapper of it.
- Updated `SourceManager::bypassFileContentsOverride` to take
`FileEntryRef` and return `Optional<FileEntryRef>`
(`ASTReader::getInputFile` is the only caller).
Differential Revision: https://reviews.llvm.org/D90053
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index dde4471..b71b2be 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -698,19 +698,17 @@ void SourceManager::overrideFileContents(const FileEntry *SourceFile, getOverriddenFilesInfo().OverriddenFiles[SourceFile] = NewFile; } -const FileEntry * -SourceManager::bypassFileContentsOverride(const FileEntry &File) { - assert(isFileOverridden(&File)); - llvm::Optional<FileEntryRef> BypassFile = - FileMgr.getBypassFile(File.getLastRef()); +Optional<FileEntryRef> +SourceManager::bypassFileContentsOverride(FileEntryRef File) { + assert(isFileOverridden(&File.getFileEntry())); + llvm::Optional<FileEntryRef> BypassFile = FileMgr.getBypassFile(File); // If the file can't be found in the FS, give up. if (!BypassFile) - return nullptr; + return None; - const FileEntry *FE = &BypassFile->getFileEntry(); - (void)getOrCreateContentCache(FE); - return FE; + (void)getOrCreateContentCache(&BypassFile->getFileEntry()); + return BypassFile; } void SourceManager::setFileIsTransient(const FileEntry *File) { |