[all-commits] [llvm/llvm-project] 36af07: Accept string literal decay in conditional operator

Elvis Stansvik via All-commits all-commits at lists.llvm.org
Tue Jan 11 12:05:54 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 36af07334246a87a0f3fb9bbc85dedfca04b00d1
      https://github.com/llvm/llvm-project/commit/36af07334246a87a0f3fb9bbc85dedfca04b00d1
  Author: Elvis Stansvik <elvstone at gmail.com>
  Date:   2022-01-11 (Tue, 11 Jan 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

  Log Message:
  -----------
  Accept string literal decay in conditional operator

The cppcoreguidelines-pro-bounds-array-to-pointer-decay check currently
accepts:

const char *b = i ? "foo" : "foobar";

but not

const char *a = i ? "foo" : "bar";

This is because the AST is slightly different in the latter case (see
https://godbolt.org/z/MkHVvs).

This eliminates the inconsistency by making it accept the latter form
as well.

Fixes https://github.com/llvm/llvm-project/issues/31155.




More information about the All-commits mailing list