[cfe-commits] r169193 - in /cfe/trunk: lib/AST/DeclPrinter.cpp test/Index/comment-objc-decls.m

Fariborz Jahanian fjahanian at apple.com
Mon Dec 3 16:47:33 PST 2012


Author: fjahanian
Date: Mon Dec  3 18:47:33 2012
New Revision: 169193

URL: http://llvm.org/viewvc/llvm-project?rev=169193&view=rev
Log:
Testing objective-C declarations embedded in
<declaration> tag of Comment XML and fixed a
missing declaration of ivars private to @implementation
as result of the testing. // rdar://12378714

Added:
    cfe/trunk/test/Index/comment-objc-decls.m
Modified:
    cfe/trunk/lib/AST/DeclPrinter.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=169193&r1=169192&r2=169193&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Dec  3 18:47:33 2012
@@ -893,7 +893,17 @@
     Out << "@implementation " << I << " : " << *SID;
   else
     Out << "@implementation " << I;
-  Out << "\n";
+  
+  if (OID->ivar_size() > 0) {
+    Out << "{\n";
+    Indentation += Policy.Indentation;
+    for (ObjCImplementationDecl::ivar_iterator I = OID->ivar_begin(),
+         E = OID->ivar_end(); I != E; ++I) {
+      Indent() << I->getType().getAsString(Policy) << ' ' << **I << ";\n";
+    }
+    Indentation -= Policy.Indentation;
+    Out << "}\n";
+  }
   VisitDeclContext(OID, false);
   Out << "@end";
 }

Added: cfe/trunk/test/Index/comment-objc-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-objc-decls.m?rev=169193&view=auto
==============================================================================
--- cfe/trunk/test/Index/comment-objc-decls.m (added)
+++ cfe/trunk/test/Index/comment-objc-decls.m Mon Dec  3 18:47:33 2012
@@ -0,0 +1,160 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s > %t/out
+// RUN: FileCheck %s < %t/out
+
+// Ensure that XML we generate is not invalid.
+// RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// WRONG-NOT: CommentXMLInvalid
+
+// rdar://12378714
+
+/**
+ * \brief This is a protocol definition
+*/
+ at protocol MyProto
+ at optional
+/**
+ * \brief MethodMyProto method
+ * \param[in] anObject input value
+ * \param[in] range output value is unsigned int
+ * \result return index
+ */
+- (unsigned int)MethodMyProto:(id)anObject inRange:(unsigned int)range;
+/**
+ * \brief PropertyMyProto - This is protocol's property.
+*/
+ at property (copy) id PropertyMyProto;
+/**
+ * \brief ClassMethodMyProto
+*/
++ ClassMethodMyProto;
+ at end
+// CHECK: <Declaration>@protocol MyProto\n at end</Declaration>
+// CHECK: <Declaration>- (unsigned int) MethodMyProto:(id)anObject inRange:(unsigned int)range</Declaration>
+// CHECK: <Declaration>@optional\n at property ( readwrite,copy,atomic ) id PropertyMyProto</Declaration>
+// CHECK: <Declaration>+ (id) ClassMethodMyProto</Declaration>
+
+/**
+ * \brief NSObject is the root class.
+*/
+ at interface NSObject {
+/**
+ * \brief IvarNSObject
+*/
+  id IvarNSObject;
+}
+ at end
+// CHECK: Declaration>@interface NSObject{\n    id IvarNSObject;\n}\n at end</Declaration>
+// CHECK: <Declaration>id IvarNSObject</Declaration>
+
+/**
+ * \brief MyClass - primary class.
+*/
+ at interface MyClass : NSObject<MyProto>
+{
+/**
+ * \brief IvarMyClass - IvarMyClass of values.
+*/
+  id IvarMyClass;
+}
+/**
+ * \brief MethodMyClass is instance method.
+*/
+- MethodMyClass;
+
+/**
+ * \brief ClassMethodMyClass is class method.
+*/
++ ClassMethodMyClass;
+
+/**
+ * \brief PropertyMyClass - This is class's property.
+*/
+ at property (copy) id PropertyMyClass;
+ at end
+// CHECK: <Declaration>@interface MyClass : NSObject<MyProto> {\n    id IvarMyClass;\n}\n at end</Declaration>
+// CHECK: <Declaration>id IvarMyClass</Declaration>
+// CHECK: <Declaration>- (id) MethodMyClass</Declaration>
+// CHECK: <Declaration>+ (id) ClassMethodMyClass</Declaration>
+// CHECK: <Declaration>@property ( readwrite,copy,atomic ) id PropertyMyClass</Declaration
+
+/**
+ * \brief MyClass (Category) is private to MyClass.
+*/
+ at interface MyClass (Category)
+/**
+ * \brief This is private to MyClass
+ */
+- (void)MethodMyClassCategory;
+
+/**
+ * \brief PropertyMyClassCategory - This is class's private property.
+*/
+ at property (copy) id PropertyMyClassCategory;
+ at end
+// CHECK: <Declaration>@interface MyClass(Category)\n at end</Declaration>
+// CHECK: <Declaration>- (void) MethodMyClassCategory</Declaration>
+// CHECK: <Declaration>@property ( readwrite,copy,atomic ) id PropertyMyClassCategory</Declaration>
+// CHECK: <Declaration>- (id) PropertyMyClassCategory</Declaration>
+// CHECK: <Declaration>- (void) setPropertyMyClassCategory:(id)arg</Declaration>
+
+/// @implementation's
+
+/**
+ * \brief implementation of MyClass class.
+*/
+ at implementation MyClass {
+/**
+ * \brief IvarPrivateToMyClassImpl.
+*/
+  id IvarPrivateToMyClassImpl;
+}
+/**
+ * \brief MethodMyClass is instance method implementation.
+*/
+- MethodMyClass {
+  return 0;
+}
+
+/**
+ * \brief ClassMethodMyClass is class method implementation.
+*/
++ ClassMethodMyClass {
+  return 0;
+}
+ at end
+// CHECK: <Declaration>@implementation MyClass{\n    id IvarPrivateToMyClassImpl;\n    id _PropertyMyClass;\n}\n at end</Declaration>
+// CHECK: <Declaration>id IvarPrivateToMyClassImpl</Declaration>
+// CHECK: <Declaration>- (id) MethodMyClass</Declaration>
+// CHECK: <Declaration>+ (id) ClassMethodMyClass</Declaration>
+
+/**
+ * \brief MyClass (Category) is implementation of private to MyClass.
+*/
+ at implementation MyClass (Category)
+/**
+ * \brief This is private to MyClass
+ */
+- (void)MethodMyClassCategory {}
+/**
+ * \brief property getter
+*/
+- (id) PropertyMyClassCategory { return 0; }
+
+/**
+ * \brief property setter
+*/
+- (void) setPropertyMyClassCategory : (id) arg {}
+ at end
+// CHECK: <Declaration>@implementation MyClass(Category)\n at end</Declaration>
+// CHECK: <Declaration>- (void) MethodMyClassCategory</Declaration>
+// CHECK: <Declaration>- (id) PropertyMyClassCategory</Declaration>
+// CHECK: <Declaration>- (void) setPropertyMyClassCategory:(id)arg</Declaration>
+
+/**
+ * \brief NSObject implementation
+*/
+ at implementation NSObject
+ at end
+// CHECK: <Declaration>@implementation NSObject at end</Declaration>





More information about the cfe-commits mailing list