14 #include "llvm/ADT/StringSwitch.h"
16 using namespace clang;
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];
91 if (NSArraySelectors[MK].isNull()) {
151 return (NSArraySelectors[MK] = Sel);
154 return NSArraySelectors[MK];
169 if (NSDictionarySelectors[MK].isNull()) {
177 &Ctx.
Idents.
get(
"dictionaryWithDictionary"));
189 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
197 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
206 &Ctx.
Idents.
get(
"dictionaryWithObjectsAndKeys"));
214 &Ctx.
Idents.
get(
"initWithObjectsAndKeys"));
252 return (NSDictionarySelectors[MK] = Sel);
255 return NSDictionarySelectors[MK];
270 if (NSSetSelectors[MK].isNull()) {
309 return (NSSetSelectors[MK] = Sel);
312 return NSSetSelectors[MK];
327 bool Instance)
const {
330 "numberWithUnsignedChar",
332 "numberWithUnsignedShort",
334 "numberWithUnsignedInt",
336 "numberWithUnsignedLong",
337 "numberWithLongLong",
338 "numberWithUnsignedLongLong",
343 "numberWithUnsignedInteger"
347 "initWithUnsignedChar",
349 "initWithUnsignedShort",
351 "initWithUnsignedInt",
353 "initWithUnsignedLong",
355 "initWithUnsignedLongLong",
360 "initWithUnsignedInteger"
366 Sels = NSNumberInstanceSelectors;
367 Names = InstanceSelectorName;
369 Sels = NSNumberClassSelectors;
370 Names = ClassSelectorName;
373 if (Sels[MK].isNull())
407 case BuiltinType::Char_S:
408 case BuiltinType::SChar:
410 case BuiltinType::Char_U:
411 case BuiltinType::UChar:
413 case BuiltinType::Short:
415 case BuiltinType::UShort:
417 case BuiltinType::Int:
419 case BuiltinType::UInt:
421 case BuiltinType::Long:
423 case BuiltinType::ULong:
425 case BuiltinType::LongLong:
427 case BuiltinType::ULongLong:
429 case BuiltinType::Float:
431 case BuiltinType::Double:
433 case BuiltinType::Bool:
436 case BuiltinType::Void:
437 case BuiltinType::WChar_U:
438 case BuiltinType::WChar_S:
439 case BuiltinType::Char16:
440 case BuiltinType::Char32:
441 case BuiltinType::Int128:
442 case BuiltinType::LongDouble:
443 case BuiltinType::UInt128:
444 case BuiltinType::NullPtr:
445 case BuiltinType::ObjCClass:
446 case BuiltinType::ObjCId:
447 case BuiltinType::ObjCSel:
448 case BuiltinType::OCLImage1d:
449 case BuiltinType::OCLImage1dArray:
450 case BuiltinType::OCLImage1dBuffer:
451 case BuiltinType::OCLImage2d:
452 case BuiltinType::OCLImage2dArray:
453 case BuiltinType::OCLImage3d:
454 case BuiltinType::OCLSampler:
455 case BuiltinType::OCLEvent:
456 case BuiltinType::BoundMember:
457 case BuiltinType::Dependent:
458 case BuiltinType::Overload:
459 case BuiltinType::UnknownAny:
460 case BuiltinType::ARCUnbridgedCast:
461 case BuiltinType::Half:
462 case BuiltinType::PseudoObject:
463 case BuiltinType::BuiltinFn:
472 return isObjCTypedef(T,
"BOOL", BOOLId);
476 return isObjCTypedef(T,
"NSInteger", NSIntegerId);
480 return isObjCTypedef(T,
"NSUInteger", NSUIntegerId);
488 StringRef NSIntegralResust =
489 llvm::StringSwitch<StringRef>(
490 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
491 .Case(
"int8_t",
"int8_t")
492 .Case(
"int16_t",
"int16_t")
493 .Case(
"int32_t",
"int32_t")
494 .Case(
"NSInteger",
"NSInteger")
495 .Case(
"int64_t",
"int64_t")
496 .Case(
"uint8_t",
"uint8_t")
497 .Case(
"uint16_t",
"uint16_t")
498 .Case(
"uint32_t",
"uint32_t")
499 .Case(
"NSUInteger",
"NSUInteger")
500 .Case(
"uint64_t",
"uint64_t")
501 .Default(StringRef());
502 if (!NSIntegralResust.empty())
503 return NSIntegralResust;
516 if (!InterfaceDecl) {
522 bool IsSubclass =
false;
534 bool NSAPI::isObjCTypedef(
QualType T,
545 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
553 bool NSAPI::isObjCEnumerator(
const Expr *E,
565 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
566 return EnumD->getIdentifier() == II;
576 I = Ids.begin(), E = Ids.end(); I != E; ++I)
Defines the clang::ASTContext interface.
Smart pointer class that efficiently represents Objective-C method names.
IdentifierInfo * getIdentifier() const
Optional< NSDictionaryMethodKind > getNSDictionaryMethodKind(Selector Sel)
Return NSDictionaryMethodKind if Sel is such a selector.
NSNumberLiteralMethodKind
Enumerates the NSNumber methods used to generate literals.
Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const
The Objective-C NSDictionary selectors.
NSDictionaryMethodKind
Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...
bool isNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, Selector Sel) const
Selector getNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, bool Instance) const
The Objective-C NSNumber selectors used to create NSNumber literals.
bool isObjCNSUIntegerType(QualType T) const
Returns true if.
IdentifierInfo * getNSClassId(NSClassIdKindKind K) const
Selector getNSStringSelector(NSStringMethodKind MK) const
The Objective-C NSString selectors.
Selector getUnarySelector(IdentifierInfo *ID)
Optional< NSSetMethodKind > getNSSetMethodKind(Selector Sel)
Return NSSetMethodKind if Sel is such a selector.
bool hasMacroDefinition() const
Return true if this identifier is #defined to some other value.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Optional< NSNumberLiteralMethodKind > getNSNumberLiteralMethodKind(Selector Sel) const
Return NSNumberLiteralMethodKind if Sel is such a selector.
bool isNull() const
Determine whether this is the empty selector.
Selector getNullarySelector(IdentifierInfo *ID)
const LangOptions & getLangOpts() const
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...
bool isObjCNSIntegerType(QualType T) const
Returns true if.
bool isMacroDefined(StringRef Id) const
Returns true if Id is currently defined as a macro.
Selector getNSSetSelector(NSSetMethodKind MK) const
The Objective-C NSSet selectors.
SelectorTable & Selectors
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
StringRef GetNSIntegralKind(QualType T) const
Returns one of NSIntegral typedef names if.
Selector getNSArraySelector(NSArrayMethodKind MK) const
The Objective-C NSArray selectors.
bool isSubclassOfNSClass(ObjCInterfaceDecl *InterfaceDecl, NSClassIdKindKind NSClassKind) const
Returns true if InterfaceDecl is subclass of NSClassKind.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Optional< NSStringMethodKind > getNSStringMethodKind(Selector Sel) const
Return NSStringMethodKind if.
Optional< NSNumberLiteralMethodKind > getNSNumberFactoryMethodKind(QualType T) const
Determine the appropriate NSNumber factory method kind for a literal of the given type...
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
static const unsigned NumNSArrayMethods
static const unsigned NumNSDictionaryMethods
ObjCInterfaceDecl * getSuperClass() const
Optional< NSArrayMethodKind > getNSArrayMethodKind(Selector Sel)
Return NSArrayMethodKind if Sel is such a selector.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
bool isObjCBOOLType(QualType T) const
Returns true if.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
static const unsigned NumNSStringMethods