13#include "llvm/ADT/StringSwitch.h"
19 : Ctx(ctx), ClassIds(), BOOLId(nullptr), NSIntegerId(nullptr),
20 NSUIntegerId(nullptr), NSASCIIStringEncodingId(nullptr),
21 NSUTF8StringEncodingId(nullptr) {}
30 "NSMutableDictionary",
33 "NSMutableOrderedSet",
38 return (ClassIds[K] = &Ctx.
Idents.
get(ClassName[K]));
44 if (NSStringSelectors[MK].isNull()) {
73 return (NSStringSelectors[MK] = Sel);
76 return NSStringSelectors[MK];
80 if (NSArraySelectors[MK].isNull()) {
140 return (NSArraySelectors[MK] = Sel);
143 return NSArraySelectors[MK];
146std::optional<NSAPI::NSArrayMethodKind>
159 if (NSDictionarySelectors[MK].isNull()) {
167 &Ctx.
Idents.
get(
"dictionaryWithDictionary"));
179 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
187 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
196 &Ctx.
Idents.
get(
"dictionaryWithObjectsAndKeys"));
204 &Ctx.
Idents.
get(
"initWithObjectsAndKeys"));
242 return (NSDictionarySelectors[MK] = Sel);
245 return NSDictionarySelectors[MK];
248std::optional<NSAPI::NSDictionaryMethodKind>
260 if (NSSetSelectors[MK].isNull()) {
299 return (NSSetSelectors[MK] = Sel);
302 return NSSetSelectors[MK];
316 bool Instance)
const {
319 "numberWithUnsignedChar",
321 "numberWithUnsignedShort",
323 "numberWithUnsignedInt",
325 "numberWithUnsignedLong",
326 "numberWithLongLong",
327 "numberWithUnsignedLongLong",
332 "numberWithUnsignedInteger"
336 "initWithUnsignedChar",
338 "initWithUnsignedShort",
340 "initWithUnsignedInt",
342 "initWithUnsignedLong",
344 "initWithUnsignedLongLong",
349 "initWithUnsignedInteger"
355 Sels = NSNumberInstanceSelectors;
356 Names = InstanceSelectorName;
358 Sels = NSNumberClassSelectors;
359 Names = ClassSelectorName;
362 if (Sels[MK].isNull())
367std::optional<NSAPI::NSNumberLiteralMethodKind>
378std::optional<NSAPI::NSNumberLiteralMethodKind>
396 case BuiltinType::Char_S:
397 case BuiltinType::SChar:
399 case BuiltinType::Char_U:
400 case BuiltinType::UChar:
402 case BuiltinType::Short:
404 case BuiltinType::UShort:
406 case BuiltinType::Int:
408 case BuiltinType::UInt:
410 case BuiltinType::Long:
412 case BuiltinType::ULong:
414 case BuiltinType::LongLong:
416 case BuiltinType::ULongLong:
418 case BuiltinType::Float:
420 case BuiltinType::Double:
422 case BuiltinType::Bool:
425 case BuiltinType::Void:
426 case BuiltinType::WChar_U:
427 case BuiltinType::WChar_S:
428 case BuiltinType::Char8:
429 case BuiltinType::Char16:
430 case BuiltinType::Char32:
431 case BuiltinType::Int128:
432 case BuiltinType::LongDouble:
433 case BuiltinType::ShortAccum:
434 case BuiltinType::Accum:
435 case BuiltinType::LongAccum:
436 case BuiltinType::UShortAccum:
437 case BuiltinType::UAccum:
438 case BuiltinType::ULongAccum:
439 case BuiltinType::ShortFract:
440 case BuiltinType::Fract:
441 case BuiltinType::LongFract:
442 case BuiltinType::UShortFract:
443 case BuiltinType::UFract:
444 case BuiltinType::ULongFract:
445 case BuiltinType::SatShortAccum:
446 case BuiltinType::SatAccum:
447 case BuiltinType::SatLongAccum:
448 case BuiltinType::SatUShortAccum:
449 case BuiltinType::SatUAccum:
450 case BuiltinType::SatULongAccum:
451 case BuiltinType::SatShortFract:
452 case BuiltinType::SatFract:
453 case BuiltinType::SatLongFract:
454 case BuiltinType::SatUShortFract:
455 case BuiltinType::SatUFract:
456 case BuiltinType::SatULongFract:
457 case BuiltinType::UInt128:
458 case BuiltinType::Float16:
459 case BuiltinType::Float128:
460 case BuiltinType::Ibm128:
461 case BuiltinType::NullPtr:
462 case BuiltinType::ObjCClass:
463 case BuiltinType::ObjCId:
464 case BuiltinType::ObjCSel:
465#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
466 case BuiltinType::Id:
467#include "clang/Basic/OpenCLImageTypes.def"
468#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
469 case BuiltinType::Id:
470#include "clang/Basic/OpenCLExtensionTypes.def"
471 case BuiltinType::OCLSampler:
472 case BuiltinType::OCLEvent:
473 case BuiltinType::OCLClkEvent:
474 case BuiltinType::OCLQueue:
475 case BuiltinType::OCLReserveID:
476#define SVE_TYPE(Name, Id, SingletonId) \
477 case BuiltinType::Id:
478#include "clang/Basic/AArch64SVEACLETypes.def"
479#define PPC_VECTOR_TYPE(Name, Id, Size) \
480 case BuiltinType::Id:
481#include "clang/Basic/PPCTypes.def"
482#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
483#include "clang/Basic/RISCVVTypes.def"
484#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
485#include "clang/Basic/WebAssemblyReferenceTypes.def"
486 case BuiltinType::BoundMember:
487 case BuiltinType::Dependent:
488 case BuiltinType::Overload:
489 case BuiltinType::UnknownAny:
490 case BuiltinType::ARCUnbridgedCast:
491 case BuiltinType::Half:
492 case BuiltinType::PseudoObject:
493 case BuiltinType::BuiltinFn:
494 case BuiltinType::IncompleteMatrixIdx:
495 case BuiltinType::OMPArraySection:
496 case BuiltinType::OMPArrayShaping:
497 case BuiltinType::OMPIterator:
498 case BuiltinType::BFloat16:
507 return isObjCTypedef(T,
"BOOL", BOOLId);
511 return isObjCTypedef(T,
"NSInteger", NSIntegerId);
515 return isObjCTypedef(T,
"NSUInteger", NSUIntegerId);
523 StringRef NSIntegralResust =
524 llvm::StringSwitch<StringRef>(
525 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
526 .Case(
"int8_t",
"int8_t")
527 .Case(
"int16_t",
"int16_t")
528 .Case(
"int32_t",
"int32_t")
529 .Case(
"NSInteger",
"NSInteger")
530 .Case(
"int64_t",
"int64_t")
531 .Case(
"uint8_t",
"uint8_t")
532 .Case(
"uint16_t",
"uint16_t")
533 .Case(
"uint32_t",
"uint32_t")
534 .Case(
"NSUInteger",
"NSUInteger")
535 .Case(
"uint64_t",
"uint64_t")
536 .Default(StringRef());
537 if (!NSIntegralResust.empty())
538 return NSIntegralResust;
551 if (!InterfaceDecl) {
557 bool IsSubclass =
false;
569bool NSAPI::isObjCTypedef(
QualType T,
580 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
588bool NSAPI::isObjCEnumerator(
const Expr *E,
600 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
601 return EnumD->getIdentifier() == II;
611 I = Ids.begin(), E = Ids.end(); I != E; ++I)
Defines the clang::ASTContext interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
SelectorTable & Selectors
This class is used for builtin types like 'int'.
A reference to a declared variable, function, enum, etc.
An instance of this object exists for each enum constant that is defined.
This represents one expression.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
One of these records is kept for each identifier that is lexed.
bool hasMacroDefinition() const
Return true if this identifier is #defined to some other value.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
std::optional< NSNumberLiteralMethodKind > getNSNumberLiteralMethodKind(Selector Sel) const
Return NSNumberLiteralMethodKind if Sel is such a selector.
bool isObjCNSIntegerType(QualType T) const
Returns true if.
@ NSStr_initWithUTF8String
@ NSStr_stringWithCString
@ NSStr_stringWithCStringEncoding
@ NSStr_stringWithUTF8String
Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const
The Objective-C NSDictionary selectors.
static const unsigned NumNSArrayMethods
Selector getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, bool Instance) const
The Objective-C NSNumber selectors used to create NSNumber literals.
bool isMacroDefined(StringRef Id) const
Returns true if Id is currently defined as a macro.
std::optional< NSNumberLiteralMethodKind > getNSNumberFactoryMethodKind(QualType T) const
Determine the appropriate NSNumber factory method kind for a literal of the given type.
std::optional< NSDictionaryMethodKind > getNSDictionaryMethodKind(Selector Sel)
Return NSDictionaryMethodKind if Sel is such a selector.
static const unsigned NumClassIds
NSSetMethodKind
Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.
@ NSOrderedSet_setObjectAtIndex
@ NSOrderedSet_replaceObjectAtIndexWithObject
@ NSOrderedSet_setObjectAtIndexedSubscript
@ NSOrderedSet_insertObjectAtIndex
NSDictionaryMethodKind
Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...
@ NSMutableDict_setValueForKey
@ NSDict_dictionaryWithObjectsForKeys
@ NSDict_dictionaryWithDictionary
@ NSMutableDict_setObjectForKey
@ NSDict_initWithObjectsForKeys
@ NSDict_dictionaryWithObjectForKey
@ NSDict_initWithDictionary
@ NSDict_dictionaryWithObjectsForKeysCount
@ NSDict_initWithObjectsAndKeys
@ NSMutableDict_setObjectForKeyedSubscript
@ NSDict_dictionaryWithObjectsAndKeys
Selector getNSArraySelector(NSArrayMethodKind MK) const
The Objective-C NSArray selectors.
std::optional< NSArrayMethodKind > getNSArrayMethodKind(Selector Sel)
Return NSArrayMethodKind if Sel is such a selector.
NSArrayMethodKind
Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks.
@ NSMutableArr_setObjectAtIndexedSubscript
@ NSMutableArr_insertObjectAtIndex
@ NSArr_arrayWithObjectsCount
@ NSMutableArr_replaceObjectAtIndex
bool isSubclassOfNSClass(ObjCInterfaceDecl *InterfaceDecl, NSClassIdKindKind NSClassKind) const
Returns true if InterfaceDecl is subclass of NSClassKind.
std::optional< NSSetMethodKind > getNSSetMethodKind(Selector Sel)
Return NSSetMethodKind if Sel is such a selector.
bool isNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, Selector Sel) const
static const unsigned NumNSNumberLiteralMethods
bool isObjCNSUIntegerType(QualType T) const
Returns true if.
NSNumberLiteralMethodKind
Enumerates the NSNumber methods used to generate literals.
@ NSNumberWithUnsignedChar
@ NSNumberWithUnsignedLongLong
@ NSNumberWithUnsignedInt
@ NSNumberWithUnsignedLong
@ NSNumberWithUnsignedInteger
@ NSNumberWithUnsignedShort
Selector getNSStringSelector(NSStringMethodKind MK) const
The Objective-C NSString selectors.
static const unsigned NumNSDictionaryMethods
bool isObjCBOOLType(QualType T) const
Returns true if.
static const unsigned NumNSSetMethods
StringRef GetNSIntegralKind(QualType T) const
Returns one of NSIntegral typedef names if.
Selector getNSSetSelector(NSSetMethodKind MK) const
The Objective-C NSSet selectors.
IdentifierInfo * getNSClassId(NSClassIdKindKind K) const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents an ObjC class declaration.
ObjCInterfaceDecl * getSuperClass() const
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
Selector getNullarySelector(IdentifierInfo *ID)
Selector getUnarySelector(IdentifierInfo *ID)
Smart pointer class that efficiently represents Objective-C method names.
bool isNull() const
Determine whether this is the empty selector.
const T * getAs() const
Member-template getAs<specific type>'.