[clang] [llvm] [SystemZ][z/OS] Update autoconversion functions to improve support for UTF-8 (PR #98652)

Sean Perry via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 08:03:15 PST 2024


================
@@ -166,8 +167,15 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM,
   // Unless this is a named pipe (in which case we can handle a mismatch),
   // check that the file's size is the same as in the file entry (which may
   // have come from a stat cache).
+#ifndef __MVS__
   if (!ContentsEntry->isNamedPipe() &&
       Buffer->getBufferSize() != (size_t)ContentsEntry->getSize()) {
+#else
+  // The buffer will always be larger than the file size on z/OS in the presence
+  // of characters outside the base character set.
+  if (!ContentsEntry->isNamedPipe() &&
+      Buffer->getBufferSize() < (size_t)ContentsEntry->getSize()) {
----------------
perry-ca wrote:

To remove the #if we could just replace the != with < and then add an assert:
```cpp
assert(Buffer->getBufferSize() <= (size_t)ContentsEntry->getSize());
f (!ContentsEntry->isNamedPipe() &&
      Buffer->getBufferSize() < (size_t)ContentsEntry->getSize()) {
```

https://github.com/llvm/llvm-project/pull/98652


More information about the cfe-commits mailing list