[all-commits] [llvm/llvm-project] c72d3a: [Clang] Handle consteval expression in array bound...

cor3ntin via All-commits all-commits at lists.llvm.org
Thu Oct 5 02:36:41 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c72d3a0966afd2dcb4421dde922c0faf06d65c0e
      https://github.com/llvm/llvm-project/commit/c72d3a0966afd2dcb4421dde922c0faf06d65c0e
  Author: cor3ntin <corentinjabot at gmail.com>
  Date:   2023-10-05 (Thu, 05 Oct 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Parse/Parser.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseExpr.cpp
    M clang/lib/Sema/Sema.cpp
    M clang/lib/Sema/SemaCUDA.cpp
    M clang/lib/Sema/SemaChecking.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/test/SemaCXX/cxx2a-consteval.cpp
    M clang/unittests/Support/TimeProfilerTest.cpp

  Log Message:
  -----------
  [Clang] Handle consteval expression in array bounds expressions (#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 consteval function (which
are specified to be only immediately called in non-constant contexts)
that appear in arrays bounds.

This introduces `Sema::isAlwayConstantEvaluatedContext`, and a flag in
ExpressionEvaluationContextRecord, such that immediate functions in
array bounds are always immediately invoked.

Sema had both `isConstantEvaluatedContext` and
`isConstantEvaluated`, so I took the opportunity to cleanup that.

The change in `TimeProfilerTest.cpp` is an unfortunate manifestation of
the problem that #66203 seeks to address.

Fixes #65520




More information about the All-commits mailing list