[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread via cfe-commits
https://github.com/cor3ntin closed https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread via cfe-commits
github-actions[bot] wrote: @jj-marr 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 build,

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread JJ Marr via cfe-commits
jj-marr wrote: OK, merge whenever. https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread via cfe-commits
cor3ntin wrote: > Is it something I can actually do myself? Or can only maintainers merge? Yes, only maintainers can do it (you can become a maintainer after you make a few contributions) https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access https://github.com/llvm/llvm-project/p

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread JJ Marr via cfe-commits
jj-marr wrote: > @jj-marr Thanks. Do you want us to merge that for you? Is it something I can actually do myself? https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 >From 67984fbf0374fa40fd7b73431b17baddc301290f Mon Sep 17 00:00:00 2001 From: JJ Marr Date: Sat, 8 Mar 2025 22:00:45 -0500 Subject: [PATCH] Explain which assertion failed during consteval --- clang/docs/Releas

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-13 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 >From 64eb62576dc1ecf0e696f2448e410c2fd77575de Mon Sep 17 00:00:00 2001 From: JJ Marr Date: Sat, 8 Mar 2025 22:00:45 -0500 Subject: [PATCH] Explain which assertion failed during consteval --- clang/docs/Releas

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-12 Thread via cfe-commits
cor3ntin wrote: @jj-marr Thanks. Do you want us to merge that for you? https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-12 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-11 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis commented: LGTM https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-11 Thread via cfe-commits
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-11 Thread via cfe-commits
https://github.com/cor3ntin approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-11 Thread via cfe-commits
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-11 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-11 Thread JJ Marr via cfe-commits
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-11 Thread via cfe-commits
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-10 Thread JJ Marr via cfe-commits
@@ -5975,9 +5975,15 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-10 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-10 Thread via cfe-commits
@@ -5975,9 +5975,15 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread JJ Marr via cfe-commits
jj-marr wrote: > LGTM modulo nit. > > Are you happy with the current state? @cor3ntin @Sirraide Shouldn't CI be passing? I can't figure out why there are failures. https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-comm

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread JJ Marr via cfe-commits
@@ -5975,9 +5975,15 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread Yanzuo Liu via cfe-commits
@@ -5975,9 +5975,15 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc, Definition->hasAttr( return true; - if (Info.getLangOpts().CPlusPlus11) { -const FunctionDecl *DiagDecl = Definition ? Defin

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis commented: LGTM module nit. Are you happy with the current state? @cor3ntin @Sirraide https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 >From 3b6d28e4f74c1fda73abe3b5972d5ac2a43576de Mon Sep 17 00:00:00 2001 From: JJ Marr Date: Sat, 8 Mar 2025 22:00:45 -0500 Subject: [PATCH] Explain which assertion failed during consteval --- clang/docs/Releas

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-s

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-05-09 Thread JJ Marr via cfe-commits
https://github.com/jj-marr ready_for_review https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-04-29 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 >From d06c5ab5c30e535893335af798df339b0e9c6878 Mon Sep 17 00:00:00 2001 From: JJ Marr Date: Sat, 8 Mar 2025 22:00:45 -0500 Subject: [PATCH] Explain which assertion failed during consteval --- .../clang/Basic/D

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-04-17 Thread JJ Marr via cfe-commits
https://github.com/jj-marr converted_to_draft https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-04-04 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 >From 0cba377eb8693657b7688cd1feb1cc9c5734f307 Mon Sep 17 00:00:00 2001 From: JJ Marr Date: Sat, 8 Mar 2025 22:00:45 -0500 Subject: [PATCH] Explain which assertion failed during consteval --- .../clang/Basic/D

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-20 Thread JJ Marr via cfe-commits
jj-marr wrote: I'm still working on this. It seems like I broke the assertion tests. I'm unsure why, but it should be fixed if I figure out a better way of evaluating the macro. https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-12 Thread A. Jiang via cfe-commits
@@ -107,6 +107,8 @@ def err_ice_too_large : Error< "integer constant expression evaluates to value %0 that cannot be " "represented in a %1-bit %select{signed|unsigned}2 integer type">; def err_expr_not_string_literal : Error<"expression is not a string literal">; +def note

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-11 Thread via cfe-commits
@@ -8361,6 +8361,17 @@ class ExprEvaluatorBase return false; } +// If an assertion fails during constant evaluation, give a specific note explaining that +if (FD->getName() == "__assert_fail") { cor3ntin wrote: Maybe we can instead check

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-11 Thread Mariya Podchishchaeva via cfe-commits
@@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus %s + +#ifdef __ASSERT_FUNCTION +#undef __ASSERT_FUNCTION +#endif +extern "C" void __assert_fail(const char*, const char*, unsigned, const char*); + +#define assert(cond) \ + ((cond) ? (void)0 : __assert_f

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-11 Thread via cfe-commits
@@ -8361,6 +8361,17 @@ class ExprEvaluatorBase return false; } +// If an assertion fails during constant evaluation, give a specific note explaining that +if (FD->getName() == "__assert_fail") { cor3ntin wrote: Either way, we need a test

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-11 Thread Mariya Podchishchaeva via cfe-commits
https://github.com/Fznamznon edited https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-11 Thread Mariya Podchishchaeva via cfe-commits
https://github.com/Fznamznon edited https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-11 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-10 Thread via cfe-commits
@@ -8361,6 +8361,17 @@ class ExprEvaluatorBase return false; } +// If an assertion fails during constant evaluation, give a specific note explaining that +if (FD->getName() == "__assert_fail") { Sirraide wrote: > Maybe we can instead chec

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-10 Thread JJ Marr via cfe-commits
@@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus %s + +#ifdef __ASSERT_FUNCTION +#undef __ASSERT_FUNCTION +#endif +extern "C" void __assert_fail(const char*, const char*, unsigned, const char*); + +#define assert(cond) \ + ((cond) ? (void)0 : __assert_f

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-09 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-09 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis commented: Thank you for the patch! You should add a release note in clang/docs/ReleaseNotes.rst so that users can know the improvement. https://github.com/llvm/llvm-project/pull/130458 ___ cfe-commits mailing list cfe-commits

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-09 Thread Yanzuo Liu via cfe-commits
@@ -8361,6 +8361,17 @@ class ExprEvaluatorBase return false; } +// If an assertion fails during constant evaluation, give a specific note explaining that +if (FD->getName() == "__assert_fail") { zwuis wrote: The name of corresponding func

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-08 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] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-08 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: JJ Marr (jj-marr) Changes Take this piece of code: ```cpp #include consteval int square(int x) { int result = x * x; assert(result == 42); return result; } void test() { auto val = square(2); } ``` The assertion will fai

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-08 Thread JJ Marr via cfe-commits
https://github.com/jj-marr updated https://github.com/llvm/llvm-project/pull/130458 >From d61892d8546944000118ad0312886da75cd6509b Mon Sep 17 00:00:00 2001 From: JJ Marr Date: Sat, 8 Mar 2025 22:00:45 -0500 Subject: [PATCH] Explain which assertion failed during consteval --- .../clang/Basic/D

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-03-08 Thread JJ Marr via cfe-commits
https://github.com/jj-marr created https://github.com/llvm/llvm-project/pull/130458 Take this piece of code: ```cpp #include consteval int square(int x) { int result = x * x; assert(result == 42); return result; } void test() { auto val = square(2); } ``` The assertion will fail, and