[llvm-branch-commits] [clang] release/22.x: [Clang] Fix rewrite-includes-bom.c to use POSIX-compliant regex (#176043) (PR #177675)

Cullen Rhodes via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 28 01:25:20 PST 2026


https://github.com/c-rhodes updated https://github.com/llvm/llvm-project/pull/177675

>From db9972322071ceb5206605186ab37aaf08bdf11b Mon Sep 17 00:00:00 2001
From: Alison Zhang <alisonxzhang at gmail.com>
Date: Wed, 14 Jan 2026 17:44:30 -0500
Subject: [PATCH] [Clang] Fix rewrite-includes-bom.c to use POSIX-compliant
 regex (#176043)

As `\s` is a GNU extension, it is not supported by the system grep on
AIX and thus fails in the
[buildbot](https://lab.llvm.org/buildbot/#/builders/64/builds/6835):

```
******************** TEST 'Clang :: Frontend/rewrite-includes-bom.c' FAILED ********************
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 1
cat /home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/Frontend/Inputs/rewrite-includes-bom.h | od -t x1 | grep -q 'ef\s*bb\s*bf'
# executed command: cat /home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/llvm-project/clang/test/Frontend/Inputs/rewrite-includes-bom.h
# executed command: od -t x1
# executed command: grep -q 'ef\s*bb\s*bf'
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
--
********************
```

This change replaces `\s` with the POSIX-compliant `[[:space::]]` so the
test is supported on AIX.

Co-authored-by: Alison Zhang <alisonzhang at ibm.com>
(cherry picked from commit 8ac6c4adbdf014b6d384d9a9120dc2318aab10a4)
---
 clang/test/Frontend/rewrite-includes-bom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Frontend/rewrite-includes-bom.c b/clang/test/Frontend/rewrite-includes-bom.c
index 27bf470ba1fd1..0c60ee66c8e73 100644
--- a/clang/test/Frontend/rewrite-includes-bom.c
+++ b/clang/test/Frontend/rewrite-includes-bom.c
@@ -1,6 +1,6 @@
-// RUN: cat %S/Inputs/rewrite-includes-bom.h | od -t x1 | grep -q 'ef\s*bb\s*bf'
+// RUN: cat %S/Inputs/rewrite-includes-bom.h | od -t x1 | grep -q 'ef[[:space:]]*bb[[:space:]]*bf'
 // RUN: %clang_cc1 -E -frewrite-includes -I %S/Inputs %s -o %t.c
-// RUN: cat %t.c | od -t x1 | not grep -q 'ef\s*bb\s*bf'
+// RUN: cat %t.c | od -t x1 | not grep -q 'ef[[:space:]]*bb[[:space:]]*bf'
 // RUN: %clang_cc1 -fsyntax-only -verify %t.c
 // expected-no-diagnostics
 // UNSUPPORTED: system-windows



More information about the llvm-branch-commits mailing list