[Clang] Add a warning on invalid UTF-8 in comments.
authorCorentin Jabot <corentinjabot@gmail.com>
Fri, 17 Jun 2022 14:23:41 +0000 (16:23 +0200)
committerCorentin Jabot <corentinjabot@gmail.com>
Tue, 12 Jul 2022 12:34:30 +0000 (14:34 +0200)
commitcc309721d20c8e544ae7a10a66735ccf4981a11c
tree35566661c4e208a5d57badb7f2a12d18fabdaa76
parent4e4a4c057665d169b8fe6dcdd5bb7c0b0bf8ff19
[Clang] Add a warning on invalid UTF-8 in comments.

Introduce an off-by default `-Winvalid-utf8` warning
that detects invalid UTF-8 code units sequences in comments.

Invalid UTF-8 in other places is already diagnosed,
as that cannot appear in identifiers and other grammar constructs.

The warning is off by default as its likely to be somewhat disruptive
otherwise.

This warning allows clang to conform to the yet-to be approved WG21
"P2295R5 Support for UTF-8 as a portable source file encoding"
paper.

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

Differential Revision: https://reviews.llvm.org/D128059
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/Lexer.cpp
clang/test/Lexer/comment-invalid-utf8.c [new file with mode: 0644]
clang/test/Lexer/comment-utf8.c [new file with mode: 0644]
clang/test/SemaCXX/static-assert.cpp
llvm/include/llvm/Support/ConvertUTF.h
llvm/lib/Support/ConvertUTF.cpp