This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d67b9e2461d: SourceManager: Migrate to FileEntryRef in
getOrCreateContentCache, NFC (authored by dexonsmith).
Changed prior to commit:
https://reviews.llvm.org/D92983?vs=310717&id=319171#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92983/new/
https://reviews.llvm.org/D92983
Files:
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp
clang/lib/Serialization/ASTReader.cpp
Index: clang/lib/Serialization/ASTReader.cpp
===================================================================
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1499,7 +1499,7 @@
// we will also try to fail gracefully by setting up the SLocEntry.
unsigned InputID = Record[4];
InputFile IF = getInputFile(*F, InputID);
- const FileEntry *File = IF.getFile();
+ Optional<FileEntryRef> File = IF.getFile();
bool OverriddenBuffer = IF.isOverridden();
// Note that we only check if a File was returned. If it was out-of-date
@@ -1515,9 +1515,8 @@
}
SrcMgr::CharacteristicKind
FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
- // FIXME: The FileID should be created from the FileEntryRef.
- FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter,
- ID, BaseOffset + Record[0]);
+ FileID FID = SourceMgr.createFileID(*File, IncludeLoc, FileCharacter, ID,
+ BaseOffset + Record[0]);
SrcMgr::FileInfo &FileInfo =
const_cast<SrcMgr::FileInfo&>(SourceMgr.getSLocEntry(FID).getFile());
FileInfo.NumCreatedFIDs = Record[5];
@@ -1533,14 +1532,14 @@
}
const SrcMgr::ContentCache &ContentCache =
- SourceMgr.getOrCreateContentCache(File, isSystem(FileCharacter));
+ SourceMgr.getOrCreateContentCache(*File, isSystem(FileCharacter));
if (OverriddenBuffer && !ContentCache.BufferOverridden &&
ContentCache.ContentsEntry == ContentCache.OrigEntry &&
!ContentCache.getBufferIfLoaded()) {
auto Buffer = ReadBuffer(SLocEntryCursor, File->getName());
if (!Buffer)
return true;
- SourceMgr.overrideFileContents(File, std::move(Buffer));
+ SourceMgr.overrideFileContents(*File, std::move(Buffer));
}
break;
Index: clang/lib/Basic/SourceManager.cpp
===================================================================
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -385,10 +385,8 @@
}
}
-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 @@
Entry->IsFileVolatile = UserFilesAreVolatile && !isSystemFile;
Entry->IsTransient = FilesAreTransient;
- Entry->BufferOverridden |= FileEnt->isNamedPipe();
+ Entry->BufferOverridden |= FileEnt.isNamedPipe();
return *Entry;
}
@@ -542,7 +540,7 @@
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 @@
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 @@
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>
Index: clang/include/clang/Basic/SourceManager.h
===================================================================
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -1838,7 +1838,7 @@
SrcMgr::CharacteristicKind DirCharacter, int LoadedID,
unsigned LoadedOffset);
- SrcMgr::ContentCache &getOrCreateContentCache(const FileEntry *SourceFile,
+ SrcMgr::ContentCache &getOrCreateContentCache(FileEntryRef SourceFile,
bool isSystemFile = false);
/// Create a new ContentCache for the specified memory buffer.
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits