Page MenuHomePhabricator

[clang] add -Wvla-stack-allocation
Needs ReviewPublic

Authored by Origami404 on Thu, Nov 3, 10:05 AM.

Details

Summary

New behaviors:

-Wvla: produces portability warning for all VLAs like before
-Wvla-portability: not exists (equal to -Wvla)
-Wvla-stack-allocation -Wno-vla: only warns for VLAs that need stack allocation
-Wvla -Wvla-stack-allocation: warn for VLAs that need stack allocation, and give portablility warnings for other VLAs

Note that only one warning can be produced by one VLA because of
implementation complexity. Currently, VLAs are detected in
BuildArrayType, which will be used both by Parser and Tree Transformer.
And it passes the VLA-related warnings as an argument to other
functions. Producing multiple warnings for one VLA needs to change many
functions.

Fixes: https://github.com/llvm/llvm-project/issues/57098
Link: https://reviews.llvm.org/D132952

Co-authored-by: YingChi Long <me@inclyc.cn>

Diff Detail

Event Timeline

Origami404 created this revision.Thu, Nov 3, 10:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Nov 3, 10:05 AM
Origami404 edited the summary of this revision. (Show Details)Thu, Nov 3, 10:08 AM
Origami404 edited the summary of this revision. (Show Details)
Origami404 added reviewers: aaron.ballman, efriedma.
Origami404 added a subscriber: inclyc.
Origami404 published this revision for review.Thu, Nov 3, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Nov 3, 10:10 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

We may need a release note here so users know about the new changes to -Wvla. See clang/docs/ReleaseNotes.rst!

Update release notes.