17#include "llvm/Support/ConvertUTF.h"
39 UpdateOnReturn <const char*> UpdateBeg(Beg, I);
41 unsigned accumulator = 0;
42 bool hasDigits =
false;
44 for ( ; I != E; ++I) {
46 if (
c >=
'0' &&
c <=
'9') {
48 accumulator = (accumulator * 10) + (
c -
'0');
81 const char *I = Beg + 1;
106 const char *Tmp = Beg;
125 const char *&Beg,
const char *E,
126 unsigned *argIndex) {
189 const char *Start = I;
217 const char *lmPosition = I;
223 if (I != E && *I ==
'h') {
226 }
else if (I != E && *I ==
'l' && LO.OpenCL) {
235 if (I != E && *I ==
'l') {
248 if (IsScanf && !LO.C99 && !LO.CPlusPlus11) {
253 if (I != E && (*I ==
's' || *I ==
'S' || *I ==
'[')) {
270 if (I + 1 != E && I + 2 != E) {
271 if (I[1] ==
'6' && I[2] ==
'4') {
279 if (I[1] ==
'3' && I[2] ==
'2') {
297 const char *SpecifierBegin,
const char *FmtStrEnd,
unsigned &Len) {
298 if (SpecifierBegin + 1 >= FmtStrEnd)
301 const llvm::UTF8 *SB =
302 reinterpret_cast<const llvm::UTF8 *
>(SpecifierBegin + 1);
303 const llvm::UTF8 *SE =
reinterpret_cast<const llvm::UTF8 *
>(FmtStrEnd);
304 const char FirstByte = *SB;
309 unsigned NumBytes = llvm::getNumBytesForUTF8(FirstByte);
312 if (SB + NumBytes > SE)
328 const auto *TD = TT->getDecl();
329 const auto *DC = TT->getDecl()->getDeclContext();
330 if (DC->isTranslationUnit() || DC->isStdNamespace()) {
331 StringRef Name = TD->getIdentifier()->getName();
332 if (Name ==
"size_t") {
335 }
else if (Name ==
"ssize_t" ) {
338 }
else if (Name ==
"ptrdiff_t") {
341 }
else if (Name ==
"intmax_t") {
344 }
else if (Name ==
"uintmax_t") {
352 switch (PST->getKind()) {
354 case Kind::SignedSizeT:
361 llvm_unreachable(
"unexpected kind");
374 if (!T->isIntegerType() || T->isBooleanType())
375 return MatchKind::NoMatch;
377 if (
C.hasSameType(T, E))
378 return MatchKind::Match;
380 if (
C.getCorrespondingSignedType(T.getCanonicalType()) !=
382 return MatchKind::NoMatch;
384 return MatchKind::NoMatchSignedness;
393 argTy =
C.getDecayedType(argTy);
408 if (
const auto *OBT = argTy->
getAs<OverflowBehaviorType>())
409 argTy = OBT->getUnderlyingType();
413 llvm_unreachable(
"ArgType must be valid");
423 if (!ED->isComplete())
426 argTy = ED->getIntegerType();
431 switch (BT->getKind()) {
434 case BuiltinType::Char_S:
435 case BuiltinType::SChar:
436 case BuiltinType::UChar:
437 case BuiltinType::Char_U:
439 case BuiltinType::Bool:
446 switch (BT->getKind()) {
449 case BuiltinType::Int:
450 case BuiltinType::UInt:
452 case BuiltinType::Short:
453 case BuiltinType::UShort:
454 case BuiltinType::WChar_S:
455 case BuiltinType::WChar_U:
464 if (TK != TypeKind::DontCare) {
472 if (!ED->isComplete())
474 else if (!ED->isScoped())
475 argTy = ED->getIntegerType();
479 argTy =
C.getCorrespondingUnsaturatedType(argTy);
481 argTy =
C.getCanonicalType(argTy).getUnqualifiedType();
488 switch (BT->getKind()) {
491 case BuiltinType::Bool:
492 if (Ptr && (T ==
C.UnsignedCharTy || T ==
C.SignedCharTy))
495 case BuiltinType::Char_S:
496 case BuiltinType::SChar:
497 if (T ==
C.UnsignedShortTy || T ==
C.ShortTy)
499 if (T ==
C.UnsignedCharTy)
501 if (T ==
C.SignedCharTy)
504 case BuiltinType::Char_U:
505 case BuiltinType::UChar:
506 if (T ==
C.UnsignedShortTy || T ==
C.ShortTy)
508 if (T ==
C.UnsignedCharTy)
510 if (T ==
C.SignedCharTy)
513 case BuiltinType::Short:
514 if (T ==
C.UnsignedShortTy)
517 case BuiltinType::UShort:
521 case BuiltinType::Int:
522 if (T ==
C.UnsignedIntTy)
525 case BuiltinType::UInt:
529 case BuiltinType::Long:
530 if (T ==
C.UnsignedLongTy)
533 case BuiltinType::ULong:
537 case BuiltinType::LongLong:
538 if (T ==
C.UnsignedLongLongTy)
541 case BuiltinType::ULongLong:
542 if (T ==
C.LongLongTy)
548 switch (BT->getKind()) {
551 case BuiltinType::Bool:
552 if (T ==
C.IntTy || T ==
C.UnsignedIntTy)
555 case BuiltinType::Int:
556 case BuiltinType::UInt:
557 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy ||
558 T ==
C.ShortTy || T ==
C.UnsignedShortTy || T ==
C.WCharTy ||
562 case BuiltinType::Char_U:
563 if (T ==
C.UnsignedIntTy)
565 if (T ==
C.UnsignedShortTy)
568 case BuiltinType::Char_S:
574 case BuiltinType::Half:
575 case BuiltinType::Float:
579 case BuiltinType::Short:
580 case BuiltinType::UShort:
581 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy)
584 case BuiltinType::WChar_U:
585 case BuiltinType::WChar_S:
586 if (T !=
C.WCharTy && T !=
C.WideCharTy)
603 C.hasSameUnqualifiedType(PT->getPointeeType(),
C.getWideCharType()))
608 QualType WInt =
C.getCanonicalType(
C.getWIntType()).getUnqualifiedType();
610 if (
C.getCanonicalType(argTy).getUnqualifiedType() == WInt)
613 QualType PromoArg =
C.isPromotableIntegerType(argTy)
614 ?
C.getPromotedIntegerType(argTy)
616 PromoArg =
C.getCanonicalType(PromoArg).getUnqualifiedType();
621 C.getCorrespondingUnsignedType(PromoArg) == WInt)
666 llvm_unreachable(
"Invalid ArgType Kind!");
673 uint64_t IntSize =
C.getTypeSize(
C.IntTy);
674 uint64_t ASize =
C.getTypeSize(A);
675 uint64_t BSize =
C.getTypeSize(B);
676 if (std::max(ASize, IntSize) != std::max(BSize, IntSize))
679 return MK::NoMatchSignedness;
681 return MK::MatchPromotion;
690 if (K == AK::InvalidTy ||
Other.K == AK::InvalidTy)
692 if (K == AK::UnknownTy ||
Other.K == AK::UnknownTy)
699 bool LeftWasPointer =
false;
701 bool RightWasPointer =
false;
704 LeftWasPointer =
true;
705 }
else if (Left.K == AK::SpecificTy && Left.T->isPointerType()) {
706 Left.T = Left.T->getPointeeType();
707 LeftWasPointer =
true;
711 RightWasPointer =
true;
712 }
else if (Right.K == AK::SpecificTy && Right.T->isPointerType()) {
713 Right.T = Right.T->getPointeeType();
714 RightWasPointer =
true;
717 if (LeftWasPointer != RightWasPointer)
722 if (Right.K == AK::SpecificTy)
723 std::swap(Left, Right);
725 if (Left.K == AK::SpecificTy) {
726 if (Right.K == AK::SpecificTy) {
727 if (Left.TK != TypeKind::DontCare) {
729 }
else if (Right.TK != TypeKind::DontCare) {
733 auto Canon1 =
C.getCanonicalType(Left.T);
734 auto Canon2 =
C.getCanonicalType(Right.T);
735 if (Canon1 == Canon2)
740 if (BT1 ==
nullptr || BT2 ==
nullptr)
745 if (!LeftWasPointer && BT1->isInteger() && BT2->
isInteger())
748 }
else if (Right.K == AK::AnyCharTy) {
749 if (!LeftWasPointer && Left.T->isIntegerType())
752 }
else if (Right.K == AK::WIntTy) {
753 if (!LeftWasPointer && Left.T->isIntegerType())
771 QualType Vec =
C.getExtVectorType(T, NumElts);
779 llvm_unreachable(
"No representative type for Invalid ArgType");
781 llvm_unreachable(
"No representative type for Unknown ArgType");
786 if (TK == TypeKind::PtrdiffT || TK == TypeKind::SizeT)
793 Res =
C.getPointerType(
C.CharTy);
796 Res =
C.getPointerType(
C.getWideCharType());
799 Res =
C.ObjCBuiltinIdTy;
805 Res =
C.getWIntType();
811 Res =
C.getPointerType(Res);
823 Alias += (Alias[Alias.size()-1] ==
'*') ?
"*" :
" *";
831 return std::string(
"'") + Alias +
"' (aka '" + S +
"')";
832 return std::string(
"'") + S +
"'";
896 case bArg:
return "b";
897 case BArg:
return "B";
898 case dArg:
return "d";
899 case DArg:
return "D";
900 case iArg:
return "i";
901 case oArg:
return "o";
902 case OArg:
return "O";
903 case uArg:
return "u";
904 case UArg:
return "U";
905 case xArg:
return "x";
906 case XArg:
return "X";
907 case fArg:
return "f";
908 case FArg:
return "F";
909 case eArg:
return "e";
910 case EArg:
return "E";
911 case gArg:
return "g";
912 case GArg:
return "G";
913 case aArg:
return "a";
914 case AArg:
return "A";
915 case cArg:
return "c";
916 case sArg:
return "s";
917 case pArg:
return "p";
920 case nArg:
return "n";
926 case CArg:
return "C";
927 case SArg:
return "S";
942 case ZArg:
return "Z";
957std::optional<ConversionSpecifier>
1007 switch (
LM.getKind()) {
1014 if (LO.OpenCL &&
CS.isDoubleArg())
1017 if (
CS.isFixedPointArg())
1020 if (
Target.getTriple().isOSMSVCRT()) {
1021 switch (
CS.getKind()) {
1039 switch (
CS.getKind()) {
1055 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
1065 if (
CS.isDoubleArg()) {
1072 if (
CS.isFixedPointArg())
1075 switch (
CS.getKind()) {
1095 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
1101 switch (
CS.getKind()) {
1118 return !
Target.getTriple().isOSDarwin() &&
1119 !
Target.getTriple().isOSWindows();
1125 switch (
CS.getKind()) {
1135 switch (
CS.getKind()) {
1148 switch (
CS.getKind()) {
1155 return Target.getTriple().isOSMSVCRT();
1160 switch (
CS.getKind()) {
1166 return Target.getTriple().isOSMSVCRT();
1171 llvm_unreachable(
"Invalid LengthModifier Kind!");
1175 switch (
LM.getKind()) {
1196 llvm_unreachable(
"Invalid LengthModifier Kind!");
1201 switch (
CS.getKind()) {
1229 return LangOpt.ObjC;
1245 return LangOpt.FixedPoint;
1247 llvm_unreachable(
"Invalid ConversionSpecifier Kind!");
1252 switch(
CS.getKind()) {
1267std::optional<LengthModifier>
1278 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.