[PATCH] Factor getObjCEncodingForPropertyType out of getObjCEncodingForPropertyDecl
Joe Groff
arcata at gmail.com
Mon Jul 7 11:14:22 PDT 2014
Hi everyone. I'd like to be able to get the type encoding of an ObjC
property by itself without forming an entire ObjCPropertyDecl. Here's a
small patch that factors ASTContext::getObjCEncodingForPropertyType out of
the larger getObjCEncodingForPropertyDecl method.
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140707/58636872/attachment.html>
-------------- next part --------------
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index b0de90c..4f78862 100644
--- a/include/clang/AST/ASTContext.h
+++ b/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/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 4250850..6526a77 100644
--- a/lib/AST/ASTContext.cpp
+++ b/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) {
More information about the cfe-commits
mailing list