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) {
170 FS.setUsesPositionalArg();
189 const char *Start = I;
204 FS.setVectorNumElts(NumElts);
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') {
292 FS.setLengthModifier(lm);
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)
329 argTy =
C.getDecayedType(argTy);
346 llvm_unreachable(
"ArgType must be valid");
356 if (!ETy->getDecl()->isComplete())
358 if (ETy->isUnscopedEnumerationType())
359 argTy = ETy->getDecl()->getIntegerType();
364 switch (BT->getKind()) {
367 case BuiltinType::Char_S:
368 case BuiltinType::SChar:
369 case BuiltinType::UChar:
370 case BuiltinType::Char_U:
372 case BuiltinType::Bool:
379 switch (BT->getKind()) {
382 case BuiltinType::Int:
383 case BuiltinType::UInt:
385 case BuiltinType::Short:
386 case BuiltinType::UShort:
387 case BuiltinType::WChar_S:
388 case BuiltinType::WChar_U:
401 if (!ETy->getDecl()->isComplete())
403 else if (ETy->isUnscopedEnumerationType())
404 argTy = ETy->getDecl()->getIntegerType();
406 argTy =
C.getCanonicalType(argTy).getUnqualifiedType();
413 switch (BT->getKind()) {
416 case BuiltinType::Bool:
417 if (Ptr && (T ==
C.UnsignedCharTy || T ==
C.SignedCharTy))
420 case BuiltinType::Char_S:
421 case BuiltinType::SChar:
422 case BuiltinType::Char_U:
423 case BuiltinType::UChar:
424 if (T ==
C.UnsignedShortTy || T ==
C.ShortTy)
426 if (T ==
C.UnsignedCharTy || T ==
C.SignedCharTy)
429 case BuiltinType::Short:
430 if (T ==
C.UnsignedShortTy)
433 case BuiltinType::UShort:
437 case BuiltinType::Int:
438 if (T ==
C.UnsignedIntTy)
441 case BuiltinType::UInt:
445 case BuiltinType::Long:
446 if (T ==
C.UnsignedLongTy)
449 case BuiltinType::ULong:
453 case BuiltinType::LongLong:
454 if (T ==
C.UnsignedLongLongTy)
457 case BuiltinType::ULongLong:
458 if (T ==
C.LongLongTy)
464 switch (BT->getKind()) {
467 case BuiltinType::Bool:
468 if (T ==
C.IntTy || T ==
C.UnsignedIntTy)
471 case BuiltinType::Int:
472 case BuiltinType::UInt:
473 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy ||
474 T ==
C.ShortTy || T ==
C.UnsignedShortTy || T ==
C.WCharTy ||
478 case BuiltinType::Char_U:
479 if (T ==
C.UnsignedIntTy)
481 if (T ==
C.UnsignedShortTy)
484 case BuiltinType::Char_S:
490 case BuiltinType::Half:
491 case BuiltinType::Float16:
492 case BuiltinType::Float:
496 case BuiltinType::Short:
497 case BuiltinType::UShort:
498 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy)
501 case BuiltinType::WChar_U:
502 case BuiltinType::WChar_S:
503 if (T !=
C.WCharTy && T !=
C.WideCharTy)
517 switch (BT->getKind()) {
518 case BuiltinType::Char_U:
519 case BuiltinType::UChar:
520 case BuiltinType::Char_S:
521 case BuiltinType::SChar:
540 QualType WInt =
C.getCanonicalType(
C.getWIntType()).getUnqualifiedType();
542 if (
C.getCanonicalType(argTy).getUnqualifiedType() == WInt)
545 QualType PromoArg =
C.isPromotableIntegerType(argTy)
546 ?
C.getPromotedIntegerType(argTy)
548 PromoArg =
C.getCanonicalType(PromoArg).getUnqualifiedType();
553 C.getCorrespondingUnsignedType(PromoArg) == WInt)
588 llvm_unreachable(
"Invalid ArgType Kind!");
596 QualType Vec =
C.getExtVectorType(T, NumElts);
604 llvm_unreachable(
"No representative type for Invalid ArgType");
606 llvm_unreachable(
"No representative type for Unknown ArgType");
614 Res =
C.getPointerType(
C.CharTy);
617 Res =
C.getPointerType(
C.getWideCharType());
620 Res =
C.ObjCBuiltinIdTy;
626 Res =
C.getWIntType();
632 Res =
C.getPointerType(Res);
645 Alias += (Alias[Alias.size()-1] ==
'*') ?
"*" :
" *";
653 return std::string(
"'") + Alias +
"' (aka '" + S +
"')";
654 return std::string(
"'") + S +
"'";
718 case bArg:
return "b";
719 case BArg:
return "B";
720 case dArg:
return "d";
721 case DArg:
return "D";
722 case iArg:
return "i";
723 case oArg:
return "o";
724 case OArg:
return "O";
725 case uArg:
return "u";
726 case UArg:
return "U";
727 case xArg:
return "x";
728 case XArg:
return "X";
729 case fArg:
return "f";
730 case FArg:
return "F";
731 case eArg:
return "e";
732 case EArg:
return "E";
733 case gArg:
return "g";
734 case GArg:
return "G";
735 case aArg:
return "a";
736 case AArg:
return "A";
737 case cArg:
return "c";
738 case sArg:
return "s";
739 case pArg:
return "p";
742 case nArg:
return "n";
748 case CArg:
return "C";
749 case SArg:
return "S";
764 case ZArg:
return "Z";
769std::optional<ConversionSpecifier>
829 if (
Target.getTriple().isOSMSVCRT()) {
864 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
901 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
924 return !
Target.getTriple().isOSDarwin() &&
925 !
Target.getTriple().isOSWindows();
961 return Target.getTriple().isOSMSVCRT();
972 return Target.getTriple().isOSMSVCRT();
977 llvm_unreachable(
"Invalid LengthModifier Kind!");
1002 llvm_unreachable(
"Invalid LengthModifier Kind!");
1035 return LangOpt.ObjC;
1048 llvm_unreachable(
"Invalid ConversionSpecifier Kind!");
1068std::optional<LengthModifier>
1079 return std::nullopt;
1085 QT = TT->getDecl()->getUnderlyingType()) {
1091 }
else if (
Identifier->getName() ==
"ssize_t") {
1095 }
else if (
Identifier->getName() ==
"intmax_t") {
1098 }
else if (
Identifier->getName() ==
"uintmax_t") {
1101 }
else if (
Identifier->getName() ==
"ptrdiff_t") {
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 ...
This class is used for builtin types like 'int'.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a pointer to an Objective C object.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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 isBlockPointerType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool isVoidPointerType() const
bool isPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
const RecordType * getAsStructureType() const
bool isObjCObjectPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
Base class for declarations which introduce a typedef-name.
Defines the clang::TargetInfo interface.
@ C
Languages that the frontend can parse and compile.
@ None
The alignment was not explicit in code.