================ @@ -617,6 +625,23 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, StringRef Filename, return FileID::get(LoadedID); } unsigned FileSize = File.getSize(); +#ifdef __MVS__ + llvm::ErrorOr<bool> NeedConversion = + llvm::needzOSConversion(Filename.str().c_str()); + if (NeedConversion && *NeedConversion) { + // Buffer size may increase due to potential z/OS EBCDIC to UTF-8 + // conversion. + if (std::optional<llvm::MemoryBufferRef> Buffer = + File.getBufferOrNone(Diag, getFileManager())) { + unsigned BufSize = Buffer->getBufferSize(); + if (BufSize > FileSize) { + if (File.ContentsEntry.has_value()) + File.ContentsEntry->getFileEntry().setSize(BufSize); + FileSize = BufSize; + } + } + } +#endif ---------------- zibi2 wrote:
Could you experiment with creating for z/OS a derived class from SourceManager so we can have this code bundle with member function which for base class will be empty and we will just call this new member function here? This will minimized a lot of conditional directives. https://github.com/llvm/llvm-project/pull/98652 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits