Go to the documentation of this file.
13 #include "llvm/ADT/StringSwitch.h"
15 using namespace clang;
18 : Ctx(ctx), ClassIds(), BOOLId(nullptr), NSIntegerId(nullptr),
19 NSUIntegerId(nullptr), NSASCIIStringEncodingId(nullptr),
20 NSUTF8StringEncodingId(nullptr) {}
29 "NSMutableDictionary",
32 "NSMutableOrderedSet",
37 return (ClassIds[K] = &Ctx.
Idents.
get(ClassName[K]));
43 if (NSStringSelectors[MK].isNull()) {
72 return (NSStringSelectors[MK] = Sel);
75 return NSStringSelectors[MK];
79 if (NSArraySelectors[MK].isNull()) {
139 return (NSArraySelectors[MK] = Sel);
142 return NSArraySelectors[MK];
157 if (NSDictionarySelectors[MK].isNull()) {
165 &Ctx.
Idents.
get(
"dictionaryWithDictionary"));
177 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
185 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
194 &Ctx.
Idents.
get(
"dictionaryWithObjectsAndKeys"));
202 &Ctx.
Idents.
get(
"initWithObjectsAndKeys"));
240 return (NSDictionarySelectors[MK] = Sel);
243 return NSDictionarySelectors[MK];
258 if (NSSetSelectors[MK].isNull()) {
297 return (NSSetSelectors[MK] = Sel);
300 return NSSetSelectors[MK];
315 bool Instance)
const {
318 "numberWithUnsignedChar",
320 "numberWithUnsignedShort",
322 "numberWithUnsignedInt",
324 "numberWithUnsignedLong",
325 "numberWithLongLong",
326 "numberWithUnsignedLongLong",
331 "numberWithUnsignedInteger"
335 "initWithUnsignedChar",
337 "initWithUnsignedShort",
339 "initWithUnsignedInt",
341 "initWithUnsignedLong",
343 "initWithUnsignedLongLong",
348 "initWithUnsignedInteger"
354 Sels = NSNumberInstanceSelectors;
355 Names = InstanceSelectorName;
357 Sels = NSNumberClassSelectors;
358 Names = ClassSelectorName;
361 if (Sels[MK].isNull())
395 case BuiltinType::Char_S:
396 case BuiltinType::SChar:
398 case BuiltinType::Char_U:
399 case BuiltinType::UChar:
401 case BuiltinType::Short:
403 case BuiltinType::UShort:
405 case BuiltinType::Int:
407 case BuiltinType::UInt:
409 case BuiltinType::Long:
411 case BuiltinType::ULong:
413 case BuiltinType::LongLong:
415 case BuiltinType::ULongLong:
419 case BuiltinType::Double:
421 case BuiltinType::Bool:
424 case BuiltinType::Void:
425 case BuiltinType::WChar_U:
426 case BuiltinType::WChar_S:
427 case BuiltinType::Char8:
428 case BuiltinType::Char16:
429 case BuiltinType::Char32:
430 case BuiltinType::Int128:
431 case BuiltinType::LongDouble:
432 case BuiltinType::ShortAccum:
433 case BuiltinType::Accum:
434 case BuiltinType::LongAccum:
435 case BuiltinType::UShortAccum:
436 case BuiltinType::UAccum:
437 case BuiltinType::ULongAccum:
438 case BuiltinType::ShortFract:
439 case BuiltinType::Fract:
440 case BuiltinType::LongFract:
441 case BuiltinType::UShortFract:
442 case BuiltinType::UFract:
443 case BuiltinType::ULongFract:
444 case BuiltinType::SatShortAccum:
445 case BuiltinType::SatAccum:
446 case BuiltinType::SatLongAccum:
447 case BuiltinType::SatUShortAccum:
448 case BuiltinType::SatUAccum:
449 case BuiltinType::SatULongAccum:
450 case BuiltinType::SatShortFract:
451 case BuiltinType::SatFract:
452 case BuiltinType::SatLongFract:
453 case BuiltinType::SatUShortFract:
454 case BuiltinType::SatUFract:
455 case BuiltinType::SatULongFract:
456 case BuiltinType::UInt128:
457 case BuiltinType::Float16:
458 case BuiltinType::Float128:
459 case BuiltinType::Ibm128:
460 case BuiltinType::NullPtr:
461 case BuiltinType::ObjCClass:
462 case BuiltinType::ObjCId:
463 case BuiltinType::ObjCSel:
464 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
465 case BuiltinType::Id:
466 #include "clang/Basic/OpenCLImageTypes.def"
467 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
468 case BuiltinType::Id:
469 #include "clang/Basic/OpenCLExtensionTypes.def"
470 case BuiltinType::OCLSampler:
471 case BuiltinType::OCLEvent:
472 case BuiltinType::OCLClkEvent:
473 case BuiltinType::OCLQueue:
474 case BuiltinType::OCLReserveID:
475 #define SVE_TYPE(Name, Id, SingletonId) \
476 case BuiltinType::Id:
477 #include "clang/Basic/AArch64SVEACLETypes.def"
478 #define PPC_VECTOR_TYPE(Name, Id, Size) \
479 case BuiltinType::Id:
480 #include "clang/Basic/PPCTypes.def"
481 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
482 #include "clang/Basic/RISCVVTypes.def"
483 case BuiltinType::BoundMember:
484 case BuiltinType::Dependent:
485 case BuiltinType::Overload:
486 case BuiltinType::UnknownAny:
487 case BuiltinType::ARCUnbridgedCast:
488 case BuiltinType::Half:
489 case BuiltinType::PseudoObject:
490 case BuiltinType::BuiltinFn:
491 case BuiltinType::IncompleteMatrixIdx:
492 case BuiltinType::OMPArraySection:
493 case BuiltinType::OMPArrayShaping:
494 case BuiltinType::OMPIterator:
495 case BuiltinType::BFloat16:
504 return isObjCTypedef(T,
"BOOL", BOOLId);
508 return isObjCTypedef(T,
"NSInteger", NSIntegerId);
512 return isObjCTypedef(T,
"NSUInteger", NSUIntegerId);
520 StringRef NSIntegralResust =
521 llvm::StringSwitch<StringRef>(
522 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
523 .Case(
"int8_t",
"int8_t")
524 .Case(
"int16_t",
"int16_t")
525 .Case(
"int32_t",
"int32_t")
526 .Case(
"NSInteger",
"NSInteger")
527 .Case(
"int64_t",
"int64_t")
528 .Case(
"uint8_t",
"uint8_t")
529 .Case(
"uint16_t",
"uint16_t")
530 .Case(
"uint32_t",
"uint32_t")
531 .Case(
"NSUInteger",
"NSUInteger")
532 .Case(
"uint64_t",
"uint64_t")
533 .Default(StringRef());
534 if (!NSIntegralResust.empty())
535 return NSIntegralResust;
548 if (!InterfaceDecl) {
554 bool IsSubclass =
false;
566 bool NSAPI::isObjCTypedef(
QualType T,
577 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
585 bool NSAPI::isObjCEnumerator(
const Expr *E,
597 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
598 return EnumD->getIdentifier() == II;
608 I = Ids.begin(), E = Ids.end(); I != E; ++I)
This class is used for builtin types like 'int'.
Represents an ObjC class declaration.
bool hasMacroDefinition() const
Return true if this identifier is #defined to some other value.
@ NSStr_stringWithCString
Optional< NSNumberLiteralMethodKind > getNSNumberLiteralMethodKind(Selector Sel) const
Return NSNumberLiteralMethodKind if Sel is such a selector.
@ NSDict_initWithObjectsAndKeys
Selector getNSSetSelector(NSSetMethodKind MK) const
The Objective-C NSSet selectors.
bool isNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, Selector Sel) const
@ NSOrderedSet_setObjectAtIndex
IdentifierInfo * getNSClassId(NSClassIdKindKind K) const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static const unsigned NumClassIds
NSArrayMethodKind
Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks.
@ NSOrderedSet_insertObjectAtIndex
@ NSOrderedSet_replaceObjectAtIndexWithObject
static const unsigned NumNSArrayMethods
@ NSNumberWithUnsignedLongLong
@ NSStr_stringWithCStringEncoding
A (possibly-)qualified type.
@ NSMutableDict_setObjectForKey
static const unsigned NumNSSetMethods
bool isObjCBOOLType(QualType T) const
Returns true if.
Selector getNSArraySelector(NSArrayMethodKind MK) const
The Objective-C NSArray selectors.
@ NSOrderedSet_setObjectAtIndexedSubscript
bool isSubclassOfNSClass(ObjCInterfaceDecl *InterfaceDecl, NSClassIdKindKind NSClassKind) const
Returns true if InterfaceDecl is subclass of NSClassKind.
@ NSNumberWithUnsignedInteger
@ NSStr_initWithUTF8String
@ NSDict_dictionaryWithObjectForKey
@ NSMutableArr_replaceObjectAtIndex
static const unsigned NumNSDictionaryMethods
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
SelectorTable & Selectors
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
@ NSDict_initWithObjectsForKeys
const T * getAs() const
Member-template getAs<specific type>'.
@ NSNumberWithUnsignedShort
bool isObjCNSIntegerType(QualType T) const
Returns true if.
@ NSDict_dictionaryWithObjectsAndKeys
@ NSNumberWithUnsignedInt
An instance of this object exists for each enum constant that is defined.
@ NSDict_dictionaryWithObjectsForKeysCount
Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const
The Objective-C NSDictionary selectors.
@ NSNumberWithUnsignedLong
static const unsigned NumNSNumberLiteralMethods
@ NSStr_stringWithUTF8String
Optional< NSNumberLiteralMethodKind > getNSNumberFactoryMethodKind(QualType T) const
Determine the appropriate NSNumber factory method kind for a literal of the given type.
@ NSDict_dictionaryWithObjectsForKeys
NSDictionaryMethodKind
Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...
NSNumberLiteralMethodKind
Enumerates the NSNumber methods used to generate literals.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Selector getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, bool Instance) const
The Objective-C NSNumber selectors used to create NSNumber literals.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
@ NSDict_dictionaryWithDictionary
ObjCInterfaceDecl * getSuperClass() const
Optional< NSArrayMethodKind > getNSArrayMethodKind(Selector Sel)
Return NSArrayMethodKind if Sel is such a selector.
One of these records is kept for each identifier that is lexed.
@ NSMutableDict_setValueForKey
Optional< NSSetMethodKind > getNSSetMethodKind(Selector Sel)
Return NSSetMethodKind if Sel is such a selector.
Selector getNSStringSelector(NSStringMethodKind MK) const
The Objective-C NSString selectors.
Selector getNullarySelector(IdentifierInfo *ID)
@ NSNumberWithUnsignedChar
Selector getUnarySelector(IdentifierInfo *ID)
NSSetMethodKind
Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.
@ NSDict_initWithDictionary
bool isNull() const
Determine whether this is the empty selector.
Smart pointer class that efficiently represents Objective-C method names.
@ NSMutableDict_setObjectForKeyedSubscript
@ NSMutableArr_setObjectAtIndexedSubscript
@ NSMutableArr_insertObjectAtIndex
Optional< NSDictionaryMethodKind > getNSDictionaryMethodKind(Selector Sel)
Return NSDictionaryMethodKind if Sel is such a selector.
@ NSArr_arrayWithObjectsCount
This represents one expression.
A reference to a declared variable, function, enum, etc.
StringRef GetNSIntegralKind(QualType T) const
Returns one of NSIntegral typedef names if.
bool isObjCNSUIntegerType(QualType T) const
Returns true if.
bool isMacroDefined(StringRef Id) const
Returns true if Id is currently defined as a macro.
const LangOptions & getLangOpts() const