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::Char8:
440 case BuiltinType::Char16:
441 case BuiltinType::Char32:
442 case BuiltinType::Int128:
443 case BuiltinType::LongDouble:
444 case BuiltinType::ShortAccum:
445 case BuiltinType::Accum:
446 case BuiltinType::LongAccum:
447 case BuiltinType::UShortAccum:
448 case BuiltinType::UAccum:
449 case BuiltinType::ULongAccum:
450 case BuiltinType::ShortFract:
451 case BuiltinType::Fract:
452 case BuiltinType::LongFract:
453 case BuiltinType::UShortFract:
454 case BuiltinType::UFract:
455 case BuiltinType::ULongFract:
456 case BuiltinType::SatShortAccum:
457 case BuiltinType::SatAccum:
458 case BuiltinType::SatLongAccum:
459 case BuiltinType::SatUShortAccum:
460 case BuiltinType::SatUAccum:
461 case BuiltinType::SatULongAccum:
462 case BuiltinType::SatShortFract:
463 case BuiltinType::SatFract:
464 case BuiltinType::SatLongFract:
465 case BuiltinType::SatUShortFract:
466 case BuiltinType::SatUFract:
467 case BuiltinType::SatULongFract:
468 case BuiltinType::UInt128:
469 case BuiltinType::Float16:
470 case BuiltinType::Float128:
471 case BuiltinType::NullPtr:
472 case BuiltinType::ObjCClass:
473 case BuiltinType::ObjCId:
474 case BuiltinType::ObjCSel:
475 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 476 case BuiltinType::Id: 477 #include "clang/Basic/OpenCLImageTypes.def" 478 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 479 case BuiltinType::Id: 480 #include "clang/Basic/OpenCLExtensionTypes.def" 481 case BuiltinType::OCLSampler:
482 case BuiltinType::OCLEvent:
483 case BuiltinType::OCLClkEvent:
484 case BuiltinType::OCLQueue:
485 case BuiltinType::OCLReserveID:
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::OMPArraySection:
503 return isObjCTypedef(T,
"BOOL", BOOLId);
507 return isObjCTypedef(T,
"NSInteger", NSIntegerId);
511 return isObjCTypedef(T,
"NSUInteger", NSUIntegerId);
519 StringRef NSIntegralResust =
520 llvm::StringSwitch<StringRef>(
521 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
522 .Case(
"int8_t",
"int8_t")
523 .Case(
"int16_t",
"int16_t")
524 .Case(
"int32_t",
"int32_t")
525 .Case(
"NSInteger",
"NSInteger")
526 .Case(
"int64_t",
"int64_t")
527 .Case(
"uint8_t",
"uint8_t")
528 .Case(
"uint16_t",
"uint16_t")
529 .Case(
"uint32_t",
"uint32_t")
530 .Case(
"NSUInteger",
"NSUInteger")
531 .Case(
"uint64_t",
"uint64_t")
532 .Default(StringRef());
533 if (!NSIntegralResust.empty())
534 return NSIntegralResust;
547 if (!InterfaceDecl) {
553 bool IsSubclass =
false;
565 bool NSAPI::isObjCTypedef(
QualType T,
576 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
584 bool NSAPI::isObjCEnumerator(
const Expr *E,
596 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
597 return EnumD->getIdentifier() == II;
607 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
Optional< NSStringMethodKind > getNSStringMethodKind(Selector Sel) const
Return NSStringMethodKind if.
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
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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
static const unsigned NumNSStringMethods