[all-commits] [llvm/llvm-project] f6267d: [clang][CGExprConstant] handle implicit widening/n...

Nick Desaulniers via All-commits all-commits at lists.llvm.org
Mon Aug 7 14:57:45 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f6267d3b98c11b50bf24946f21c6646d2d3f6fa8
      https://github.com/llvm/llvm-project/commit/f6267d3b98c11b50bf24946f21c6646d2d3f6fa8
  Author: Nick Desaulniers <ndesaulniers at google.com>
  Date:   2023-08-07 (Mon, 07 Aug 2023)

  Changed paths:
    M clang/lib/CodeGen/CGExprConstant.cpp
    M clang/test/CodeGen/global-init.c

  Log Message:
  -----------
  [clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

Consider the following statements:
    long x = 1;
    short y = 1;

With the following AST:
    |-VarDecl 0x55d289973730 <x.c:1:1, col:10> col:6 x 'long' cinit
    | `-ImplicitCastExpr 0x55d289973800 <col:10> 'long' <IntegralCast>
    |   `-IntegerLiteral 0x55d2899737e0 <col:10> 'int' 1
    `-VarDecl 0x55d289973830 <line:2:1, col:11> col:7 y 'short' cinit
      `-ImplicitCastExpr 0x55d2899738b8 <col:11> 'short' <IntegralCast>
        `-IntegerLiteral 0x55d289973898 <col:11> 'int' 1

Sign or Zero extend or truncate based on the source signedness and
destination width.

Reviewed By: efriedma

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




More information about the All-commits mailing list