[all-commits] [llvm/llvm-project] 2c2639: [clang][ConstExprEmitter] handle NullToPointer Imp...

Nick Desaulniers via All-commits all-commits at lists.llvm.org
Wed Jul 26 12:53:22 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2c26397f76d9b8d2a0dc8207eeca5b0d3216f3f0
      https://github.com/llvm/llvm-project/commit/2c26397f76d9b8d2a0dc8207eeca5b0d3216f3f0
  Author: Nick Desaulniers <ndesaulniers at google.com>
  Date:   2023-07-26 (Wed, 26 Jul 2023)

  Changed paths:
    M clang/lib/CodeGen/CGExprConstant.cpp

  Log Message:
  -----------
  [clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr

Consider the following statement:
    void* foo = ((void *)0);

For the sub-AST:
    | `-ImplicitCastExpr 'const void *' <NullToPointer>
    |   `-CStyleCastExpr 'void *' <NullToPointer>
    |     `-IntegerLiteral 'int' 0

If the subexpression of the cast is itself the NULL constant, then
ImplicitCastExpr should emit the NULL pointer constant.

Reviewed By: efriedma

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




More information about the All-commits mailing list