[all-commits] [llvm/llvm-project] 27cbfa: [Clang] Propagate const context info when emitting...

Ties Stuij via All-commits all-commits at lists.llvm.org
Thu Aug 18 03:24:12 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 27cbfa7cc8cdab121842adf4dd31f6811f523928
      https://github.com/llvm/llvm-project/commit/27cbfa7cc8cdab121842adf4dd31f6811f523928
  Author: Ties Stuij <ties at stuij.se>
  Date:   2022-08-18 (Thu, 18 Aug 2022)

  Changed paths:
    M clang/lib/CodeGen/CGExprConstant.cpp
    M clang/lib/CodeGen/ConstantEmitter.h
    M clang/test/CodeGen/const-init.c

  Log Message:
  -----------
  [Clang] Propagate const context info when emitting compound literal

This patch fixes a crash when trying to emit a constant compound literal.

For C++ Clang evaluates either casts or binary operations at translation time,
but doesn't pass on the InConstantContext information that was inferred when
parsing the statement.  Because of this, strict FP evaluation (-ftrapping-math)
which shouldn't be in effect yet, then causes checkFloatingpointResult to return
false, which in tryEmitGlobalCompoundLiteral will trigger an assert that the
compound literal wasn't constant.

The discussion here around 'manifestly constant evaluated contexts' was very
helpful to me when trying to understand what LLVM's position is on what
evaluation context should be in effect, together with the explanatory text in
that patch itself:
https://reviews.llvm.org/D87528

Reviewed By: rjmccall, DavidSpickett

Differential Revision: https://reviews.llvm.org/D131555




More information about the All-commits mailing list