[all-commits] [llvm/llvm-project] 870b6d: Improve handling of static assert messages.

cor3ntin via All-commits all-commits at lists.llvm.org
Tue Jun 28 13:26:13 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 870b6d21839707a3e4c40a29b526995f065a220f
      https://github.com/llvm/llvm-project/commit/870b6d21839707a3e4c40a29b526995f065a220f
  Author: Corentin Jabot <corentinjabot at gmail.com>
  Date:   2022-06-28 (Tue, 28 Jun 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Basic/Diagnostic.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
    M clang/test/C/drs/dr0xx.c
    M clang/test/CXX/dcl.dcl/p4-0x.cpp
    M clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
    M clang/test/Lexer/null-character-in-literal.c
    M clang/test/Misc/diag-special-chars.c
    M clang/test/Misc/wrong-encoding.c
    M clang/test/PCH/cxx-static_assert.cpp
    M clang/test/Sema/static-assert.c
    M clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
    M clang/test/SemaCXX/static-assert.cpp
    M llvm/include/llvm/Support/Unicode.h
    M llvm/lib/Support/Unicode.cpp

  Log Message:
  -----------
  Improve handling of static assert messages.

Instead of dumping the string literal (which
quotes it and escape every non-ascii symbol),
we can use the content of the string when it is a
8 byte string.

Wide, UTF-8/UTF-16/32 strings are still completely
escaped, until we clarify how these entities should
behave (cf https://wg21.link/p2361).

`FormatDiagnostic` is modified to escape
non printable characters and invalid UTF-8.

This ensures that unicode characters, spaces and new
lines are properly rendered in static messages.
This make clang more consistent with other implementation
and fixes this tweet
https://twitter.com/jfbastien/status/1298307325443231744 :)

Of note, `PaddingChecker` did print out new lines that were
later removed by the diagnostic printing code.
To be consistent with its tests, the new lines are removed
from the diagnostic.

Unicode tables updated to both use the Unicode definitions
and the Unicode 14.0 data.

U+00AD SOFT HYPHEN is still considered a print character
to match existing practices in terminals, in addition of
being considered a formatting character as per Unicode.

Reviewed By: aaron.ballman, #clang-language-wg

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




More information about the All-commits mailing list