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];
90 if (NSArraySelectors[MK].isNull()) {
150 return (NSArraySelectors[MK] = Sel);
153 return NSArraySelectors[MK];
168 if (NSDictionarySelectors[MK].isNull()) {
176 &Ctx.
Idents.
get(
"dictionaryWithDictionary"));
188 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
196 &Ctx.
Idents.
get(
"dictionaryWithObjects"),
205 &Ctx.
Idents.
get(
"dictionaryWithObjectsAndKeys"));
213 &Ctx.
Idents.
get(
"initWithObjectsAndKeys"));
251 return (NSDictionarySelectors[MK] = Sel);
254 return NSDictionarySelectors[MK];
269 if (NSSetSelectors[MK].isNull()) {
308 return (NSSetSelectors[MK] = Sel);
311 return NSSetSelectors[MK];
326 bool Instance)
const {
329 "numberWithUnsignedChar",
331 "numberWithUnsignedShort",
333 "numberWithUnsignedInt",
335 "numberWithUnsignedLong",
336 "numberWithLongLong",
337 "numberWithUnsignedLongLong",
342 "numberWithUnsignedInteger" 346 "initWithUnsignedChar",
348 "initWithUnsignedShort",
350 "initWithUnsignedInt",
352 "initWithUnsignedLong",
354 "initWithUnsignedLongLong",
359 "initWithUnsignedInteger" 365 Sels = NSNumberInstanceSelectors;
366 Names = InstanceSelectorName;
368 Sels = NSNumberClassSelectors;
369 Names = ClassSelectorName;
372 if (Sels[MK].isNull())
406 case BuiltinType::Char_S:
407 case BuiltinType::SChar:
409 case BuiltinType::Char_U:
410 case BuiltinType::UChar:
412 case BuiltinType::Short:
414 case BuiltinType::UShort:
416 case BuiltinType::Int:
418 case BuiltinType::UInt:
420 case BuiltinType::Long:
422 case BuiltinType::ULong:
424 case BuiltinType::LongLong:
426 case BuiltinType::ULongLong:
428 case BuiltinType::Float:
430 case BuiltinType::Double:
432 case BuiltinType::Bool:
435 case BuiltinType::Void:
436 case BuiltinType::WChar_U:
437 case BuiltinType::WChar_S:
438 case BuiltinType::Char8:
439 case BuiltinType::Char16:
440 case BuiltinType::Char32:
441 case BuiltinType::Int128:
442 case BuiltinType::LongDouble:
443 case BuiltinType::ShortAccum:
444 case BuiltinType::Accum:
445 case BuiltinType::LongAccum:
446 case BuiltinType::UShortAccum:
447 case BuiltinType::UAccum:
448 case BuiltinType::ULongAccum:
449 case BuiltinType::ShortFract:
450 case BuiltinType::Fract:
451 case BuiltinType::LongFract:
452 case BuiltinType::UShortFract:
453 case BuiltinType::UFract:
454 case BuiltinType::ULongFract:
455 case BuiltinType::SatShortAccum:
456 case BuiltinType::SatAccum:
457 case BuiltinType::SatLongAccum:
458 case BuiltinType::SatUShortAccum:
459 case BuiltinType::SatUAccum:
460 case BuiltinType::SatULongAccum:
461 case BuiltinType::SatShortFract:
462 case BuiltinType::SatFract:
463 case BuiltinType::SatLongFract:
464 case BuiltinType::SatUShortFract:
465 case BuiltinType::SatUFract:
466 case BuiltinType::SatULongFract:
467 case BuiltinType::UInt128:
468 case BuiltinType::Float16:
469 case BuiltinType::Float128:
470 case BuiltinType::NullPtr:
471 case BuiltinType::ObjCClass:
472 case BuiltinType::ObjCId:
473 case BuiltinType::ObjCSel:
474 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 475 case BuiltinType::Id: 476 #include "clang/Basic/OpenCLImageTypes.def" 477 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 478 case BuiltinType::Id: 479 #include "clang/Basic/OpenCLExtensionTypes.def" 480 case BuiltinType::OCLSampler:
481 case BuiltinType::OCLEvent:
482 case BuiltinType::OCLClkEvent:
483 case BuiltinType::OCLQueue:
484 case BuiltinType::OCLReserveID:
485 case BuiltinType::BoundMember:
486 case BuiltinType::Dependent:
487 case BuiltinType::Overload:
488 case BuiltinType::UnknownAny:
489 case BuiltinType::ARCUnbridgedCast:
490 case BuiltinType::Half:
491 case BuiltinType::PseudoObject:
492 case BuiltinType::BuiltinFn:
493 case BuiltinType::OMPArraySection:
502 return isObjCTypedef(T,
"BOOL", BOOLId);
506 return isObjCTypedef(T,
"NSInteger", NSIntegerId);
510 return isObjCTypedef(T,
"NSUInteger", NSUIntegerId);
518 StringRef NSIntegralResust =
519 llvm::StringSwitch<StringRef>(
520 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
521 .Case(
"int8_t",
"int8_t")
522 .Case(
"int16_t",
"int16_t")
523 .Case(
"int32_t",
"int32_t")
524 .Case(
"NSInteger",
"NSInteger")
525 .Case(
"int64_t",
"int64_t")
526 .Case(
"uint8_t",
"uint8_t")
527 .Case(
"uint16_t",
"uint16_t")
528 .Case(
"uint32_t",
"uint32_t")
529 .Case(
"NSUInteger",
"NSUInteger")
530 .Case(
"uint64_t",
"uint64_t")
531 .Default(StringRef());
532 if (!NSIntegralResust.empty())
533 return NSIntegralResust;
546 if (!InterfaceDecl) {
552 bool IsSubclass =
false;
564 bool NSAPI::isObjCTypedef(
QualType T,
575 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
583 bool NSAPI::isObjCEnumerator(
const Expr *E,
595 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
596 return EnumD->getIdentifier() == II;
606 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
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
static const unsigned NumNSStringMethods