[PATCH] D125620: [Clang] Fix diagnostics formatting
Tee KOBAYASHI via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat May 14 16:42:46 PDT 2022
xtkoba created this revision.
Herald added a project: All.
xtkoba requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
When a `#warning` directive is followed by tokens containing non-ASCII characters encoded in UTF-8, a broken string can be printed out as a diagnostic message on some systems. This is because the current code assumes `char` to be `signed char`, whereas on some systems `char` is in fact `unsigned char`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125620
Files:
clang/lib/Basic/Diagnostic.cpp
Index: clang/lib/Basic/Diagnostic.cpp
===================================================================
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -811,7 +811,7 @@
StringRef(DiagStr, DiagEnd - DiagStr).equals("%0") &&
getArgKind(0) == DiagnosticsEngine::ak_std_string) {
const std::string &S = getArgStdStr(0);
- for (char c : S) {
+ for (signed char c : S) {
if (llvm::sys::locale::isPrint(c) || c == '\t') {
OutStr.push_back(c);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125620.429494.patch
Type: text/x-patch
Size: 513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220514/1402ff7a/attachment-0001.bin>
More information about the cfe-commits
mailing list