diff options
author | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 554bcb69c2d785a011a30e7db87a36a87fe7db10 (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /include/clang/AST/NSAPI.h | |
parent | bb67ca86b31f67faee50bd10c3b036d65751745a (diff) | |
download | FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.zip FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.tar.gz |
Vendor import of clang trunk r161861:
http://llvm.org/svn/llvm-project/cfe/trunk@161861
Diffstat (limited to 'include/clang/AST/NSAPI.h')
-rw-r--r-- | include/clang/AST/NSAPI.h | 74 |
1 files changed, 71 insertions, 3 deletions
diff --git a/include/clang/AST/NSAPI.h b/include/clang/AST/NSAPI.h index 40e9759..51ae1da 100644 --- a/include/clang/AST/NSAPI.h +++ b/include/clang/AST/NSAPI.h @@ -11,11 +11,13 @@ #define LLVM_CLANG_AST_NSAPI_H #include "clang/Basic/IdentifierTable.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" namespace clang { class ASTContext; class QualType; + class Expr; // \brief Provides info and caches identifiers/selectors for NSFoundation API. class NSAPI { @@ -37,15 +39,33 @@ public: enum NSStringMethodKind { NSStr_stringWithString, + NSStr_stringWithUTF8String, + NSStr_stringWithCStringEncoding, + NSStr_stringWithCString, NSStr_initWithString }; - static const unsigned NumNSStringMethods = 2; + static const unsigned NumNSStringMethods = 5; IdentifierInfo *getNSClassId(NSClassIdKindKind K) const; /// \brief The Objective-C NSString selectors. Selector getNSStringSelector(NSStringMethodKind MK) const; + /// \brief Return NSStringMethodKind if \param Sel is such a selector. + llvm::Optional<NSStringMethodKind> getNSStringMethodKind(Selector Sel) const; + + /// \brief Returns true if the expression \param E is a reference of + /// "NSUTF8StringEncoding" enum constant. + bool isNSUTF8StringEncodingConstant(const Expr *E) const { + return isObjCEnumerator(E, "NSUTF8StringEncoding", NSUTF8StringEncodingId); + } + + /// \brief Returns true if the expression \param E is a reference of + /// "NSASCIIStringEncoding" enum constant. + bool isNSASCIIStringEncodingConstant(const Expr *E) const { + return isObjCEnumerator(E, "NSASCIIStringEncoding",NSASCIIStringEncodingId); + } + /// \brief Enumerates the NSArray methods used to generate literals. enum NSArrayMethodKind { NSArr_array, @@ -88,6 +108,35 @@ public: llvm::Optional<NSDictionaryMethodKind> getNSDictionaryMethodKind(Selector Sel); + /// \brief Returns selector for "objectForKeyedSubscript:". + Selector getObjectForKeyedSubscriptSelector() const { + return getOrInitSelector(StringRef("objectForKeyedSubscript"), + objectForKeyedSubscriptSel); + } + + /// \brief Returns selector for "objectAtIndexedSubscript:". + Selector getObjectAtIndexedSubscriptSelector() const { + return getOrInitSelector(StringRef("objectAtIndexedSubscript"), + objectAtIndexedSubscriptSel); + } + + /// \brief Returns selector for "setObject:forKeyedSubscript". + Selector getSetObjectForKeyedSubscriptSelector() const { + StringRef Ids[] = { "setObject", "forKeyedSubscript" }; + return getOrInitSelector(Ids, setObjectForKeyedSubscriptSel); + } + + /// \brief Returns selector for "setObject:atIndexedSubscript". + Selector getSetObjectAtIndexedSubscriptSelector() const { + StringRef Ids[] = { "setObject", "atIndexedSubscript" }; + return getOrInitSelector(Ids, setObjectAtIndexedSubscriptSel); + } + + /// \brief Returns selector for "isEqual:". + Selector getIsEqualSelector() const { + return getOrInitSelector(StringRef("isEqual"), isEqualSel); + } + /// \brief Enumerates the NSNumber methods used to generate literals. enum NSNumberLiteralMethodKind { NSNumberWithChar, @@ -126,10 +175,22 @@ public: /// \brief Determine the appropriate NSNumber factory method kind for a /// literal of the given type. - static llvm::Optional<NSNumberLiteralMethodKind> - getNSNumberFactoryMethodKind(QualType T); + llvm::Optional<NSNumberLiteralMethodKind> + getNSNumberFactoryMethodKind(QualType T) const; + + /// \brief Returns true if \param T is a typedef of "BOOL" in objective-c. + bool isObjCBOOLType(QualType T) const; + /// \brief Returns true if \param T is a typedef of "NSInteger" in objective-c. + bool isObjCNSIntegerType(QualType T) const; + /// \brief Returns true if \param T is a typedef of "NSUInteger" in objective-c. + bool isObjCNSUIntegerType(QualType T) const; private: + bool isObjCTypedef(QualType T, StringRef name, IdentifierInfo *&II) const; + bool isObjCEnumerator(const Expr *E, + StringRef name, IdentifierInfo *&II) const; + Selector getOrInitSelector(ArrayRef<StringRef> Ids, Selector &Sel) const; + ASTContext &Ctx; mutable IdentifierInfo *ClassIds[NumClassIds]; @@ -145,6 +206,13 @@ private: /// \brief The Objective-C NSNumber selectors used to create NSNumber literals. mutable Selector NSNumberClassSelectors[NumNSNumberLiteralMethods]; mutable Selector NSNumberInstanceSelectors[NumNSNumberLiteralMethods]; + + mutable Selector objectForKeyedSubscriptSel, objectAtIndexedSubscriptSel, + setObjectForKeyedSubscriptSel,setObjectAtIndexedSubscriptSel, + isEqualSel; + + mutable IdentifierInfo *BOOLId, *NSIntegerId, *NSUIntegerId; + mutable IdentifierInfo *NSASCIIStringEncodingId, *NSUTF8StringEncodingId; }; } // end namespace clang |