[all-commits] [llvm/llvm-project] 381a64: [Clang] Add warnings when mixing different charN_t...
cor3ntin via All-commits
all-commits at lists.llvm.org
Thu May 15 09:16:27 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 381a649fb991eadb0c594de2d8b6166fcc11345a
https://github.com/llvm/llvm-project/commit/381a649fb991eadb0c594de2d8b6166fcc11345a
Author: cor3ntin <corentinjabot at gmail.com>
Date: 2025-05-15 (Thu, 15 May 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/AST/ASTDiagnostic.h
M clang/include/clang/AST/Type.h
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/AST/ASTDiagnostic.cpp
M clang/lib/AST/Type.cpp
M clang/lib/Sema/SemaChecking.cpp
M clang/lib/Sema/SemaExpr.cpp
A clang/test/SemaCXX/warn-implicit-unicode-conversions.cpp
M libcxx/include/print
M libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
M libcxx/test/std/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
M libcxx/test/std/localization/codecvt_unicode.pass.cpp
M libcxx/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_char8_t_in.pass.cpp
M libcxx/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_char8_t_out.pass.cpp
M libcxx/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_char8_t_in.pass.cpp
M libcxx/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_char8_t_out.pass.cpp
M libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char8_t/assign2.pass.cpp
M libcxx/utils/libcxx/test/features.py
M llvm/include/llvm/Support/ConvertUTF.h
M llvm/lib/Support/ConvertUTFWrapper.cpp
Log Message:
-----------
[Clang] Add warnings when mixing different charN_t types (#138708)
charN_t represent code units of different UTF encodings. Therefore the
values of 2 different charN_t objects do not represent the same
characters.
In order to avoid comparing apples and oranges, we add new warnings to
warn on:
- Implicit conversions
- Comparisons
- Other cases involving arithmetic conversions
We only produce the warning if we cannot establish the comparison would
be safe through constant evaluation.
The new `-Wimplicit-unicode-conversion` warning is enabled by default.
Note that this PR intentionally doesn;t touches char/wchar_t, but it
would be worth considering also warning on extending the new warnings to
these types (in a follow up)
Additionally most arithmetic operations on charN_t don't really make
sense (ie what does it mean to addition code units), so we could add
warnings for that.
Fixes #138526
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list