diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 12 | ||||
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 14 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp | 5 |
4 files changed, 23 insertions, 11 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 6097b85..27075ce 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -530,7 +530,7 @@ void FileManager::fillRealPathName(FileEntry *UFE, llvm::StringRef FileName) { llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileManager::getBufferForFile(FileEntryRef FE, bool isVolatile, - bool RequiresNullTerminator, + bool RequiresNullTerminator, bool IsText, std::optional<int64_t> MaybeLimit) { const FileEntry *Entry = &FE.getFileEntry(); // If the content is living on the file entry, return a reference to it. @@ -558,21 +558,21 @@ FileManager::getBufferForFile(FileEntryRef FE, bool isVolatile, // Otherwise, open the file. return getBufferForFileImpl(Filename, FileSize, isVolatile, - RequiresNullTerminator); + RequiresNullTerminator, IsText); } llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileManager::getBufferForFileImpl(StringRef Filename, int64_t FileSize, - bool isVolatile, - bool RequiresNullTerminator) const { + bool isVolatile, bool RequiresNullTerminator, + bool IsText) const { if (FileSystemOpts.WorkingDir.empty()) return FS->getBufferForFile(Filename, FileSize, RequiresNullTerminator, - isVolatile); + isVolatile, IsText); SmallString<128> FilePath(Filename); FixupRelativePath(FilePath); return FS->getBufferForFile(FilePath, FileSize, RequiresNullTerminator, - isVolatile); + isVolatile, IsText); } /// getStatValue - Get the 'stat' information for the specified path, diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 65a8a72..fe3aff7 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -121,8 +121,18 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, // Start with the assumption that the buffer is invalid to simplify early // return paths. IsBufferInvalid = true; - - auto BufferOrError = FM.getBufferForFile(*ContentsEntry, IsFileVolatile); + bool IsText = false; + +#ifdef __MVS__ + // If the file is tagged with a text ccsid, it may require autoconversion. + llvm::ErrorOr<bool> IsFileText = + llvm::iszOSTextFile(ContentsEntry->getName().data()); + if (IsFileText) + IsText = *IsFileText; +#endif + + auto BufferOrError = FM.getBufferForFile( + *ContentsEntry, IsFileVolatile, /*RequiresNullTerminator=*/true, IsText); // If we were unable to open the file, then we are in an inconsistent // situation where the content cache referenced a file which no longer diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 7efcc81..ad0551e 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -5317,7 +5317,8 @@ std::string ASTReader::getOriginalSourceFile( const PCHContainerReader &PCHContainerRdr, DiagnosticsEngine &Diags) { // Open the AST file. auto Buffer = FileMgr.getBufferForFile(ASTFileName, /*IsVolatile=*/false, - /*RequiresNullTerminator=*/false); + /*RequiresNullTerminator=*/false, + /*IsText=*/true); if (!Buffer) { Diags.Report(diag::err_fe_unable_to_read_pch_file) << ASTFileName << Buffer.getError().message(); diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp index 4d738e4..7d6239a 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp @@ -353,12 +353,13 @@ DepScanFile::create(EntryRef Entry) { } llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> -DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path) { +DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path, + bool IsText) { SmallString<256> OwnedFilename; StringRef Filename = Path.toStringRef(OwnedFilename); if (shouldBypass(Filename)) - return getUnderlyingFS().openFileForRead(Path); + return getUnderlyingFS().openFileForRead(Path, IsText); llvm::ErrorOr<EntryRef> Result = getOrCreateFileSystemEntry(Filename); if (!Result) |