Skip to content

Commit 7597e09

Browse files
authored
[clang] Increase the default expression nesting limit (#104717)
Increase the default expression nesting limit from 256 to 1024 Fixes: #94728 Compile time with different Bracket depth Clang version 20.0.0git (https://github.com/AmrDeveloper/llvm-project.git 673b9e0) Target: arm64-apple-darwin23.5.0 Bracket depth = 256, time = 0.243 Bracket depth = 512, time = 0.329 Bracket depth = 1024, time = 0.489 Bracket depth = 2048, time = 0.851
1 parent 3b80a28 commit 7597e09

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ Deprecated Compiler Flags
174174
Modified Compiler Flags
175175
-----------------------
176176

177+
- The compiler flag `-fbracket-depth` default value is increased from 256 to 2048.
178+
177179
Removed Compiler Flags
178180
-------------------------
179181

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7959,7 +7959,7 @@ def fapply_global_visibility_to_externs : Flag<["-"], "fapply-global-visibility-
79597959
MarshallingInfoFlag<LangOpts<"SetVisibilityForExternDecls">>;
79607960
def fbracket_depth : Separate<["-"], "fbracket-depth">,
79617961
HelpText<"Maximum nesting level for parentheses, brackets, and braces">,
7962-
MarshallingInfoInt<LangOpts<"BracketDepth">, "256">;
7962+
MarshallingInfoInt<LangOpts<"BracketDepth">, "2048">;
79637963
defm const_strings : BoolOption<"f", "const-strings",
79647964
LangOpts<"ConstStrings">, DefaultFalse,
79657965
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Use">,

clang/test/Parser/parser_overflow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: not %clang_cc1 %s -fsyntax-only -DHUGE 2>&1 | FileCheck %s
2-
// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
2+
// RUN: %clang_cc1 %s -fsyntax-only
33
// RUN: not %clang_cc1 %s -fsyntax-only -fbracket-depth 299 2>&1 | FileCheck %s
44
// RUN: %clang_cc1 %s -fsyntax-only -fbracket-depth 300
55
// RUN: not %clang %s -fsyntax-only -fbracket-depth=299 2>&1 | FileCheck %s
@@ -15,5 +15,5 @@ void foo(void) {
1515
#endif
1616
}
1717

18-
// CHECK: fatal error: bracket nesting level exceeded maximum of {{256|299}}
18+
// CHECK: fatal error: bracket nesting level exceeded maximum of {{2048|299}}
1919
// CHECK: note: use -fbracket-depth=N to increase maximum nesting level

0 commit comments

Comments
 (0)