aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorAbhina Sree <Abhina.Sreeskantharajan@ibm.com>2024-09-19 14:30:10 -0400
committerGitHub <noreply@github.com>2024-09-19 14:30:10 -0400
commitedf3b277a5f2ebe144827ed47463c22743cac5f9 (patch)
tree99185acc509e869ab34528456e026b06f6594f6b /clang/lib/Basic/SourceManager.cpp
parentf3f3883f4b9d15770a5ce49956ed4425c71ad69f (diff)
downloadllvm-edf3b277a5f2ebe144827ed47463c22743cac5f9.zip
llvm-edf3b277a5f2ebe144827ed47463c22743cac5f9.tar.gz
llvm-edf3b277a5f2ebe144827ed47463c22743cac5f9.tar.bz2
[SystemZ][z/OS] Propagate IsText parameter to open text files as text (#107906)
This patch adds an IsText parameter to the following functions openFileForRead, getBufferForFile, getBufferForFileImpl and determines whether a file is text by querying the file tag on z/OS. The default is set to OF_Text instead of OF_None, this change in value does not affect any other platforms other than z/OS.
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp14
1 files changed, 12 insertions, 2 deletions
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