[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

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

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-10-05 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222 >From dc95c839c104a0af50da1466e7249bde306bd662 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH 1/8] [Clang] Handle consteval expression in array bounds expres

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-10-04 Thread Shafik Yaghmour via cfe-commits
@@ -15090,8 +15093,9 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, if (SourceBT && TargetBT && SourceBT->isIntegerType() && TargetBT->isFloatingType() && !IsListInit) { // Determine the number of precision bits in the source integer type. -

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-10-04 Thread Shafik Yaghmour via cfe-commits
@@ -14143,8 +14145,9 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) { } // Otherwise, calculate the effective range of the signed operand. - IntRange signedRange = GetExprRange( - S.Context, signedOperand, S.isConstantEvaluated(), /*Approximate*/ true)

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-10-04 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik approved this pull request. LGTM after fixing nits. https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-10-04 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-10-03 Thread via cfe-commits
cor3ntin wrote: @shafik ping! https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-28 Thread Erich Keane via cfe-commits
https://github.com/erichkeane commented: Still OK with this, but Shafik should do the final approval. https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222 >From b2475193769051ae4d0c340237fd5df76dfe8c49 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH 1/6] [Clang] Handle consteval expression in array bounds expres

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread Erich Keane via cfe-commits
@@ -221,6 +221,15 @@ ExprResult Parser::ParseConstantExpression() { return ParseConstantExpressionInExprEvalContext(NotTypeCast); } +ExprResult Parser::ParseArrayBoundExpression() { + EnterExpressionEvaluationContext ConstantEvaluated( + Actions, Sema::ExpressionEvalua

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222 >From 57d48220f38507657b6b25c887cd4adf1f5008b3 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH 1/6] [Clang] Handle consteval expression in array bounds expres

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread via cfe-commits
@@ -221,6 +221,15 @@ ExprResult Parser::ParseConstantExpression() { return ParseConstantExpressionInExprEvalContext(NotTypeCast); } +ExprResult Parser::ParseArrayBoundExpression() { + EnterExpressionEvaluationContext ConstantEvaluated( + Actions, Sema::ExpressionEvalua

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread Erich Keane via cfe-commits
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread Erich Keane via cfe-commits
@@ -221,6 +221,15 @@ ExprResult Parser::ParseConstantExpression() { return ParseConstantExpressionInExprEvalContext(NotTypeCast); } +ExprResult Parser::ParseArrayBoundExpression() { + EnterExpressionEvaluationContext ConstantEvaluated( + Actions, Sema::ExpressionEvalua

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread Erich Keane via cfe-commits
https://github.com/erichkeane commented: I think this generally makes a lot of sense, I have 1 nit (plus a bunch of the 'bool' comments without the = sign that @shafik suggested, but were closed without comment), otherwise LGTM. https://github.com/llvm/llvm-project/pull/66222 _

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread Shafik Yaghmour via cfe-commits
@@ -15090,8 +15093,9 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, if (SourceBT && TargetBT && SourceBT->isIntegerType() && TargetBT->isFloatingType() && !IsListInit) { // Determine the number of precision bits in the source integer type. -

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread Shafik Yaghmour via cfe-commits
@@ -5490,6 +5490,9 @@ TreeTransform::TransformDependentSizedArrayType(TypeLocBuilder &TLB, EnterExpressionEvaluationContext Unevaluated( SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); + // VLA bounds are not truly constant. shafik wr

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222 >From 57d48220f38507657b6b25c887cd4adf1f5008b3 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH 1/5] [Clang] Handle consteval expression in array bounds expres

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222 >From 57d48220f38507657b6b25c887cd4adf1f5008b3 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH 1/4] [Clang] Handle consteval expression in array bounds expres

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-27 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222 >From 57d48220f38507657b6b25c887cd4adf1f5008b3 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH 1/3] [Clang] Handle consteval expression in array bounds expres

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-26 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 b26157edf08184f2620b3df95048a97a1658c021 4b62211b22950a9bdd3764093f6716d0f792469e --

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-26 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222 >From 44867abb2e1c0c34963229ec93b0d1d71aa33db5 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH 1/3] [Clang] Handle consteval expression in array bounds expres

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-15 Thread Takuya Shimizu via cfe-commits
hazohelet wrote: > I'll add a test. immediate contexts are recursive, constant evaluated > contexts are not, i don't think there is a case where you would get an > additional evaluation context that is not for a full expression, and if you > have a full expression you do expect the immediate i

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-14 Thread via cfe-commits
cor3ntin wrote: > My patch needs modification so that use of `is_constant_evaluated` and > consteval-if NOT considered tautologically-true when they happen > `InConditionallyConstantEvaluateContext`, which is a few lines of change. Hum, maybe to do that we need to set ahead of time whether we

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-14 Thread Takuya Shimizu via cfe-commits
hazohelet wrote: > Where do you think it matters? I can't this of cases where ConstantEvaluated > context are nested in one another without some intertwined potentially > evaluated context I was mostly thinking about cases where the array-bound expression appears inside immediate function con

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-14 Thread via cfe-commits
cor3ntin wrote: > Is it alright to set `InConditionallyConstantEvaluateContext` true only when > the outer evaluation context `isAlwaysConstantEvaluatedContext()` so that we > can say the array bound expr is always constant-evaluated if it happens in > always-constant-evaluated context? Where

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-14 Thread Takuya Shimizu via cfe-commits
hazohelet wrote: > @hazohelet Does this collide or intersect with the work wrt. (un)evaluated > contexts in https://reviews.llvm.org/D155064 ? I wasn't aware of VLA cases in that patch. My patch needs modification so that use of `is_constant_evaluated` and consteval-if NOT considered tautologi

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik review_requested https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: If the function is `constexpr` do we treat it as a VLA? https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -9843,30 +9833,44 @@ class Sema final { /// diagnostics that will be suppressed. std::optional isSFINAEContext() const; - /// Determines whether we are currently in a context that - /// is not evaluated as per C++ [expr] p5. - bool isUnevaluatedContext() const { + /

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -13928,7 +13930,7 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, return false; IntRange OtherValueRange = GetExprRange( - S.Context, Other, S.isConstantEvaluated(), /*Approximate*/ false); + S.Context, Other, S.isConstantEvaluatedCon

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -13928,7 +13930,7 @@ static bool CheckTautologicalComparison(Sema &S, BinaryOperator *E, return false; IntRange OtherValueRange = GetExprRange( - S.Context, Other, S.isConstantEvaluated(), /*Approximate*/ false); + S.Context, Other, S.isConstantEvaluatedCon

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -14143,8 +14145,9 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) { } // Otherwise, calculate the effective range of the signed operand. - IntRange signedRange = GetExprRange( - S.Context, signedOperand, S.isConstantEvaluated(), /*Approximate*/ true)

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -15159,16 +15163,16 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, IntRange SourceTypeRange = IntRange::forTargetOfCanonicalType(S.Context, Source); - IntRange LikelySourceRange = - GetExprRange(S.Context, E, S.isConstantEvaluated(), /*A

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -15090,8 +15093,9 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, if (SourceBT && TargetBT && SourceBT->isIntegerType() && TargetBT->isFloatingType() && !IsListInit) { // Determine the number of precision bits in the source integer type. -

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread Timm Baeder via cfe-commits
tbaederr wrote: @hazohelet Does this collide or intersect with the work wrt. (un)evaluated contexts in https://reviews.llvm.org/D155064 ? https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://l

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread via cfe-commits
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/66222: >From d7f281ed8809d991393de0c922fd08a0d657d863 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 13 Sep 2023 17:36:39 +0200 Subject: [PATCH] [Clang] Handle consteval expression in array bounds expressio

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Changes The bounds of a c++ array is a _constant-expression_. And in C++ it is also a constant expression. But we also support VLAs, ie arrays with non-constant bounds. We need to take care to handle the case of a consteval function (w

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread via cfe-commits
https://github.com/llvmbot labeled https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread via cfe-commits
https://github.com/cor3ntin review_requested https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread via cfe-commits
https://github.com/cor3ntin labeled https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread via cfe-commits
https://github.com/cor3ntin labeled https://github.com/llvm/llvm-project/pull/66222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-09-13 Thread via cfe-commits
https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/66222: The bounds of a c++ array is a _constant-expression_. And in C++ it is also a constant expression. But we also support VLAs, ie arrays with non-constant bounds. We need to take care to handle the case of a co