diff options
-rw-r--r-- | clang/include/clang/Basic/FileManager.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Lex/HeaderMap.h | 3 | ||||
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Lex/HeaderMap.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Serialization/ModuleManager.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Lex/HeaderSearchTest.cpp | 2 |
7 files changed, 10 insertions, 11 deletions
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index 58ff42ee..56c45e3 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -275,7 +275,7 @@ public: /// Open the specified file as a MemoryBuffer, returning a new /// MemoryBuffer if successful, otherwise returning null. llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> - getBufferForFile(const FileEntry *Entry, bool isVolatile = false, + getBufferForFile(FileEntryRef Entry, bool isVolatile = false, bool RequiresNullTerminator = true); llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> getBufferForFile(StringRef Filename, bool isVolatile = false, diff --git a/clang/include/clang/Lex/HeaderMap.h b/clang/include/clang/Lex/HeaderMap.h index de753cb..9d88b36 100644 --- a/clang/include/clang/Lex/HeaderMap.h +++ b/clang/include/clang/Lex/HeaderMap.h @@ -88,8 +88,7 @@ class HeaderMap : private HeaderMapImpl { public: /// This attempts to load the specified file as a header map. If it doesn't /// look like a HeaderMap, it gives up and returns null. - static std::unique_ptr<HeaderMap> Create(const FileEntry *FE, - FileManager &FM); + static std::unique_ptr<HeaderMap> Create(FileEntryRef FE, FileManager &FM); using HeaderMapImpl::dump; using HeaderMapImpl::forEachKey; diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index c3eec80..30e2916 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -536,8 +536,9 @@ void FileManager::fillRealPathName(FileEntry *UFE, llvm::StringRef FileName) { } llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> -FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile, +FileManager::getBufferForFile(FileEntryRef FE, bool isVolatile, bool RequiresNullTerminator) { + const FileEntry *Entry = &FE.getFileEntry(); // If the content is living on the file entry, return a reference to it. if (Entry->Content) return llvm::MemoryBuffer::getMemBuffer(Entry->Content->getMemBufferRef()); @@ -548,7 +549,7 @@ FileManager::getBufferForFile(const FileEntry *Entry, bool isVolatile, if (isVolatile || Entry->isNamedPipe()) FileSize = -1; - StringRef Filename = Entry->getName(); + StringRef Filename = FE.getName(); // If the file is already open, use the open file descriptor. if (Entry->File) { auto Result = Entry->File->getBuffer(Filename, FileSize, diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp index da0b889..2b26426 100644 --- a/clang/lib/Lex/HeaderMap.cpp +++ b/clang/lib/Lex/HeaderMap.cpp @@ -48,10 +48,9 @@ static inline unsigned HashHMapKey(StringRef Str) { /// map. If it doesn't look like a HeaderMap, it gives up and returns null. /// If it looks like a HeaderMap but is obviously corrupted, it puts a reason /// into the string error argument and returns null. -std::unique_ptr<HeaderMap> HeaderMap::Create(const FileEntry *FE, - FileManager &FM) { +std::unique_ptr<HeaderMap> HeaderMap::Create(FileEntryRef FE, FileManager &FM) { // If the file is too small to be a header map, ignore it. - unsigned FileSize = FE->getSize(); + unsigned FileSize = FE.getSize(); if (FileSize <= sizeof(HMapHeader)) return nullptr; auto FileBuffer = FM.getBufferForFile(FE); diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 2289edc..6842c0d 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2501,7 +2501,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) { // accept the cached file as legit. if (ValidateASTInputFilesContent && StoredContentHash != static_cast<uint64_t>(llvm::hash_code(-1))) { - auto MemBuffOrError = FileMgr.getBufferForFile(File); + auto MemBuffOrError = FileMgr.getBufferForFile(*File); if (!MemBuffOrError) { if (!Complain) return MTimeChange; diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 112d27e..de4cd3d 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -209,7 +209,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, // // RequiresNullTerminator is false because module files don't need it, and // this allows the file to still be mmapped. - Buf = FileMgr.getBufferForFile(NewModule->File, + Buf = FileMgr.getBufferForFile(*NewModule->File, /*IsVolatile=*/true, /*RequiresNullTerminator=*/false); } diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp index cc30b0a..c578fa7 100644 --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/unittests/Lex/HeaderSearchTest.cpp @@ -67,7 +67,7 @@ protected: VFS->addFile(Filename, 0, std::move(Buf), /*User=*/std::nullopt, /*Group=*/std::nullopt, llvm::sys::fs::file_type::regular_file); - auto FE = FileMgr.getFile(Filename, true); + auto FE = FileMgr.getOptionalFileRef(Filename, true); assert(FE); // Test class supports only one HMap at a time. |