aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/AST/FormatString.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-12-18 20:30:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-04-19 21:12:03 +0000
commitc9157d925c489f07ba9c0b2ce47e5149b75969a5 (patch)
tree08bc4a3d9cad3f9ebffa558ddf140b9d9257b219 /contrib/llvm-project/clang/lib/AST/FormatString.cpp
parent2a66844f606a35d68ad8a8061f4bea204274b3bc (diff)
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/FormatString.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/AST/FormatString.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/FormatString.cpp b/contrib/llvm-project/clang/lib/AST/FormatString.cpp
index ad5af9508983..e0c9e18cfe3a 100644
--- a/contrib/llvm-project/clang/lib/AST/FormatString.cpp
+++ b/contrib/llvm-project/clang/lib/AST/FormatString.cpp
@@ -368,8 +368,11 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const {
case BuiltinType::SChar:
case BuiltinType::UChar:
case BuiltinType::Char_U:
+ return Match;
case BuiltinType::Bool:
- return Match;
+ if (!Ptr)
+ return Match;
+ break;
}
// "Partially matched" because of promotions?
if (!Ptr) {
@@ -410,11 +413,14 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const {
switch (BT->getKind()) {
default:
break;
+ case BuiltinType::Bool:
+ if (Ptr && (T == C.UnsignedCharTy || T == C.SignedCharTy))
+ return NoMatch;
+ [[fallthrough]];
case BuiltinType::Char_S:
case BuiltinType::SChar:
case BuiltinType::Char_U:
case BuiltinType::UChar:
- case BuiltinType::Bool:
if (T == C.UnsignedShortTy || T == C.ShortTy)
return NoMatchTypeConfusion;
if (T == C.UnsignedCharTy || T == C.SignedCharTy)
@@ -458,6 +464,10 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const {
switch (BT->getKind()) {
default:
break;
+ case BuiltinType::Bool:
+ if (T == C.IntTy || T == C.UnsignedIntTy)
+ return MatchPromotion;
+ break;
case BuiltinType::Int:
case BuiltinType::UInt:
if (T == C.SignedCharTy || T == C.UnsignedCharTy ||
@@ -465,6 +475,24 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const {
T == C.WideCharTy)
return MatchPromotion;
break;
+ case BuiltinType::Char_U:
+ if (T == C.UnsignedIntTy)
+ return MatchPromotion;
+ if (T == C.UnsignedShortTy)
+ return NoMatchPromotionTypeConfusion;
+ break;
+ case BuiltinType::Char_S:
+ if (T == C.IntTy)
+ return MatchPromotion;
+ if (T == C.ShortTy)
+ return NoMatchPromotionTypeConfusion;
+ break;
+ case BuiltinType::Half:
+ case BuiltinType::Float16:
+ case BuiltinType::Float:
+ if (T == C.DoubleTy)
+ return MatchPromotion;
+ break;
case BuiltinType::Short:
case BuiltinType::UShort:
if (T == C.SignedCharTy || T == C.UnsignedCharTy)