Skip to content

[clang] Document -fstrict-flex-arrays option #138388

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

Merged
merged 1 commit into from
May 4, 2025

Conversation

serge-sans-paille
Copy link
Collaborator

Fix #138185

@llvmbot llvmbot added the clang Clang issues not falling into any other category label May 3, 2025
@llvmbot
Copy link
Member

llvmbot commented May 3, 2025

@llvm/pr-subscribers-clang

Author: None (serge-sans-paille)

Changes

Fix #138185


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

1 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+4-1)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 2946ffaa28da0..5ceba7e3bf4c7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1554,7 +1554,10 @@ def fstrict_flex_arrays_EQ : Joined<["-"], "fstrict-flex-arrays=">, Group<f_Grou
   Visibility<[ClangOption, CC1Option]>,
   NormalizedValuesScope<"LangOptions::StrictFlexArraysLevelKind">,
   NormalizedValues<["Default", "OneZeroOrIncomplete", "ZeroOrIncomplete", "IncompleteOnly"]>,
-  HelpText<"Enable optimizations based on the strict definition of flexible arrays">,
+  HelpText<"Enable optimizations based on the strict definition of flexible arrays. "
+    "If ``<n>`` is equal to 0, any trailing array member is considered a flexible array. "
+    "If ``<n>`` is equal to 1, trailing array members of size 0, 1 and undefined are considered flexible arrays. "
+    "If ``<n>`` is equal to 3, only trailing array members of undefined size are considered flexible arrays.">,
   MarshallingInfoEnum<LangOpts<"StrictFlexArraysLevel">, "Default">;
 defm apple_pragma_pack : BoolFOption<"apple-pragma-pack",
   LangOpts<"ApplePragmaPack">, DefaultFalse,

@serge-sans-paille
Copy link
Collaborator Author

@zygoloid this restores (and hopefully improves) the original documentation. The values and behavior are obviously the same as gcc. I don't have a strong opinion on value aliases.

@@ -1554,7 +1554,10 @@ def fstrict_flex_arrays_EQ : Joined<["-"], "fstrict-flex-arrays=">, Group<f_Grou
Visibility<[ClangOption, CC1Option]>,
NormalizedValuesScope<"LangOptions::StrictFlexArraysLevelKind">,
NormalizedValues<["Default", "OneZeroOrIncomplete", "ZeroOrIncomplete", "IncompleteOnly"]>,
HelpText<"Enable optimizations based on the strict definition of flexible arrays">,
HelpText<"Enable optimizations based on the strict definition of flexible arrays. "
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is much too long to include in the --help output. Maybe this could be specified as DocBrief instead soon it goes into the command-line reference but not --help

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. I wasn't aware of DocBreef, that's indeed much better like this.

HelpText<"Enable optimizations based on the strict definition of flexible arrays. "
"If ``<n>`` is equal to 0, any trailing array member is considered a flexible array. "
"If ``<n>`` is equal to 1, trailing array members of size 0, 1 and undefined are considered flexible arrays. "
"If ``<n>`` is equal to 3, only trailing array members of undefined size are considered flexible arrays.">,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oopsie. Fixed

Copy link
Collaborator

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

Thank you!

@serge-sans-paille serge-sans-paille merged commit f35e172 into llvm:main May 4, 2025
11 checks passed
@AaronBallman
Copy link
Collaborator

Thank you for the quick turnaround on the documentation!

IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[clang] values for command-line flag -fstrict-flex-arrays= are undocumented and very confusing
4 participants