[PATCH] D156185: [clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 16:32:32 PDT 2023


nickdesaulniers added a comment.

For this case in this patch in particular:

  extern const char* bar;
  const char* foo [] = {
      "hello",
      "goodbye",
      bar
  };

  TranslationUnitDecl
  |-VarDecl <line:1:1, col:20> col:20 used bar 'const char *' extern
  `-VarDecl <line:2:1, line:6:1> line:2:13 foo 'const char *[3]' cinit
    `-InitListExpr <col:22, line:6:1> 'const char *[3]'
      |-ImplicitCastExpr <line:3:5> 'const char *' <NoOp>
      | `-ImplicitCastExpr <col:5> 'char *' <ArrayToPointerDecay>
      |   `-StringLiteral <col:5> 'char[6]' lvalue "hello"
      |-ImplicitCastExpr <line:4:5> 'const char *' <NoOp>
      | `-ImplicitCastExpr <col:5> 'char *' <ArrayToPointerDecay>
      |   `-StringLiteral <col:5> 'char[8]' lvalue "goodbye"
      `-ImplicitCastExpr <line:5:5> 'const char *' <LValueToRValue>
        `-DeclRefExpr <col:5> 'const char *' lvalue Var 0x55b64410c270 'bar' 'const char *'

so if you were concerned with arrays <https://reviews.llvm.org/D76096#4523828> of string literals <https://reviews.llvm.org/D76096#4524003>, we need this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156185/new/

https://reviews.llvm.org/D156185



More information about the cfe-commits mailing list