[clang] [z.OS] fix strnlen() usage in Context.cpp available on z/OS (PR #160339)

Zibi Sarbinowski via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 23 09:22:29 PDT 2025


https://github.com/zibi2 created https://github.com/llvm/llvm-project/pull/160339

On z/OS `strnlen()` is not available by default so we use the wrapper header `zOSSupport.h` to make it visible. This will fix the following error:

```
clang/lib/AST/ByteCode/Context.cpp:250:16: error: use of undeclared identifier 'strnlen'
  250 |       Result = strnlen(reinterpret_cast<const char *>(Ptr.getRawAddress()), N);
      |                ^~~~~~~
1 error generated.
```

>From 6cb631724d30e5f47edc9337f09b7ec02ee4a378 Mon Sep 17 00:00:00 2001
From: Zibi Sarbinowski <zibi at ca.ibm.com>
Date: Tue, 23 Sep 2025 16:23:37 +0000
Subject: [PATCH] fix strnlen() usage in Context.cpp available on z/OS

---
 clang/lib/AST/ByteCode/Context.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp
index 8860bcc54a9c1..71d0bcf61a5ff 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/Expr.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/Support/SystemZ/zOSSupport.h"
 
 using namespace clang;
 using namespace clang::interp;



More information about the cfe-commits mailing list