clang 19.0.0git
Public Types | Public Member Functions | Static Public Attributes | List of all members
clang::NSAPI Class Reference

#include "clang/AST/NSAPI.h"

Public Types

enum  NSClassIdKindKind {
  ClassId_NSObject , ClassId_NSString , ClassId_NSArray , ClassId_NSMutableArray ,
  ClassId_NSDictionary , ClassId_NSMutableDictionary , ClassId_NSNumber , ClassId_NSMutableSet ,
  ClassId_NSMutableOrderedSet , ClassId_NSValue
}
 
enum  NSStringMethodKind {
  NSStr_stringWithString , NSStr_stringWithUTF8String , NSStr_stringWithCStringEncoding , NSStr_stringWithCString ,
  NSStr_initWithString , NSStr_initWithUTF8String
}
 
enum  NSArrayMethodKind {
  NSArr_array , NSArr_arrayWithArray , NSArr_arrayWithObject , NSArr_arrayWithObjects ,
  NSArr_arrayWithObjectsCount , NSArr_initWithArray , NSArr_initWithObjects , NSArr_objectAtIndex ,
  NSMutableArr_replaceObjectAtIndex , NSMutableArr_addObject , NSMutableArr_insertObjectAtIndex , NSMutableArr_setObjectAtIndexedSubscript
}
 Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks. More...
 
enum  NSDictionaryMethodKind {
  NSDict_dictionary , NSDict_dictionaryWithDictionary , NSDict_dictionaryWithObjectForKey , NSDict_dictionaryWithObjectsForKeys ,
  NSDict_dictionaryWithObjectsForKeysCount , NSDict_dictionaryWithObjectsAndKeys , NSDict_initWithDictionary , NSDict_initWithObjectsAndKeys ,
  NSDict_initWithObjectsForKeys , NSDict_objectForKey , NSMutableDict_setObjectForKey , NSMutableDict_setObjectForKeyedSubscript ,
  NSMutableDict_setValueForKey
}
 Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some checks. More...
 
enum  NSSetMethodKind {
  NSMutableSet_addObject , NSOrderedSet_insertObjectAtIndex , NSOrderedSet_setObjectAtIndex , NSOrderedSet_setObjectAtIndexedSubscript ,
  NSOrderedSet_replaceObjectAtIndexWithObject
}
 Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks. More...
 
enum  NSNumberLiteralMethodKind {
  NSNumberWithChar , NSNumberWithUnsignedChar , NSNumberWithShort , NSNumberWithUnsignedShort ,
  NSNumberWithInt , NSNumberWithUnsignedInt , NSNumberWithLong , NSNumberWithUnsignedLong ,
  NSNumberWithLongLong , NSNumberWithUnsignedLongLong , NSNumberWithFloat , NSNumberWithDouble ,
  NSNumberWithBool , NSNumberWithInteger , NSNumberWithUnsignedInteger
}
 Enumerates the NSNumber methods used to generate literals. More...
 

Public Member Functions

 NSAPI (ASTContext &Ctx)
 
ASTContextgetASTContext () const
 
IdentifierInfogetNSClassId (NSClassIdKindKind K) const
 
Selector getNSStringSelector (NSStringMethodKind MK) const
 The Objective-C NSString selectors.
 
bool isNSUTF8StringEncodingConstant (const Expr *E) const
 Returns true if the expression.
 
bool isNSASCIIStringEncodingConstant (const Expr *E) const
 Returns true if the expression.
 
Selector getNSArraySelector (NSArrayMethodKind MK) const
 The Objective-C NSArray selectors.
 
std::optional< NSArrayMethodKindgetNSArrayMethodKind (Selector Sel)
 Return NSArrayMethodKind if Sel is such a selector.
 
Selector getNSDictionarySelector (NSDictionaryMethodKind MK) const
 The Objective-C NSDictionary selectors.
 
std::optional< NSDictionaryMethodKindgetNSDictionaryMethodKind (Selector Sel)
 Return NSDictionaryMethodKind if Sel is such a selector.
 
Selector getNSSetSelector (NSSetMethodKind MK) const
 The Objective-C NSSet selectors.
 
std::optional< NSSetMethodKindgetNSSetMethodKind (Selector Sel)
 Return NSSetMethodKind if Sel is such a selector.
 
Selector getObjectForKeyedSubscriptSelector () const
 Returns selector for "objectForKeyedSubscript:".
 
Selector getObjectAtIndexedSubscriptSelector () const
 Returns selector for "objectAtIndexedSubscript:".
 
Selector getSetObjectForKeyedSubscriptSelector () const
 Returns selector for "setObject:forKeyedSubscript".
 
Selector getSetObjectAtIndexedSubscriptSelector () const
 Returns selector for "setObject:atIndexedSubscript".
 
Selector getIsEqualSelector () const
 Returns selector for "isEqual:".
 
Selector getNewSelector () const
 
Selector getInitSelector () const
 
Selector getNSNumberLiteralSelector (NSNumberLiteralMethodKind MK, bool Instance) const
 The Objective-C NSNumber selectors used to create NSNumber literals.
 
bool isNSNumberLiteralSelector (NSNumberLiteralMethodKind MK, Selector Sel) const
 
std::optional< NSNumberLiteralMethodKindgetNSNumberLiteralMethodKind (Selector Sel) const
 Return NSNumberLiteralMethodKind if Sel is such a selector.
 
std::optional< NSNumberLiteralMethodKindgetNSNumberFactoryMethodKind (QualType T) const
 Determine the appropriate NSNumber factory method kind for a literal of the given type.
 
bool isObjCBOOLType (QualType T) const
 Returns true if.
 
bool isObjCNSIntegerType (QualType T) const
 Returns true if.
 
bool isObjCNSUIntegerType (QualType T) const
 Returns true if.
 
StringRef GetNSIntegralKind (QualType T) const
 Returns one of NSIntegral typedef names if.
 
bool isMacroDefined (StringRef Id) const
 Returns true if Id is currently defined as a macro.
 
bool isSubclassOfNSClass (ObjCInterfaceDecl *InterfaceDecl, NSClassIdKindKind NSClassKind) const
 Returns true if InterfaceDecl is subclass of NSClassKind.
 

Static Public Attributes

static const unsigned NumClassIds = 10
 
static const unsigned NumNSStringMethods = 6
 
static const unsigned NumNSArrayMethods = 12
 
static const unsigned NumNSDictionaryMethods = 13
 
static const unsigned NumNSSetMethods = 5
 
static const unsigned NumNSNumberLiteralMethods = 15
 

Detailed Description

Definition at line 23 of file NSAPI.h.

Member Enumeration Documentation

◆ NSArrayMethodKind

Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks.

Enumerator
NSArr_array 
NSArr_arrayWithArray 
NSArr_arrayWithObject 
NSArr_arrayWithObjects 
NSArr_arrayWithObjectsCount 
NSArr_initWithArray 
NSArr_initWithObjects 
NSArr_objectAtIndex 
NSMutableArr_replaceObjectAtIndex 
NSMutableArr_addObject 
NSMutableArr_insertObjectAtIndex 
NSMutableArr_setObjectAtIndexedSubscript 

Definition at line 72 of file NSAPI.h.

◆ NSClassIdKindKind

Enumerator
ClassId_NSObject 
ClassId_NSString 
ClassId_NSArray 
ClassId_NSMutableArray 
ClassId_NSDictionary 
ClassId_NSMutableDictionary 
ClassId_NSNumber 
ClassId_NSMutableSet 
ClassId_NSMutableOrderedSet 
ClassId_NSValue 

Definition at line 29 of file NSAPI.h.

◆ NSDictionaryMethodKind

Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some checks.

Enumerator
NSDict_dictionary 
NSDict_dictionaryWithDictionary 
NSDict_dictionaryWithObjectForKey 
NSDict_dictionaryWithObjectsForKeys 
NSDict_dictionaryWithObjectsForKeysCount 
NSDict_dictionaryWithObjectsAndKeys 
NSDict_initWithDictionary 
NSDict_initWithObjectsAndKeys 
NSDict_initWithObjectsForKeys 
NSDict_objectForKey 
NSMutableDict_setObjectForKey 
NSMutableDict_setObjectForKeyedSubscript 
NSMutableDict_setValueForKey 

Definition at line 96 of file NSAPI.h.

◆ NSNumberLiteralMethodKind

Enumerates the NSNumber methods used to generate literals.

Enumerator
NSNumberWithChar 
NSNumberWithUnsignedChar 
NSNumberWithShort 
NSNumberWithUnsignedShort 
NSNumberWithInt 
NSNumberWithUnsignedInt 
NSNumberWithLong 
NSNumberWithUnsignedLong 
NSNumberWithLongLong 
NSNumberWithUnsignedLongLong 
NSNumberWithFloat 
NSNumberWithDouble 
NSNumberWithBool 
NSNumberWithInteger 
NSNumberWithUnsignedInteger 

Definition at line 174 of file NSAPI.h.

◆ NSSetMethodKind

Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.

Enumerator
NSMutableSet_addObject 
NSOrderedSet_insertObjectAtIndex 
NSOrderedSet_setObjectAtIndex 
NSOrderedSet_setObjectAtIndexedSubscript 
NSOrderedSet_replaceObjectAtIndexWithObject 

Definition at line 121 of file NSAPI.h.

◆ NSStringMethodKind

Enumerator
NSStr_stringWithString 
NSStr_stringWithUTF8String 
NSStr_stringWithCStringEncoding 
NSStr_stringWithCString 
NSStr_initWithString 
NSStr_initWithUTF8String 

Definition at line 43 of file NSAPI.h.

Constructor & Destructor Documentation

◆ NSAPI()

NSAPI::NSAPI ( ASTContext Ctx)
explicit

Definition at line 18 of file NSAPI.cpp.

Member Function Documentation

◆ getASTContext()

ASTContext & clang::NSAPI::getASTContext ( ) const
inline

◆ getInitSelector()

Selector clang::NSAPI::getInitSelector ( ) const
inline

Definition at line 169 of file NSAPI.h.

◆ getIsEqualSelector()

Selector clang::NSAPI::getIsEqualSelector ( ) const
inline

Returns selector for "isEqual:".

Definition at line 161 of file NSAPI.h.

◆ getNewSelector()

Selector clang::NSAPI::getNewSelector ( ) const
inline

Definition at line 165 of file NSAPI.h.

◆ getNSArrayMethodKind()

std::optional< NSAPI::NSArrayMethodKind > NSAPI::getNSArrayMethodKind ( Selector  Sel)

Return NSArrayMethodKind if Sel is such a selector.

Definition at line 138 of file NSAPI.cpp.

References getNSArraySelector(), and NumNSArrayMethods.

◆ getNSArraySelector()

Selector NSAPI::getNSArraySelector ( NSArrayMethodKind  MK) const

◆ getNSClassId()

IdentifierInfo * NSAPI::getNSClassId ( NSClassIdKindKind  K) const

◆ getNSDictionaryMethodKind()

std::optional< NSAPI::NSDictionaryMethodKind > NSAPI::getNSDictionaryMethodKind ( Selector  Sel)

Return NSDictionaryMethodKind if Sel is such a selector.

Definition at line 226 of file NSAPI.cpp.

References getNSDictionarySelector(), and NumNSDictionaryMethods.

◆ getNSDictionarySelector()

Selector NSAPI::getNSDictionarySelector ( NSDictionaryMethodKind  MK) const

◆ GetNSIntegralKind()

StringRef NSAPI::GetNSIntegralKind ( QualType  T) const

Returns one of NSIntegral typedef names if.

Parameters
Tis a typedef of that name in objective-c.

Definition at line 488 of file NSAPI.cpp.

References clang::FunctionProtoType::desugar(), clang::Type::getAs(), clang::ASTContext::getLangOpts(), and clang::T.

◆ getNSNumberFactoryMethodKind()

std::optional< NSAPI::NSNumberLiteralMethodKind > NSAPI::getNSNumberFactoryMethodKind ( QualType  T) const

◆ getNSNumberLiteralMethodKind()

std::optional< NSAPI::NSNumberLiteralMethodKind > NSAPI::getNSNumberLiteralMethodKind ( Selector  Sel) const

Return NSNumberLiteralMethodKind if Sel is such a selector.

Definition at line 338 of file NSAPI.cpp.

References isNSNumberLiteralSelector(), and NumNSNumberLiteralMethods.

Referenced by rewriteToNumberLiteral(), and rewriteToNumericBoxedExpression().

◆ getNSNumberLiteralSelector()

Selector NSAPI::getNSNumberLiteralSelector ( NSNumberLiteralMethodKind  MK,
bool  Instance 
) const

The Objective-C NSNumber selectors used to create NSNumber literals.

Parameters
Instanceif true it will return the selector for the init* method otherwise it will return the selector for the number* method.

Definition at line 285 of file NSAPI.cpp.

References clang::IdentifierTable::get(), clang::SelectorTable::getUnarySelector(), clang::ASTContext::Idents, NumNSNumberLiteralMethods, and clang::ASTContext::Selectors.

Referenced by isNSNumberLiteralSelector().

◆ getNSSetMethodKind()

std::optional< NSAPI::NSSetMethodKind > NSAPI::getNSSetMethodKind ( Selector  Sel)

Return NSSetMethodKind if Sel is such a selector.

Definition at line 275 of file NSAPI.cpp.

References getNSSetSelector(), and NumNSSetMethods.

◆ getNSSetSelector()

Selector NSAPI::getNSSetSelector ( NSSetMethodKind  MK) const

◆ getNSStringSelector()

Selector NSAPI::getNSStringSelector ( NSStringMethodKind  MK) const

◆ getObjectAtIndexedSubscriptSelector()

Selector clang::NSAPI::getObjectAtIndexedSubscriptSelector ( ) const
inline

Returns selector for "objectAtIndexedSubscript:".

Definition at line 143 of file NSAPI.h.

Referenced by rewriteToArraySubscriptGet().

◆ getObjectForKeyedSubscriptSelector()

Selector clang::NSAPI::getObjectForKeyedSubscriptSelector ( ) const
inline

Returns selector for "objectForKeyedSubscript:".

Definition at line 137 of file NSAPI.h.

Referenced by rewriteToDictionarySubscriptGet().

◆ getSetObjectAtIndexedSubscriptSelector()

Selector clang::NSAPI::getSetObjectAtIndexedSubscriptSelector ( ) const
inline

Returns selector for "setObject:atIndexedSubscript".

Definition at line 155 of file NSAPI.h.

Referenced by rewriteToArraySubscriptSet().

◆ getSetObjectForKeyedSubscriptSelector()

Selector clang::NSAPI::getSetObjectForKeyedSubscriptSelector ( ) const
inline

Returns selector for "setObject:forKeyedSubscript".

Definition at line 149 of file NSAPI.h.

Referenced by rewriteToDictionarySubscriptSet().

◆ isMacroDefined()

bool NSAPI::isMacroDefined ( StringRef  Id) const

Returns true if Id is currently defined as a macro.

Definition at line 514 of file NSAPI.cpp.

References clang::IdentifierTable::get(), clang::IdentifierInfo::hasMacroDefinition(), Id, and clang::ASTContext::Idents.

Referenced by rewriteToObjCProperty().

◆ isNSASCIIStringEncodingConstant()

bool clang::NSAPI::isNSASCIIStringEncodingConstant ( const Expr E) const
inline

Returns true if the expression.

Parameters
Eis a reference of "NSASCIIStringEncoding" enum constant.

Definition at line 66 of file NSAPI.h.

Referenced by rewriteToStringBoxedExpression().

◆ isNSNumberLiteralSelector()

bool clang::NSAPI::isNSNumberLiteralSelector ( NSNumberLiteralMethodKind  MK,
Selector  Sel 
) const
inline

◆ isNSUTF8StringEncodingConstant()

bool clang::NSAPI::isNSUTF8StringEncodingConstant ( const Expr E) const
inline

Returns true if the expression.

Parameters
Eis a reference of "NSUTF8StringEncoding" enum constant.

Definition at line 60 of file NSAPI.h.

Referenced by rewriteToStringBoxedExpression().

◆ isObjCBOOLType()

bool NSAPI::isObjCBOOLType ( QualType  T) const

Returns true if.

Parameters
Tis a typedef of "BOOL" in objective-c.

Definition at line 476 of file NSAPI.cpp.

References clang::T.

Referenced by getNSNumberFactoryMethodKind().

◆ isObjCNSIntegerType()

bool NSAPI::isObjCNSIntegerType ( QualType  T) const

Returns true if.

Parameters
Tis a typedef of "NSInteger" in objective-c.

Definition at line 480 of file NSAPI.cpp.

References clang::T.

Referenced by getNSNumberFactoryMethodKind().

◆ isObjCNSUIntegerType()

bool NSAPI::isObjCNSUIntegerType ( QualType  T) const

Returns true if.

Parameters
Tis a typedef of "NSUInteger" in objective-c.

Definition at line 484 of file NSAPI.cpp.

References clang::T.

Referenced by getNSNumberFactoryMethodKind().

◆ isSubclassOfNSClass()

bool NSAPI::isSubclassOfNSClass ( ObjCInterfaceDecl InterfaceDecl,
NSClassIdKindKind  NSClassKind 
) const

Returns true if InterfaceDecl is subclass of NSClassKind.

Definition at line 519 of file NSAPI.cpp.

References clang::NamedDecl::getIdentifier(), getNSClassId(), and clang::ObjCInterfaceDecl::getSuperClass().

Member Data Documentation

◆ NumClassIds

const unsigned clang::NSAPI::NumClassIds = 10
static

Definition at line 41 of file NSAPI.h.

Referenced by getNSClassId().

◆ NumNSArrayMethods

const unsigned clang::NSAPI::NumNSArrayMethods = 12
static

Definition at line 86 of file NSAPI.h.

Referenced by getNSArrayMethodKind().

◆ NumNSDictionaryMethods

const unsigned clang::NSAPI::NumNSDictionaryMethods = 13
static

Definition at line 111 of file NSAPI.h.

Referenced by getNSDictionaryMethodKind().

◆ NumNSNumberLiteralMethods

const unsigned clang::NSAPI::NumNSNumberLiteralMethods = 15
static

◆ NumNSSetMethods

const unsigned clang::NSAPI::NumNSSetMethods = 5
static

Definition at line 128 of file NSAPI.h.

Referenced by getNSSetMethodKind().

◆ NumNSStringMethods

const unsigned clang::NSAPI::NumNSStringMethods = 6
static

Definition at line 51 of file NSAPI.h.


The documentation for this class was generated from the following files: