diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-12-09 16:42:33 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-25 17:03:12 -0800 |
commit | 8d67b9e2461d654c0a3657e511e2295006f23748 (patch) | |
tree | 5f350cbdd42e1af98d76358df4911858cfc09e66 /clang/lib/Basic/SourceManager.cpp | |
parent | 46b1645e6c4fe5020ae08e4d94b3de0c80117b4b (diff) | |
download | llvm-8d67b9e2461d654c0a3657e511e2295006f23748.zip llvm-8d67b9e2461d654c0a3657e511e2295006f23748.tar.gz llvm-8d67b9e2461d654c0a3657e511e2295006f23748.tar.bz2 |
SourceManager: Migrate to FileEntryRef in getOrCreateContentCache, NFC
Change `SourceManager::getOrCreateContentCache` to take a `FileEntryRef`
and update call sites (mostly internal to SourceManager.cpp). In a
couple of cases this temporarily relies on `FileEntry::getLastRef`, but
those can be cleaned up once other APIs switch over.
The one change outside of SourceManager.cpp is in ASTReader.cpp, which
stops relying on the auto-degrade-to-`FileEntry*` behaviour from
`InputFile::getFile` since it now needs a `FileEntryRef`.
No functionality change here.
Differential Revision: https://reviews.llvm.org/D92983
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 10142ea..c0b2283 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -385,10 +385,8 @@ void SourceManager::initializeForReplay(const SourceManager &Old) { } } -ContentCache &SourceManager::getOrCreateContentCache(const FileEntry *FileEnt, +ContentCache &SourceManager::getOrCreateContentCache(FileEntryRef FileEnt, bool isSystemFile) { - assert(FileEnt && "Didn't specify a file entry to use?"); - // Do we already have information about this file? ContentCache *&Entry = FileInfos[FileEnt]; if (Entry) @@ -414,7 +412,7 @@ ContentCache &SourceManager::getOrCreateContentCache(const FileEntry *FileEnt, Entry->IsFileVolatile = UserFilesAreVolatile && !isSystemFile; Entry->IsTransient = FilesAreTransient; - Entry->BufferOverridden |= FileEnt->isNamedPipe(); + Entry->BufferOverridden |= FileEnt.isNamedPipe(); return *Entry; } @@ -542,7 +540,7 @@ FileID SourceManager::createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID, unsigned LoadedOffset) { - SrcMgr::ContentCache &IR = getOrCreateContentCache(&SourceFile.getFileEntry(), + SrcMgr::ContentCache &IR = getOrCreateContentCache(SourceFile, isSystem(FileCharacter)); // If this is a named pipe, immediately load the buffer to ensure subsequent @@ -682,13 +680,13 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info, llvm::Optional<llvm::MemoryBufferRef> SourceManager::getMemoryBufferForFileOrNone(const FileEntry *File) { - SrcMgr::ContentCache &IR = getOrCreateContentCache(File); + SrcMgr::ContentCache &IR = getOrCreateContentCache(File->getLastRef()); return IR.getBufferOrNone(Diag, getFileManager(), SourceLocation()); } void SourceManager::overrideFileContents( const FileEntry *SourceFile, std::unique_ptr<llvm::MemoryBuffer> Buffer) { - SrcMgr::ContentCache &IR = getOrCreateContentCache(SourceFile); + SrcMgr::ContentCache &IR = getOrCreateContentCache(SourceFile->getLastRef()); IR.setBuffer(std::move(Buffer)); IR.BufferOverridden = true; @@ -716,12 +714,12 @@ SourceManager::bypassFileContentsOverride(FileEntryRef File) { if (!BypassFile) return None; - (void)getOrCreateContentCache(&BypassFile->getFileEntry()); + (void)getOrCreateContentCache(*BypassFile); return BypassFile; } void SourceManager::setFileIsTransient(const FileEntry *File) { - getOrCreateContentCache(File).IsTransient = true; + getOrCreateContentCache(File->getLastRef()).IsTransient = true; } Optional<StringRef> |