Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC][llvm][support] rename INFINITY in regcomp #101758

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

daltenty
Copy link
Member

@daltenty daltenty commented Aug 2, 2024

since C23 this macro is defined by float.h, which clang implements in it's float.h since #96659 landed.

However, regcomp.c in LLVMSupport happened to define it's own macro with that name, leading to problems when bootstrapping. This change renames the offending macro.

since C23 this macro is defined by float.h, which clang implements in it's float.h since llvm#96659 landed.

However, regcomp.c in LLVMSupport happened to define it's own macro with that name, leading to problems when bootstrapping. This change renames the offending macro.
@llvmbot
Copy link
Member

llvmbot commented Aug 2, 2024

@llvm/pr-subscribers-llvm-support

Author: David Tenty (daltenty)

Changes

since C23 this macro is defined by float.h, which clang implements in it's float.h since #96659 landed.

However, regcomp.c in LLVMSupport happened to define it's own macro with that name, leading to problems when bootstrapping. This change renames the offending macro.


Full diff: https://github.com/llvm/llvm-project/pull/101758.diff

1 Files Affected:

  • (modified) llvm/lib/Support/regcomp.c (+4-4)
diff --git a/llvm/lib/Support/regcomp.c b/llvm/lib/Support/regcomp.c
index 990aef32a396f..daa41eb4912ef 100644
--- a/llvm/lib/Support/regcomp.c
+++ b/llvm/lib/Support/regcomp.c
@@ -278,7 +278,7 @@ static char nuls[10];		/* place to point scanner in event of error */
 #else
 #define	DUPMAX	255
 #endif
-#define	INFINITY	(DUPMAX + 1)
+#define REGINFINITY (DUPMAX + 1)
 
 #ifndef NDEBUG
 static int never = 0;		/* for use in asserts; shuts lint up */
@@ -582,7 +582,7 @@ p_ere_exp(struct parse *p)
 				count2 = p_count(p);
 				REQUIRE(count <= count2, REG_BADBR);
 			} else		/* single number with comma */
-				count2 = INFINITY;
+				count2 = REGINFINITY;
 		} else		/* just a single number */
 			count2 = count;
 		repeat(p, pos, count, count2);
@@ -753,7 +753,7 @@ p_simp_re(struct parse *p,
 				count2 = p_count(p);
 				REQUIRE(count <= count2, REG_BADBR);
 			} else		/* single number with comma */
-				count2 = INFINITY;
+				count2 = REGINFINITY;
 		} else		/* just a single number */
 			count2 = count;
 		repeat(p, pos, count, count2);
@@ -1115,7 +1115,7 @@ repeat(struct parse *p,
 #	define	N	2
 #	define	INF	3
 #	define	REP(f, t)	((f)*8 + (t))
-#	define	MAP(n)	(((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)
+#	define	MAP(n)	(((n) <= 1) ? (n) : ((n) == REGINFINITY) ? INF : N)
 	sopno copy;
 
 	if (p->error != 0)	/* head off possible runaway recursion */

Copy link

github-actions bot commented Aug 2, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 12e3a06cb7615fbd91031420f3dec2a85d7877d6 4c53951a5048eaebf764b39549d22da6e1f4082a --extensions c -- llvm/lib/Support/regcomp.c
View the diff from clang-format here.
diff --git a/llvm/lib/Support/regcomp.c b/llvm/lib/Support/regcomp.c
index 9a30425c47..e6cc03fea3 100644
--- a/llvm/lib/Support/regcomp.c
+++ b/llvm/lib/Support/regcomp.c
@@ -583,8 +583,8 @@ p_ere_exp(struct parse *p)
 				REQUIRE(count <= count2, REG_BADBR);
 			} else		/* single number with comma */
                           count2 = REGINFINITY;
-                } else		/* just a single number */
-			count2 = count;
+                } else /* just a single number */
+                  count2 = count;
 		repeat(p, pos, count, count2);
 		if (!EAT('}')) {	/* error heuristics */
 			while (MORE() && PEEK() != '}')
@@ -754,8 +754,8 @@ p_simp_re(struct parse *p,
 				REQUIRE(count <= count2, REG_BADBR);
 			} else		/* single number with comma */
                           count2 = REGINFINITY;
-                } else		/* just a single number */
-			count2 = count;
+                } else /* just a single number */
+                  count2 = count;
 		repeat(p, pos, count, count2);
 		if (!EATTWO('\\', '}')) {	/* error heuristics */
 			while (MORE() && !SEETWO('\\', '}'))
@@ -1118,7 +1118,7 @@ repeat(struct parse *p,
 #define MAP(n) (((n) <= 1) ? (n) : ((n) == REGINFINITY) ? INF : N)
         sopno copy;
 
-	if (p->error != 0)	/* head off possible runaway recursion */
+        if (p->error != 0)	/* head off possible runaway recursion */
 		return;
 
 	assert(from <= to);

Copy link
Contributor

@xingxue-ibm xingxue-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@daltenty
Copy link
Member Author

daltenty commented Aug 8, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

This file is from an external source and doesn't follow the clang-format rules, so after some discussion I'm going to ignore this.

@daltenty daltenty merged commit 899f648 into llvm:main Aug 8, 2024
4 of 6 checks passed
@daltenty daltenty deleted the daltenty/regex-infinity branch August 8, 2024 15:16
@daltenty
Copy link
Member Author

daltenty commented Aug 8, 2024

The original #96659 is in release/19.x so this is presumable an issue there as well.

/cherry-pick 899f648

@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

The original #96659 is in release/19.x so this is presumable an issue there as well.

/cherry-pick 899f648

Error: Command failed due to missing milestone.

@AaronBallman AaronBallman added this to the LLVM 19.X Release milestone Aug 8, 2024
@AaronBallman
Copy link
Collaborator

/cherry-pick 899f648

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 8, 2024
since C23 this macro is defined by float.h, which clang implements in
it's float.h since llvm#96659 landed.

However, regcomp.c in LLVMSupport happened to define it's own macro with
that name, leading to problems when bootstrapping. This change renames
the offending macro.

(cherry picked from commit 899f648)
@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

/pull-request #102492

tru pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 10, 2024
since C23 this macro is defined by float.h, which clang implements in
it's float.h since llvm#96659 landed.

However, regcomp.c in LLVMSupport happened to define it's own macro with
that name, leading to problems when bootstrapping. This change renames
the offending macro.

(cherry picked from commit 899f648)
kstoimenov pushed a commit to kstoimenov/llvm-project that referenced this pull request Aug 15, 2024
since C23 this macro is defined by float.h, which clang implements in
it's float.h since llvm#96659 landed.

However, regcomp.c in LLVMSupport happened to define it's own macro with
that name, leading to problems when bootstrapping. This change renames
the offending macro.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants