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()) {
71 return (NSStringSelectors[MK] = Sel);
74 return NSStringSelectors[MK];
78 if (NSArraySelectors[MK].isNull()) {
131 return (NSArraySelectors[MK] = Sel);
134 return NSArraySelectors[MK];
137std::optional<NSAPI::NSArrayMethodKind>
150 if (NSDictionarySelectors[MK].isNull()) {
158 &Ctx.
Idents.
get(
"dictionaryWithDictionary"));
181 &Ctx.
Idents.
get(
"dictionaryWithObjectsAndKeys"));
189 &Ctx.
Idents.
get(
"initWithObjectsAndKeys"));
219 return (NSDictionarySelectors[MK] = Sel);
222 return NSDictionarySelectors[MK];
225std::optional<NSAPI::NSDictionaryMethodKind>
237 if (NSSetSelectors[MK].isNull()) {
269 return (NSSetSelectors[MK] = Sel);
272 return NSSetSelectors[MK];
286 bool Instance)
const {
289 "numberWithUnsignedChar",
291 "numberWithUnsignedShort",
293 "numberWithUnsignedInt",
295 "numberWithUnsignedLong",
296 "numberWithLongLong",
297 "numberWithUnsignedLongLong",
302 "numberWithUnsignedInteger"
306 "initWithUnsignedChar",
308 "initWithUnsignedShort",
310 "initWithUnsignedInt",
312 "initWithUnsignedLong",
314 "initWithUnsignedLongLong",
319 "initWithUnsignedInteger"
325 Sels = NSNumberInstanceSelectors;
326 Names = InstanceSelectorName;
328 Sels = NSNumberClassSelectors;
329 Names = ClassSelectorName;
332 if (Sels[MK].isNull())
337std::optional<NSAPI::NSNumberLiteralMethodKind>
348std::optional<NSAPI::NSNumberLiteralMethodKind>
366 case BuiltinType::Char_S:
367 case BuiltinType::SChar:
369 case BuiltinType::Char_U:
370 case BuiltinType::UChar:
372 case BuiltinType::Short:
374 case BuiltinType::UShort:
376 case BuiltinType::Int:
378 case BuiltinType::UInt:
380 case BuiltinType::Long:
382 case BuiltinType::ULong:
384 case BuiltinType::LongLong:
386 case BuiltinType::ULongLong:
388 case BuiltinType::Float:
390 case BuiltinType::Double:
392 case BuiltinType::Bool:
395 case BuiltinType::Void:
396 case BuiltinType::WChar_U:
397 case BuiltinType::WChar_S:
398 case BuiltinType::Char8:
399 case BuiltinType::Char16:
400 case BuiltinType::Char32:
401 case BuiltinType::Int128:
402 case BuiltinType::LongDouble:
403 case BuiltinType::ShortAccum:
404 case BuiltinType::Accum:
405 case BuiltinType::LongAccum:
406 case BuiltinType::UShortAccum:
407 case BuiltinType::UAccum:
408 case BuiltinType::ULongAccum:
409 case BuiltinType::ShortFract:
410 case BuiltinType::Fract:
411 case BuiltinType::LongFract:
412 case BuiltinType::UShortFract:
413 case BuiltinType::UFract:
414 case BuiltinType::ULongFract:
415 case BuiltinType::SatShortAccum:
416 case BuiltinType::SatAccum:
417 case BuiltinType::SatLongAccum:
418 case BuiltinType::SatUShortAccum:
419 case BuiltinType::SatUAccum:
420 case BuiltinType::SatULongAccum:
421 case BuiltinType::SatShortFract:
422 case BuiltinType::SatFract:
423 case BuiltinType::SatLongFract:
424 case BuiltinType::SatUShortFract:
425 case BuiltinType::SatUFract:
426 case BuiltinType::SatULongFract:
427 case BuiltinType::UInt128:
428 case BuiltinType::Float16:
429 case BuiltinType::Float128:
430 case BuiltinType::Ibm128:
431 case BuiltinType::NullPtr:
432 case BuiltinType::ObjCClass:
433 case BuiltinType::ObjCId:
434 case BuiltinType::ObjCSel:
435#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
436 case BuiltinType::Id:
437#include "clang/Basic/OpenCLImageTypes.def"
438#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
439 case BuiltinType::Id:
440#include "clang/Basic/OpenCLExtensionTypes.def"
441 case BuiltinType::OCLSampler:
442 case BuiltinType::OCLEvent:
443 case BuiltinType::OCLClkEvent:
444 case BuiltinType::OCLQueue:
445 case BuiltinType::OCLReserveID:
446#define SVE_TYPE(Name, Id, SingletonId) \
447 case BuiltinType::Id:
448#include "clang/Basic/AArch64SVEACLETypes.def"
449#define PPC_VECTOR_TYPE(Name, Id, Size) \
450 case BuiltinType::Id:
451#include "clang/Basic/PPCTypes.def"
452#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
453#include "clang/Basic/RISCVVTypes.def"
454#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
455#include "clang/Basic/WebAssemblyReferenceTypes.def"
456#define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
457#include "clang/Basic/AMDGPUTypes.def"
458#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
459#include "clang/Basic/HLSLIntangibleTypes.def"
460 case BuiltinType::BoundMember:
461 case BuiltinType::UnresolvedTemplate:
462 case BuiltinType::Dependent:
463 case BuiltinType::Overload:
464 case BuiltinType::UnknownAny:
465 case BuiltinType::ARCUnbridgedCast:
466 case BuiltinType::Half:
467 case BuiltinType::PseudoObject:
468 case BuiltinType::BuiltinFn:
469 case BuiltinType::IncompleteMatrixIdx:
470 case BuiltinType::ArraySection:
471 case BuiltinType::OMPArrayShaping:
472 case BuiltinType::OMPIterator:
473 case BuiltinType::BFloat16:
482 return isObjCTypedef(
T,
"BOOL", BOOLId);
486 return isObjCTypedef(
T,
"NSInteger", NSIntegerId);
490 return isObjCTypedef(
T,
"NSUInteger", NSUIntegerId);
498 StringRef NSIntegralResust =
499 llvm::StringSwitch<StringRef>(
500 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
501 .Case(
"int8_t",
"int8_t")
502 .Case(
"int16_t",
"int16_t")
503 .Case(
"int32_t",
"int32_t")
504 .Case(
"NSInteger",
"NSInteger")
505 .Case(
"int64_t",
"int64_t")
506 .Case(
"uint8_t",
"uint8_t")
507 .Case(
"uint16_t",
"uint16_t")
508 .Case(
"uint32_t",
"uint32_t")
509 .Case(
"NSUInteger",
"NSUInteger")
510 .Case(
"uint64_t",
"uint64_t")
511 .Default(StringRef());
512 if (!NSIntegralResust.empty())
513 return NSIntegralResust;
526 if (!InterfaceDecl) {
532 bool IsSubclass =
false;
555 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
563bool NSAPI::isObjCEnumerator(
const Expr *
E,
575 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
576 return EnumD->getIdentifier() == II;
586 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.
Selector getNullarySelector(const IdentifierInfo *ID)
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Selector getUnarySelector(const 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>'.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T