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");
355 if (!ETy->getDecl()->isComplete())
357 argTy = ETy->getDecl()->getIntegerType();
362 switch (BT->getKind()) {
365 case BuiltinType::Char_S:
366 case BuiltinType::SChar:
367 case BuiltinType::UChar:
368 case BuiltinType::Char_U:
369 case BuiltinType::Bool:
374 switch (BT->getKind()) {
377 case BuiltinType::Int:
378 case BuiltinType::UInt:
380 case BuiltinType::Short:
381 case BuiltinType::UShort:
382 case BuiltinType::WChar_S:
383 case BuiltinType::WChar_U:
395 if (!ETy->getDecl()->isComplete())
398 argTy = ETy->getDecl()->getIntegerType();
400 argTy =
C.getCanonicalType(argTy).getUnqualifiedType();
407 switch (BT->getKind()) {
410 case BuiltinType::Char_S:
411 case BuiltinType::SChar:
412 case BuiltinType::Char_U:
413 case BuiltinType::UChar:
414 case BuiltinType::Bool:
415 if (T ==
C.UnsignedShortTy || T ==
C.ShortTy)
417 if (T ==
C.UnsignedCharTy || T ==
C.SignedCharTy)
420 case BuiltinType::Short:
421 if (T ==
C.UnsignedShortTy)
424 case BuiltinType::UShort:
428 case BuiltinType::Int:
429 if (T ==
C.UnsignedIntTy)
432 case BuiltinType::UInt:
436 case BuiltinType::Long:
437 if (T ==
C.UnsignedLongTy)
440 case BuiltinType::ULong:
444 case BuiltinType::LongLong:
445 if (T ==
C.UnsignedLongLongTy)
448 case BuiltinType::ULongLong:
449 if (T ==
C.LongLongTy)
455 switch (BT->getKind()) {
458 case BuiltinType::Int:
459 case BuiltinType::UInt:
460 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy ||
461 T ==
C.ShortTy || T ==
C.UnsignedShortTy || T ==
C.WCharTy ||
465 case BuiltinType::Short:
466 case BuiltinType::UShort:
467 if (T ==
C.SignedCharTy || T ==
C.UnsignedCharTy)
470 case BuiltinType::WChar_U:
471 case BuiltinType::WChar_S:
472 if (T !=
C.WCharTy && T !=
C.WideCharTy)
486 switch (BT->getKind()) {
487 case BuiltinType::Char_U:
488 case BuiltinType::UChar:
489 case BuiltinType::Char_S:
490 case BuiltinType::SChar:
509 QualType WInt =
C.getCanonicalType(
C.getWIntType()).getUnqualifiedType();
511 if (
C.getCanonicalType(argTy).getUnqualifiedType() == WInt)
514 QualType PromoArg =
C.isPromotableIntegerType(argTy)
515 ?
C.getPromotedIntegerType(argTy)
517 PromoArg =
C.getCanonicalType(PromoArg).getUnqualifiedType();
522 C.getCorrespondingUnsignedType(PromoArg) == WInt)
557 llvm_unreachable(
"Invalid ArgType Kind!");
565 QualType Vec =
C.getExtVectorType(T, NumElts);
573 llvm_unreachable(
"No representative type for Invalid ArgType");
575 llvm_unreachable(
"No representative type for Unknown ArgType");
583 Res =
C.getPointerType(
C.CharTy);
586 Res =
C.getPointerType(
C.getWideCharType());
589 Res =
C.ObjCBuiltinIdTy;
595 Res =
C.getWIntType();
601 Res =
C.getPointerType(Res);
614 Alias += (Alias[Alias.size()-1] ==
'*') ?
"*" :
" *";
622 return std::string(
"'") + Alias +
"' (aka '" + S +
"')";
623 return std::string(
"'") + S +
"'";
687 case bArg:
return "b";
688 case BArg:
return "B";
689 case dArg:
return "d";
690 case DArg:
return "D";
691 case iArg:
return "i";
692 case oArg:
return "o";
693 case OArg:
return "O";
694 case uArg:
return "u";
695 case UArg:
return "U";
696 case xArg:
return "x";
697 case XArg:
return "X";
698 case fArg:
return "f";
699 case FArg:
return "F";
700 case eArg:
return "e";
701 case EArg:
return "E";
702 case gArg:
return "g";
703 case GArg:
return "G";
704 case aArg:
return "a";
705 case AArg:
return "A";
706 case cArg:
return "c";
707 case sArg:
return "s";
708 case pArg:
return "p";
711 case nArg:
return "n";
717 case CArg:
return "C";
718 case SArg:
return "S";
733 case ZArg:
return "Z";
738std::optional<ConversionSpecifier>
798 if (
Target.getTriple().isOSMSVCRT()) {
833 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
868 return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS();
891 return !
Target.getTriple().isOSDarwin() &&
892 !
Target.getTriple().isOSWindows();
928 return Target.getTriple().isOSMSVCRT();
939 return Target.getTriple().isOSMSVCRT();
944 llvm_unreachable(
"Invalid LengthModifier Kind!");
969 llvm_unreachable(
"Invalid LengthModifier Kind!");
1002 return LangOpt.ObjC;
1015 llvm_unreachable(
"Invalid ConversionSpecifier Kind!");
1035std::optional<LengthModifier>
1046 return std::nullopt;
1052 QT = TT->getDecl()->getUnderlyingType()) {
1058 }
else if (
Identifier->getName() ==
"ssize_t") {
1062 }
else if (
Identifier->getName() ==
"intmax_t") {
1065 }
else if (
Identifier->getName() ==
"uintmax_t") {
1068 }
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.