]> granicus.if.org Git - clang/commitdiff
Add @encode support for complex types.
authorAnders Carlsson <andersca@mac.com>
Thu, 9 Apr 2009 21:55:45 +0000 (21:55 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 9 Apr 2009 21:55:45 +0000 (21:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68729 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/CodeGenObjC/encode-test-5.m [new file with mode: 0644]

index e976ccf967ae15d7af51a4c9040b06163a6b99ab..deeb7631917b1a2baff84029da56eee07c02848a 100644 (file)
@@ -2266,8 +2266,11 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     
       S += encoding;
     }
-  }
-  else if (T->isObjCQualifiedIdType()) {
+  } else if (const ComplexType *CT = T->getAsComplexType()) {
+    S += 'j';
+    getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, 0, false, 
+                               false);
+  } else if (T->isObjCQualifiedIdType()) {
     getObjCEncodingForTypeImpl(getObjCIdType(), S, 
                                ExpandPointedToStructures,
                                ExpandStructures, FD);
diff --git a/test/CodeGenObjC/encode-test-5.m b/test/CodeGenObjC/encode-test-5.m
new file mode 100644 (file)
index 0000000..970df3d
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: clang-cc -triple=i686-apple-darwin9 -fnext-runtime -emit-llvm -o %t %s &&
+
+// RUN: grep ji %t | count 1 &&
+char *a = @encode(_Complex int);
+
+// RUN: grep jf %t | count 1 &&
+char *b = @encode(_Complex float);
+
+// RUN: grep jd %t | count 1
+char *c = @encode(_Complex double);
+