]> granicus.if.org Git - clang/commitdiff
Type encoding for structs.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 13 Nov 2007 23:21:38 +0000 (23:21 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 13 Nov 2007 23:21:38 +0000 (23:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44087 91177308-0d34-0410-b5e6-96231b3b80d8

AST/ASTContext.cpp
test/Sema/metadata-test-2.m [new file with mode: 0644]

index 132224cbd70642b6d570a4838351e782f2934459..b844adf4318ba02d8aaadbb35b2b3dacb1dfbd9b 100644 (file)
@@ -1050,8 +1050,18 @@ void ASTContext::getObjcEncodingForType(QualType T, std::string& S) const
     S += ']';
   } else if (T->getAsFunctionType()) {
     S += '?';
+  } else if (const RecordType *RTy = T->getAsRecordType()) {
+    RecordDecl *RDecl= RTy->getDecl();
+    S += '{';
+    S += RDecl->getName();
+    S += '=';
+    for (int i = 0; i < RDecl->getNumMembers(); i++) {
+      FieldDecl *field = RDecl->getMember(i);
+      getObjcEncodingForType(field->getType(), S);
+    }
+    S += '}';
   } else
-    assert(0 && "@encode for type not implemented!");
+      assert(0 && "@encode for type not implemented!");
 }
 
 void ASTContext::getObjcEncodingForTypeQualifier(Decl::ObjcDeclQualifier QT, 
diff --git a/test/Sema/metadata-test-2.m b/test/Sema/metadata-test-2.m
new file mode 100644 (file)
index 0000000..dbaf035
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: clang -rewrite-test %s
+
+typedef struct _NSPoint {
+    float x;
+    float y;
+} NSPoint;
+
+@interface Intf
+- (void) MyMeth : (NSPoint) Arg1;
+@end
+
+@implementation Intf
+- (void) MyMeth : (NSPoint) Arg1{}
+@end
+