[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2025-01-07 Thread via cfe-commits
github-actions[bot] wrote: @amane-ame Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a buil

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2025-01-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/119563 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2025-01-06 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 01/11] [clang] Fix crashes when passing VLA to va_arg --- clang/li

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2025-01-06 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 01/11] [clang] Fix crashes when passing VLA to va_arg --- clang/li

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2025-01-06 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/119563 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-31 Thread via cfe-commits
amane-ame wrote: cc @efriedma-quic @tbaederr. Could anyone please review this? https://github.com/llvm/llvm-project/pull/119563 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-24 Thread via cfe-commits
amane-ame wrote: Ping. https://github.com/llvm/llvm-project/pull/119563 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-20 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 01/10] [clang] Fix crashes when passing VLA to va_arg --- clang/li

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-17 Thread via cfe-commits
https://github.com/amane-ame edited https://github.com/llvm/llvm-project/pull/119563 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-17 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 01/10] [clang] Fix crashes when passing VLA to va_arg --- clang/li

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-17 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 3e2e04fbf1978d657bb6968c16f68ef7c4adfbdb Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 01/10] [clang] Fix crashes when passing VLA to va_arg --- clang/li

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-16 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 1/9] [clang] Fix crashes when passing VLA to va_arg --- clang/lib/

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-16 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff f4081711f0884ec7afe93577e118ecc89cb7b1cf 7dcd400df3670d749902ab04485974ba843415f2 --e

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-14 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 1/8] [clang] Fix crashes when passing VLA to va_arg --- clang/lib/

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-13 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 1/7] [clang] Fix crashes when passing VLA to va_arg --- clang/lib/

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-13 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 1/7] [clang] Fix crashes when passing VLA to va_arg --- clang/lib/

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-13 Thread Eli Friedman via cfe-commits
@@ -20,4 +20,7 @@ void vla(int n, ...) __builtin_va_list ap; void *p; p = __builtin_va_arg(ap, typeof (int (*)[++n])); // CHECK: add nsw i32 {{.*}}, 1 + // Don't crash on some undefined behaviors. + p = __builtin_va_arg(ap, typeof (int [++n])); // expected-warning{{sec

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-13 Thread Eli Friedman via cfe-commits
@@ -16538,6 +16538,13 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, << TInfo->getTypeLoc().getSourceRange(); } +if (TInfo->getType()->isVariableArrayType()) { efriedma-quic wrote: This should check for any array type; the issu

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-13 Thread Eli Friedman via cfe-commits
@@ -6121,6 +6121,8 @@ RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr, VAListAddr = VE->isMicrosoftABI() ? EmitMSVAListRef(VE->getSubExpr()) : EmitVAListRef(VE->getSubExpr()); QualType Ty = VE->getType(); + if (Ty->

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 1/4] [clang] Fix crashes when passing VLA to va_arg --- clang/lib/

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119563 From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH 1/3] [clang] Fix crashes when passing VLA to va_arg --- clang/lib/

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: C standard rules for va_arg: "[...] if *type* is not compatible with the type of the actual next argument [...], the behavior is undefined [...]". A struct is never compatible with an array, so yes , it's undefined. (See 6.2.7 for what constitutes a "compatible type".)

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread Robear Selwans via cfe-commits
mo7sen wrote: > While you're here, maybe look at emitting an undefined-behavior warning for > this construct? A VLA is never compatible with a function argument: if you > try to write an array in an function type, it gets promoted to a pointer. So > this construct is guaranteed to produce brok

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Please add a testcase to clang/test/CodeGen/ . Put it in an existing file if there's already some related test. (See also https://llvm.org/docs/Contributing.html#how-to-submit-a-patch ) I don't think EmitAggregateCopy is the right place to call EmitVariablyModifiedType:

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-codegen Author: 天音あめ (amane-ame) Changes Closes #119360. --- Full diff: https://github.com/llvm/llvm-project/pull/119563.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CGExprAgg.cpp (+2) ``diff diff

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread via cfe-commits
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it

[clang] [clang] Fix crashes when passing VLA to va_arg (PR #119563)

2024-12-11 Thread via cfe-commits
https://github.com/amane-ame created https://github.com/llvm/llvm-project/pull/119563 Closes #119360. From 659eda3ec76b63418f8b621b004728d9d7bf26ad Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 22:17:51 +0800 Subject: [PATCH] [clang] Fix crashes when passing VLA to va_arg --