From 98ac7d2d35fe032497142aa1a5905f49e6414929 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 7 Jul 2014 22:25:15 +0000 Subject: [PATCH] ASTContext: Factor 'getObjCEncodingForPropertyType' as its own method. It is useful to get the property encoding for an ObjC type without a full ObjCPropertyDecl. llvm-svn: 212496 --- clang/include/clang/AST/ASTContext.h | 4 ++++ clang/lib/AST/ASTContext.cpp | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 40ccf8484e0b..0a991cc4cee9 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1373,6 +1373,10 @@ public: void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr) const; + /// \brief Emit the Objective-C property type encoding for the given + /// type \p T into \p S. + void getObjCEncodingForPropertyType(QualType T, std::string &S) const; + void getLegacyIntegralTypeEncoding(QualType &t) const; /// \brief Put the string version of the type qualifiers \p QT into \p S. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 425085046714..6526a7775462 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -5022,9 +5022,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, // Encode result type. // GCC has some special rules regarding encoding of properties which // closely resembles encoding of ivars. - getObjCEncodingForTypeImpl(PD->getType(), S, true, true, nullptr, - true /* outermost type */, - true /* encoding for property */); + getObjCEncodingForPropertyType(PD->getType(), S); if (PD->isReadOnly()) { S += ",R"; @@ -5097,6 +5095,16 @@ void ASTContext::getObjCEncodingForType(QualType T, std::string& S, true /* outermost type */); } +void ASTContext::getObjCEncodingForPropertyType(QualType T, + std::string& S) const { + // Encode result type. + // GCC has some special rules regarding encoding of properties which + // closely resembles encoding of ivars. + getObjCEncodingForTypeImpl(T, S, true, true, nullptr, + true /* outermost type */, + true /* encoding property */); +} + static char getObjCEncodingForPrimitiveKind(const ASTContext *C, BuiltinType::Kind kind) { switch (kind) {