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:
417 case BuiltinType::Float:
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::NullPtr:
460 case BuiltinType::ObjCClass:
461 case BuiltinType::ObjCId:
462 case BuiltinType::ObjCSel:
463 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 464 case BuiltinType::Id: 465 #include "clang/Basic/OpenCLImageTypes.def" 466 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 467 case BuiltinType::Id: 468 #include "clang/Basic/OpenCLExtensionTypes.def" 469 case BuiltinType::OCLSampler:
470 case BuiltinType::OCLEvent:
471 case BuiltinType::OCLClkEvent:
472 case BuiltinType::OCLQueue:
473 case BuiltinType::OCLReserveID:
474 #define SVE_TYPE(Name, Id, SingletonId) \ 475 case BuiltinType::Id: 476 #include "clang/Basic/AArch64SVEACLETypes.def" 477 case BuiltinType::BoundMember:
478 case BuiltinType::Dependent:
479 case BuiltinType::Overload:
480 case BuiltinType::UnknownAny:
481 case BuiltinType::ARCUnbridgedCast:
482 case BuiltinType::Half:
483 case BuiltinType::PseudoObject:
484 case BuiltinType::BuiltinFn:
485 case BuiltinType::OMPArraySection:
494 return isObjCTypedef(T,
"BOOL", BOOLId);
498 return isObjCTypedef(T,
"NSInteger", NSIntegerId);
502 return isObjCTypedef(T,
"NSUInteger", NSUIntegerId);
510 StringRef NSIntegralResust =
511 llvm::StringSwitch<StringRef>(
512 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
513 .Case(
"int8_t",
"int8_t")
514 .Case(
"int16_t",
"int16_t")
515 .Case(
"int32_t",
"int32_t")
516 .Case(
"NSInteger",
"NSInteger")
517 .Case(
"int64_t",
"int64_t")
518 .Case(
"uint8_t",
"uint8_t")
519 .Case(
"uint16_t",
"uint16_t")
520 .Case(
"uint32_t",
"uint32_t")
521 .Case(
"NSUInteger",
"NSUInteger")
522 .Case(
"uint64_t",
"uint64_t")
523 .Default(StringRef());
524 if (!NSIntegralResust.empty())
525 return NSIntegralResust;
538 if (!InterfaceDecl) {
544 bool IsSubclass =
false;
556 bool NSAPI::isObjCTypedef(
QualType T,
567 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
575 bool NSAPI::isObjCEnumerator(
const Expr *E,
587 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
588 return EnumD->getIdentifier() == II;
598 I = Ids.begin(), E = Ids.end(); I != E; ++I)
Optional< NSNumberLiteralMethodKind > getNSNumberFactoryMethodKind(QualType T) const
Determine the appropriate NSNumber factory method kind for a literal of the given type...
Defines the clang::ASTContext interface.
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
An instance of this object exists for each enum constant that is defined.
Optional< NSDictionaryMethodKind > getNSDictionaryMethodKind(Selector Sel)
Return NSDictionaryMethodKind if Sel is such a selector.
NSNumberLiteralMethodKind
Enumerates the NSNumber methods used to generate literals.
NSDictionaryMethodKind
Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...
const T * getAs() const
Member-template getAs<specific type>'.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Selector getUnarySelector(IdentifierInfo *ID)
One of these records is kept for each identifier that is lexed.
Optional< NSSetMethodKind > getNSSetMethodKind(Selector Sel)
Return NSSetMethodKind if Sel is such a selector.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Selector getNSStringSelector(NSStringMethodKind MK) const
The Objective-C NSString selectors.
Selector getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, bool Instance) const
The Objective-C NSNumber selectors used to create NSNumber literals.
Optional< NSNumberLiteralMethodKind > getNSNumberLiteralMethodKind(Selector Sel) const
Return NSNumberLiteralMethodKind if Sel is such a selector.
Selector getNullarySelector(IdentifierInfo *ID)
static const unsigned NumClassIds
static const unsigned NumNSNumberLiteralMethods
NSSetMethodKind
Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.
Represents an ObjC class declaration.
static const unsigned NumNSSetMethods
NSArrayMethodKind
Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks...
This represents one expression.
Selector getNSArraySelector(NSArrayMethodKind MK) const
The Objective-C NSArray selectors.
ObjCInterfaceDecl * getSuperClass() const
StringRef GetNSIntegralKind(QualType T) const
Returns one of NSIntegral typedef names if.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
SelectorTable & Selectors
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool isObjCBOOLType(QualType T) const
Returns true if.
bool isObjCNSUIntegerType(QualType T) const
Returns true if.
Selector getNSSetSelector(NSSetMethodKind MK) const
The Objective-C NSSet selectors.
bool isObjCNSIntegerType(QualType T) const
Returns true if.
bool isSubclassOfNSClass(ObjCInterfaceDecl *InterfaceDecl, NSClassIdKindKind NSClassKind) const
Returns true if InterfaceDecl is subclass of NSClassKind.
IdentifierInfo * getNSClassId(NSClassIdKindKind K) const
Dataflow Directional Tag Classes.
bool isMacroDefined(StringRef Id) const
Returns true if Id is currently defined as a macro.
bool isNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, Selector Sel) const
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
static const unsigned NumNSArrayMethods
Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const
The Objective-C NSDictionary selectors.
static const unsigned NumNSDictionaryMethods
bool isNull() const
Determine whether this is the empty selector.
This class is used for builtin types like 'int'.
Optional< NSArrayMethodKind > getNSArrayMethodKind(Selector Sel)
Return NSArrayMethodKind if Sel is such a selector.
A reference to a declared variable, function, enum, etc.
bool hasMacroDefinition() const
Return true if this identifier is #defined to some other value.
const LangOptions & getLangOpts() const