[clang] [Clang] Added check for unexpanded pack in attribute [[assume]] (PR #91841)
https://github.com/azmat-y created https://github.com/llvm/llvm-project/pull/91841 Added check for unexpanded parameter pack in attribute [[assume]]. This solves #91232. >From c9f0887b5af64387938e0d80a4210af296e68f31 Mon Sep 17 00:00:00 2001 From: Azmat Yusuf Date: Sat, 11 May 2024 09:56:02 +0530 Subject: [PATCH] [Clang] Added check for unexpanded pack in attribute [[assume]] --- clang/lib/Sema/SemaStmtAttr.cpp | 5 + 1 file changed, 5 insertions(+) diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 1c84830b6ddd2..36f8ecadcfab7 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -670,6 +670,11 @@ ExprResult Sema::ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, } auto *Assumption = A.getArgAsExpr(0); + + if (DiagnoseUnexpandedParameterPack(Assumption)) { +return ExprError(); + } + if (Assumption->getDependence() == ExprDependence::None) { ExprResult Res = BuildCXXAssumeExpr(Assumption, A.getAttrName(), Range); if (Res.isInvalid()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Added check for unexpanded pack in attribute [[assume]] (PR #91841)
azmat-y wrote: Would I be correct in assuming that the test would be somewhat similar to this. llvm-project/clang/test/Sema/unroll-template-value-crash.cpp ``` // RUN: %clang_cc1 -x c++ -verify %s // expected-no-diagnostics template void foo() { #pragma unroll Unroll for (int i = 0; i < Unroll; ++i); #pragma GCC unroll Unroll for (int i = 0; i < Unroll; ++i); } ``` Can you point me towards information on clang_cc1 and similar arguments used for lit. I have scanned through [lit](https://llvm.org/docs/CommandGuide/lit.html#execution-options) but could not find a mention for it. https://github.com/llvm/llvm-project/pull/91841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Added check for unexpanded pack in attribute [[assume]] (PR #91893)
https://github.com/azmat-y created https://github.com/llvm/llvm-project/pull/91893 Added a check for unexpanded parameter pack in attribute [[assume]]. Tested it with expected-error statements from clang fronted. This fixes #91232. @Sirraide >From cbb35bd010f2d46ae70367549a2838841a55aeb7 Mon Sep 17 00:00:00 2001 From: Azmat Yusuf Date: Sun, 12 May 2024 20:49:14 +0530 Subject: [PATCH] [Clang] Added check for unexpanded pack in attribute [[assume]] --- clang/lib/Sema/SemaStmtAttr.cpp | 5 + clang/test/SemaCXX/cxx23-assume.cpp | 5 + 2 files changed, 10 insertions(+) diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 1c84830b6ddd2..36f8ecadcfab7 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -670,6 +670,11 @@ ExprResult Sema::ActOnCXXAssumeAttr(Stmt *St, const ParsedAttr &A, } auto *Assumption = A.getArgAsExpr(0); + + if (DiagnoseUnexpandedParameterPack(Assumption)) { +return ExprError(); + } + if (Assumption->getDependence() == ExprDependence::None) { ExprResult Res = BuildCXXAssumeExpr(Assumption, A.getAttrName(), Range); if (Res.isInvalid()) diff --git a/clang/test/SemaCXX/cxx23-assume.cpp b/clang/test/SemaCXX/cxx23-assume.cpp index 8676970de14f6..e67d72ae0a995 100644 --- a/clang/test/SemaCXX/cxx23-assume.cpp +++ b/clang/test/SemaCXX/cxx23-assume.cpp @@ -138,3 +138,8 @@ constexpr int foo() { } static_assert(foo() == 0); + +template +void f() { +[[assume(val)]]; // expected-error {{expression contains unexpanded parameter pack}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Added check for unexpanded pack in attribute [[assume]] (PR #91893)
azmat-y wrote: It was a pleasure working on this. I have received two emails from llvm build bot regarding failed builds, though the commit shows 8 build fails. How to go about investigating the cause of failures? Can you give me some pointers regarding this. And do the failures means this patch will need to be reverted? https://github.com/llvm/llvm-project/pull/91893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Added check for unexpanded pack in attribute [[assume]] (PR #91893)
azmat-y wrote: Here are the builds Mentioned in emails [clang-aarch64-sve-vls](https://lab.llvm.org/buildbot/#/builders/184/builds/12514) [clang-aarch64-sve-vla-2stage](https://lab.llvm.org/buildbot/#/builders/198/builds/9849) Others [arc-builder](https://lab.llvm.org/buildbot/#/builders/164/builds/52197) [bolt-x86_64-ubuntu-clang](https://lab.llvm.org/buildbot/#/builders/252/builds/9890) [clang-with-lto-ubuntu](https://lab.llvm.org/buildbot/#/builders/124/builds/10736) [clang-with-thin-lto-ubuntu](https://lab.llvm.org/buildbot/#/builders/67/builds/15879) [clang-x64-windows-msvc](https://lab.llvm.org/buildbot/#/builders/123/builds/26469) [lldb-aarch64-windows](https://lab.llvm.org/buildbot/#/builders/219/builds/11350) https://github.com/llvm/llvm-project/pull/91893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Added check for unexpanded pack in attribute [[assume]] (PR #91893)
azmat-y wrote: Thanks for confirming and also thanks for your help. https://github.com/llvm/llvm-project/pull/91893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits