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::Float16:
445 case BuiltinType::Float128:
446 case BuiltinType::NullPtr:
447 case BuiltinType::ObjCClass:
448 case BuiltinType::ObjCId:
449 case BuiltinType::ObjCSel:
450 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 451 case BuiltinType::Id: 452 #include "clang/Basic/OpenCLImageTypes.def" 453 case BuiltinType::OCLSampler:
454 case BuiltinType::OCLEvent:
455 case BuiltinType::OCLClkEvent:
456 case BuiltinType::OCLQueue:
457 case BuiltinType::OCLReserveID:
458 case BuiltinType::BoundMember:
459 case BuiltinType::Dependent:
460 case BuiltinType::Overload:
461 case BuiltinType::UnknownAny:
462 case BuiltinType::ARCUnbridgedCast:
463 case BuiltinType::Half:
464 case BuiltinType::PseudoObject:
465 case BuiltinType::BuiltinFn:
466 case BuiltinType::OMPArraySection:
475 return isObjCTypedef(T,
"BOOL", BOOLId);
479 return isObjCTypedef(T,
"NSInteger", NSIntegerId);
483 return isObjCTypedef(T,
"NSUInteger", NSUIntegerId);
491 StringRef NSIntegralResust =
492 llvm::StringSwitch<StringRef>(
493 TDT->getDecl()->getDeclName().getAsIdentifierInfo()->getName())
494 .Case(
"int8_t",
"int8_t")
495 .Case(
"int16_t",
"int16_t")
496 .Case(
"int32_t",
"int32_t")
497 .Case(
"NSInteger",
"NSInteger")
498 .Case(
"int64_t",
"int64_t")
499 .Case(
"uint8_t",
"uint8_t")
500 .Case(
"uint16_t",
"uint16_t")
501 .Case(
"uint32_t",
"uint32_t")
502 .Case(
"NSUInteger",
"NSUInteger")
503 .Case(
"uint64_t",
"uint64_t")
504 .Default(StringRef());
505 if (!NSIntegralResust.empty())
506 return NSIntegralResust;
519 if (!InterfaceDecl) {
525 bool IsSubclass =
false;
548 if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
556 bool NSAPI::isObjCEnumerator(
const Expr *E,
568 EnumD = dyn_cast_or_null<EnumConstantDecl>(DRE->getDecl()))
569 return EnumD->getIdentifier() == II;
579 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.
EnumConstantDecl - 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
getIdentifier - 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...
Expr - This represents one expression.
Selector getNSArraySelector(NSArrayMethodKind MK) const
The Objective-C NSArray selectors.
const FunctionProtoType * T
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