Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
6 changed files
with
140 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// RUN: %clang_cc1 -fsyntax-only %s -Winvalid-utf8 -verify=expected | ||
// RUN: %clang_cc1 -fsyntax-only %s -verify=nowarn | ||
// nowarn-no-diagnostics | ||
|
||
// This file is purposefully encoded as windows-1252 | ||
// be careful when modifying. | ||
|
||
//€ | ||
// expected-warning@-1 {{invalid UTF-8 in comment}} | ||
|
||
// € ‚ƒ„…†‡ˆ‰ Š ‹ Œ Ž | ||
// expected-warning@-1 6{{invalid UTF-8 in comment}} | ||
|
||
/*€*/ | ||
// expected-warning@-1 {{invalid UTF-8 in comment}} | ||
|
||
/*€ ‚ƒ„…†‡ˆ‰ Š ‹ Œ Ž*/ | ||
// expected-warning@-1 6{{invalid UTF-8 in comment}} | ||
|
||
/* | ||
€ | ||
*/ | ||
// expected-warning@-2 {{invalid UTF-8 in comment}} | ||
|
||
// abcd | ||
// €abcd | ||
// expected-warning@-1 {{invalid UTF-8 in comment}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters