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
This commit is contained in:
Joe Groff 2014-07-07 22:25:15 +00:00
parent 70af1fdf9d
commit 98ac7d2d35
2 changed files with 15 additions and 3 deletions

View File

@ -1373,6 +1373,10 @@ public:
void getObjCEncodingForType(QualType T, std::string &S, void getObjCEncodingForType(QualType T, std::string &S,
const FieldDecl *Field=nullptr) const; 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; void getLegacyIntegralTypeEncoding(QualType &t) const;
/// \brief Put the string version of the type qualifiers \p QT into \p S. /// \brief Put the string version of the type qualifiers \p QT into \p S.

View File

@ -5022,9 +5022,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
// Encode result type. // Encode result type.
// GCC has some special rules regarding encoding of properties which // GCC has some special rules regarding encoding of properties which
// closely resembles encoding of ivars. // closely resembles encoding of ivars.
getObjCEncodingForTypeImpl(PD->getType(), S, true, true, nullptr, getObjCEncodingForPropertyType(PD->getType(), S);
true /* outermost type */,
true /* encoding for property */);
if (PD->isReadOnly()) { if (PD->isReadOnly()) {
S += ",R"; S += ",R";
@ -5097,6 +5095,16 @@ void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
true /* outermost type */); 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, static char getObjCEncodingForPrimitiveKind(const ASTContext *C,
BuiltinType::Kind kind) { BuiltinType::Kind kind) {
switch (kind) { switch (kind) {