17#include "llvm/Support/ConvertUTF.h"
41 unsigned accumulator = 0;
42 bool hasDigits =
false;
46 if (
c >=
'0' &&
c <=
'9') {
48 accumulator = (accumulator * 10) + (
c -
'0');
63 const char *&Beg,
const char *E,
unsigned &argIndex) {
76 const char *I = Beg + 1;
101 const char *Tmp = Beg;
117 const char *&Beg,
const char *E,
unsigned *argIndex) {
176 const char *Start = I;
203 const char *lmPosition = I;
209 if (I != E && *I ==
'h') {
212 }
else if (I != E && *I ==
'l' && LO.OpenCL) {
221 if (I != E && *I ==
'l') {
249 if (IsScanf && !LO.C99 && !LO.CPlusPlus11) {
254 if (I != E && (*I ==
's' || *I ==
'S' || *I ==
'[')) {
271 if (I + 1 != E && I + 2 != E) {
272 if (I[1] ==
'6' && I[2] ==
'4') {
280 if (I[1] ==
'3' && I[2] ==
'2') {
300 const char *SpecifierBegin,
const char *FmtStrEnd,
unsigned &Len) {
301 if (SpecifierBegin + 1 >= FmtStrEnd)
304 const llvm::UTF8 *SB =
305 reinterpret_cast<const llvm::UTF8 *
>(SpecifierBegin + 1);
306 const llvm::UTF8 *SE =
reinterpret_cast<const llvm::UTF8 *
>(FmtStrEnd);
307 const char FirstByte = *SB;
312 unsigned NumBytes = llvm::getNumBytesForUTF8(FirstByte);
315 if (SB + NumBytes > SE)
331 const auto *TD = TT->getDecl();
332 const auto *DC = TT->getDecl()->getDeclContext();
333 if (DC->isTranslationUnit() || DC->isStdNamespace()) {
334 StringRef Name = TD->getIdentifier()->getName();
335 if (Name ==
"size_t") {
338 }
else if (Name ==
"ssize_t" ) {
341 }
else if (Name ==
"ptrdiff_t") {
344 }
else if (Name ==
"intmax_t") {
347 }
else if (Name ==
"uintmax_t") {
355 switch (PST->getKind()) {
357 case Kind::SignedSizeT:
364 llvm_unreachable(
"unexpected kind");
377 if (!T->isIntegerType() || T->isBooleanType())
378 return MatchKind::NoMatch;
380 if (
C.hasSameType(T, E))
381 return MatchKind::Match;
383 if (
C.getCorrespondingSignedType(T.getCanonicalType()) !=
385 return MatchKind::NoMatch;
387 return MatchKind::NoMatchSignedness;
396 argTy =
C.getDecayedType(argTy);
411 if (
const auto *OBT = argTy->
getAs<OverflowBehaviorType>())
412 argTy = OBT->getUnderlyingType();
416 llvm_unreachable(
"ArgType must be valid");
426 if (!ED->isComplete())
429 argTy = ED->getIntegerType();
434 switch (BT->getKind()) {
437 case BuiltinType::Char_S:
438 case BuiltinType::SChar:
439 case BuiltinType::UChar:
440 case BuiltinType::Char_U:
442 case BuiltinType::Bool:
449 switch (BT->getKind()) {
452 case BuiltinType::Int:
453 case BuiltinType::UInt:
455 case BuiltinType::Short:
456 case BuiltinType::UShort:
457 case BuiltinType::WChar_S:
458 case BuiltinType::WChar_U:
467 if (TK != TypeKind::DontCare) {
475 if (!ED->isComplete())
477 else if (!ED->isScoped())
478 argTy = ED->getIntegerType();
482 argTy =
C.getCorrespondingUnsaturatedType(argTy);
484 argTy =
C.getCanonicalType(argTy).getUnqualifiedType();
491 switch (BT->getKind()) {
494 case BuiltinType::Bool:
495 if (Ptr && (T ==
C.UnsignedCharTy || T ==
C.SignedCharTy))
498 case BuiltinType::Char_S:
499 case BuiltinType::SChar:
500 if (T ==
C.UnsignedShortTy || T ==
C.ShortTy)
502 if (T ==
C.UnsignedCharTy)
504 if (T ==
C.SignedCharTy)
507 case BuiltinType::Char_U:
508 case BuiltinType::UChar:
509 if (T ==
C.UnsignedShortTy || T ==
C.ShortTy)
511 if (T ==
C.UnsignedCharTy)
513 if (T ==
C.SignedCharTy)
516 case BuiltinType::Short:
517 if (T ==
C.UnsignedShortTy)
520 case BuiltinType::UShort:
524 case BuiltinType::Int:
525 if (T ==
C.UnsignedIntTy)
528 case BuiltinType::UInt:
532 case BuiltinType::Long:
533 if (T ==
C.UnsignedLongTy)
536 case BuiltinType::ULong:
540 case BuiltinType::LongLong:
541 if (T ==
C.UnsignedLongLongTy)
544 case BuiltinType::ULongLong:
545 if (T ==
C.LongLongTy)
551 switch (BT->getKind()) {
554 case BuiltinType::Bool:
555 if (T ==
C.IntTy || T ==
C.UnsignedIntTy)
558 case BuiltinType::Int:
559 case BuiltinType::UInt:
560 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy || T ==
C.ShortTy ||
561 T ==
C.UnsignedShortTy || T ==
C.WCharTy || T ==
C.WideCharTy)
564 case BuiltinType::Char_U:
565 if (T ==
C.UnsignedIntTy)
567 if (T ==
C.UnsignedShortTy)
570 case BuiltinType::Char_S:
576 case BuiltinType::Half:
577 case BuiltinType::Float:
581 case BuiltinType::Short:
582 case BuiltinType::UShort:
583 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy)
586 case BuiltinType::WChar_U:
587 case BuiltinType::WChar_S:
588 if (T !=
C.WCharTy && T !=
C.WideCharTy)
605 C.hasSameUnqualifiedType(PT->getPointeeType(),
C.getWideCharType()))
610 QualType WInt =
C.getCanonicalType(
C.getWIntType()).getUnqualifiedType();
612 if (
C.getCanonicalType(argTy).getUnqualifiedType() == WInt)
615 QualType PromoArg =
C.isPromotableIntegerType(argTy)
616 ?
C.getPromotedIntegerType(argTy)
618 PromoArg =
C.getCanonicalType(PromoArg).getUnqualifiedType();
623 C.getCorrespondingUnsignedType(PromoArg) == WInt)
668 llvm_unreachable(
"Invalid ArgType Kind!");
675 uint64_t IntSize =
C.getTypeSize(
C.IntTy);
676 uint64_t ASize =
C.getTypeSize(A);
677 uint64_t BSize =
C.getTypeSize(B);
678 if (std::max(ASize, IntSize) != std::max(BSize, IntSize))
681 return MK::NoMatchSignedness;
683 return MK::MatchPromotion;
692 if (K == AK::InvalidTy ||
Other.K == AK::InvalidTy)
694 if (K == AK::UnknownTy ||
Other.K == AK::UnknownTy)
701 bool LeftWasPointer =
false;
703 bool RightWasPointer =
false;
706 LeftWasPointer =
true;
707 }
else if (Left.K == AK::SpecificTy && Left.T->isPointerType()) {
708 Left.T = Left.T->getPointeeType();
709 LeftWasPointer =
true;
713 RightWasPointer =
true;
714 }
else if (Right.K == AK::SpecificTy && Right.T->isPointerType()) {
715 Right.T = Right.T->getPointeeType();
716 RightWasPointer =
true;
719 if (LeftWasPointer != RightWasPointer)
724 if (Right.K == AK::SpecificTy)
725 std::swap(Left, Right);
727 if (Left.K == AK::SpecificTy) {
728 if (Right.K == AK::SpecificTy) {
729 if (Left.TK != TypeKind::DontCare) {
731 }
else if (Right.TK != TypeKind::DontCare) {
735 auto Canon1 =
C.getCanonicalType(Left.T);
736 auto Canon2 =
C.getCanonicalType(Right.T);
737 if (Canon1 == Canon2)
742 if (BT1 ==
nullptr || BT2 ==
nullptr)
747 if (!LeftWasPointer && BT1->isInteger() && BT2->
isInteger())
750 }
else if (Right.K == AK::AnyCharTy) {
751 if (!LeftWasPointer && Left.T->isIntegerType())
754 }
else if (Right.K == AK::WIntTy) {
755 if (!LeftWasPointer && Left.T->isIntegerType())
773 QualType Vec =
C.getExtVectorType(T, NumElts);
781 llvm_unreachable(
"No representative type for Invalid ArgType");
783 llvm_unreachable(
"No representative type for Unknown ArgType");
788 if (TK == TypeKind::PtrdiffT || TK == TypeKind::SizeT)
795 Res =
C.getPointerType(
C.CharTy);
798 Res =
C.getPointerType(
C.getWideCharType());
801 Res =
C.ObjCBuiltinIdTy;
807 Res =
C.getWIntType();
813 Res =
C.getPointerType(Res);
825 Alias += (Alias[Alias.size() - 1] ==
'*') ?
"*" :
" *";
833 return std::string(
"'") + Alias +
"' (aka '" + S +
"')";
834 return std::string(
"'") + S +
"'";
992std::optional<ConversionSpecifier>
1042 switch (
LM.getKind()) {
1049 if (LO.OpenCL &&
CS.isDoubleArg())
1052 if (
CS.isFixedPointArg())
1055 if (
Target.getTriple().isOSMSVCRT()) {
1056 switch (
CS.getKind()) {
1074 switch (
CS.getKind()) {
1090 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
1100 if (
CS.isDoubleArg()) {
1107 if (
CS.isFixedPointArg())
1110 switch (
CS.getKind()) {
1130 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
1136 switch (
CS.getKind()) {
1153 return !
Target.getTriple().isOSDarwin() &&
1154 !
Target.getTriple().isOSWindows();
1160 switch (
CS.getKind()) {
1170 switch (
CS.getKind()) {
1183 switch (
CS.getKind()) {
1190 return Target.getTriple().isOSMSVCRT();
1195 switch (
CS.getKind()) {
1201 return Target.getTriple().isOSMSVCRT();
1206 llvm_unreachable(
"Invalid LengthModifier Kind!");
1210 switch (
LM.getKind()) {
1231 llvm_unreachable(
"Invalid LengthModifier Kind!");
1236 switch (
CS.getKind()) {
1264 return LangOpt.ObjC;
1280 return LangOpt.FixedPoint;
1282 llvm_unreachable(
"Invalid ConversionSpecifier Kind!");
1287 switch (
CS.getKind()) {
1302std::optional<LengthModifier>
1313 return std::nullopt;
Defines the clang::LangOptions interface.
__device__ __2f16 float c
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
This class is used for builtin types like 'int'.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents a pointer to an Objective C object.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
QualType getCanonicalType() const
bool isConstQualified() const
Determine whether this type is const-qualified.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Exposes information about the current target.
bool isStructureType() const
bool isBlockPointerType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
QualType getCanonicalTypeInternal() const
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isObjCObjectPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
@ Other
Other implicit parameter.