[clang] 1c46118 - Load AST files as binary on z/OS (#191840)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 14 11:46:49 PDT 2026
Author: Sean Perry
Date: 2026-04-14T14:46:44-04:00
New Revision: 1c46118228527a406362952cade120f380190ef9
URL: https://github.com/llvm/llvm-project/commit/1c46118228527a406362952cade120f380190ef9
DIFF: https://github.com/llvm/llvm-project/commit/1c46118228527a406362952cade120f380190ef9.diff
LOG: Load AST files as binary on z/OS (#191840)
The ast files need to be loaded as binary on z/OS to avoid translation.
Add the `IsText=false` option to all of the relevant file open calls.
Added:
Modified:
clang/include/clang/Basic/FileManager.h
clang/lib/Basic/Module.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ModuleManager.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index 01ce243e1b5fc..e440a57e3a866 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -207,9 +207,10 @@ class FileManager : public RefCountedBase<FileManager> {
/// Get a FileEntryRef if it exists, without doing anything on error.
OptionalFileEntryRef getOptionalFileRef(StringRef Filename,
bool OpenFile = false,
- bool CacheFailure = true) {
+ bool CacheFailure = true,
+ bool IsText = true) {
return llvm::expectedToOptional(
- getFileRef(Filename, OpenFile, CacheFailure));
+ getFileRef(Filename, OpenFile, CacheFailure, IsText));
}
/// Returns the current file system options
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 81e28e46d36ca..869d0a5b0c3cf 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -45,7 +45,8 @@ ModuleFileName::makeKey(FileManager &FileMgr) const {
return ModuleFileKey(*ModuleCache, ImplicitModuleSuffix);
} else {
if (auto ModuleFile = FileMgr.getOptionalFileRef(Path, /*OpenFile=*/true,
- /*CacheFailure=*/false))
+ /*CacheFailure=*/false,
+ /*IsText=*/false))
return ModuleFileKey(*ModuleFile);
}
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 049dc227821cf..75b1b9e180703 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5948,13 +5948,21 @@ bool ASTReader::readASTFileControlBlock(
// FIXME: This allows use of the VFS; we do not allow use of the
// VFS when actually loading a module.
- auto Entry =
- Filename == "-" ? FileMgr.getSTDIN() : FileMgr.getFileRef(Filename);
+ auto Entry = Filename == "-" ? FileMgr.getSTDIN()
+ : FileMgr.getFileRef(Filename,
+ /*OpenFile=*/false,
+ /*CacheFailure=*/true,
+ /*IsText=*/false);
if (!Entry) {
llvm::consumeError(Entry.takeError());
return true;
}
- auto BufferOrErr = FileMgr.getBufferForFile(*Entry);
+ auto BufferOrErr =
+ FileMgr.getBufferForFile(*Entry,
+ /*IsVolatile=*/false,
+ /*RequiresNullTerminator=*/false,
+ /*MaybeLimit=*/std::nullopt,
+ /*IsText=*/false);
if (!BufferOrErr)
return true;
OwnedBuffer = std::move(*BufferOrErr);
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index 0aa3adc9d8cfc..03939a9ce061a 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -61,7 +61,8 @@ ModuleFile *ModuleManager::lookup(ModuleFileKey Key) const {
std::unique_ptr<llvm::MemoryBuffer>
ModuleManager::lookupBuffer(StringRef Name) {
auto Entry = FileMgr.getOptionalFileRef(Name, /*OpenFile=*/false,
- /*CacheFailure=*/false);
+ /*CacheFailure=*/false,
+ /*IsText=*/false);
if (!Entry)
return nullptr;
return std::move(InMemoryBuffers[*Entry]);
@@ -183,7 +184,8 @@ AddModuleResult ModuleManager::addModule(
// should store this directly in the in-memory module cache.
OptionalFileEntryRef Entry =
FileMgr.getOptionalFileRef(FileName, /*OpenFile=*/true,
- /*CacheFailure=*/false);
+ /*CacheFailure=*/false,
+ /*IsText=*/false);
if (!Entry) {
Result.K = AddModuleResult::Missing;
return Result;
@@ -212,7 +214,8 @@ AddModuleResult ModuleManager::addModule(
FileName == StringRef("-")
? FileMgr.getSTDIN()
: FileMgr.getFileRef(FileName, /*OpenFile=*/true,
- /*CacheFailure=*/false);
+ /*CacheFailure=*/false,
+ /*IsText=*/false);
if (!Entry)
return Entry.takeError();
@@ -223,7 +226,9 @@ AddModuleResult ModuleManager::addModule(
// this allows the file to still be mmapped.
return llvm::errorOrToExpected(
FileMgr.getBufferForFile(*Entry, /*IsVolatile=*/false,
- /*RequiresNullTerminator=*/false));
+ /*RequiresNullTerminator=*/false,
+ /*MaybeLimit=*/std::nullopt,
+ /*IsText=*/false));
}();
if (!Buf) {
More information about the cfe-commits
mailing list