r180860 - [ObjC declaration documentation] declaration of
Fariborz Jahanian
fjahanian at apple.com
Wed May 1 10:28:37 PDT 2013
Author: fjahanian
Date: Wed May 1 12:28:37 2013
New Revision: 180860
URL: http://llvm.org/viewvc/llvm-project?rev=180860&view=rev
Log:
[ObjC declaration documentation] declaration of
types involving Objective-C pointers must have
their arc qualifiers elided as they don't
add any additional info. // rdar://13757500.
Added:
cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/DeclPrinter.cpp
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=180860&r1=180859&r2=180860&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed May 1 12:28:37 2013
@@ -853,6 +853,10 @@ public:
return *this;
}
+ /// getUnqualifiedObjCPointerType - Returns the unqualified version if
+ /// Objective-C pointer type; otherwise, returns type as is.
+ inline QualType getUnqualifiedObjCPointerType() const;
+
/// operator==/!= - Indicate whether the specified types and qualifiers are
/// identical.
friend bool operator==(const QualType &LHS, const QualType &RHS) {
@@ -4648,6 +4652,11 @@ inline QualType QualType::getUnqualified
return QualType(getSplitUnqualifiedTypeImpl(*this).Ty, 0);
}
+inline QualType QualType::getUnqualifiedObjCPointerType() const {
+ return getTypePtr()->isObjCObjectPointerType() ?
+ getUnqualifiedType() : *this;
+}
+
inline SplitQualType QualType::getSplitUnqualifiedType() const {
if (!getTypePtr()->getCanonicalTypeInternal().hasLocalQualifiers())
return split();
@@ -4679,7 +4688,7 @@ inline void QualType::removeLocalCVRQual
inline unsigned QualType::getAddressSpace() const {
return getQualifiers().getAddressSpace();
}
-
+
/// getObjCGCAttr - Return the gc attribute of this type.
inline Qualifiers::GC QualType::getObjCGCAttr() const {
return getQualifiers().getObjCGCAttr();
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=180860&r1=180859&r2=180860&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Wed May 1 12:28:37 2013
@@ -617,7 +617,8 @@ void DeclPrinter::VisitFieldDecl(FieldDe
if (!Policy.SuppressSpecifiers && D->isModulePrivate())
Out << "__module_private__ ";
- Out << D->getType().stream(Policy, D->getName());
+ Out << D->getType().getUnqualifiedObjCPointerType().
+ stream(Policy, D->getName());
if (D->isBitField()) {
Out << " : ";
@@ -661,7 +662,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *
Out << "__module_private__ ";
}
- QualType T = D->getType();
+ QualType T = D->getType().getUnqualifiedObjCPointerType();
if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D))
T = Parm->getOriginalType();
T.print(Out, Policy, D->getName());
@@ -910,7 +911,8 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
else
Out << "+ ";
if (!OMD->getResultType().isNull())
- Out << '(' << OMD->getResultType().getAsString(Policy) << ")";
+ Out << '(' << OMD->getResultType().getUnqualifiedObjCPointerType().
+ getAsString(Policy) << ")";
std::string name = OMD->getSelector().getAsString();
std::string::size_type pos, lastPos = 0;
@@ -919,7 +921,8 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
// FIXME: selector is missing here!
pos = name.find_first_of(':', lastPos);
Out << " " << name.substr(lastPos, pos - lastPos);
- Out << ":(" << (*PI)->getType().getAsString(Policy) << ')' << **PI;
+ Out << ":(" << (*PI)->getType().getUnqualifiedObjCPointerType().
+ getAsString(Policy) << ')' << **PI;
lastPos = pos + 1;
}
@@ -952,7 +955,8 @@ void DeclPrinter::VisitObjCImplementatio
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";
+ Indent() << I->getType().getUnqualifiedObjCPointerType().
+ getAsString(Policy) << ' ' << **I << ";\n";
}
Indentation -= Policy.Indentation;
Out << "}\n";
@@ -990,7 +994,8 @@ void DeclPrinter::VisitObjCInterfaceDecl
Indentation += Policy.Indentation;
for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
E = OID->ivar_end(); I != E; ++I) {
- Indent() << I->getType().getAsString(Policy) << ' ' << **I << ";\n";
+ Indent() << I->getType().getUnqualifiedObjCPointerType().
+ getAsString(Policy) << ' ' << **I << ";\n";
}
Indentation -= Policy.Indentation;
Out << "}\n";
@@ -1041,7 +1046,8 @@ void DeclPrinter::VisitObjCCategoryDecl(
Indentation += Policy.Indentation;
for (ObjCCategoryDecl::ivar_iterator I = PID->ivar_begin(),
E = PID->ivar_end(); I != E; ++I) {
- Indent() << I->getType().getAsString(Policy) << ' ' << **I << ";\n";
+ Indent() << I->getType().getUnqualifiedObjCPointerType().
+ getAsString(Policy) << ' ' << **I << ";\n";
}
Indentation -= Policy.Indentation;
Out << "}\n";
@@ -1127,7 +1133,8 @@ void DeclPrinter::VisitObjCPropertyDecl(
(void) first; // Silence dead store warning due to idiomatic code.
Out << " )";
}
- Out << ' ' << PDecl->getType().getAsString(Policy) << ' ' << *PDecl;
+ Out << ' ' << PDecl->getType().getUnqualifiedObjCPointerType().
+ getAsString(Policy) << ' ' << *PDecl;
if (Policy.PolishForDeclaration)
Out << ';';
}
Added: cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-unqualified-objc-pointer.m?rev=180860&view=auto
==============================================================================
--- cfe/trunk/test/Index/comment-unqualified-objc-pointer.m (added)
+++ cfe/trunk/test/Index/comment-unqualified-objc-pointer.m Wed May 1 12:28:37 2013
@@ -0,0 +1,36 @@
+// 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 -fobjc-arc %s > %t/out
+// RUN: FileCheck %s < %t/out
+// rdar://13757500
+
+ at class NSString;
+
+ at interface NSArray @end
+
+ at interface NSMutableArray : NSArray
+{
+//! This is the name.
+ NSString *Name;
+}
+//! This is WithLabel comment.
+- (NSString *)WithLabel:(NSString *)label;
+// CHECK: <Declaration>- (NSString *)WithLabel:(NSString *)label;</Declaration>
+
+//! This is a property to get the Name.
+ at property (copy) NSString *Name;
+// CHECK: <Declaration>@property(readwrite, copy, atomic) NSString *Name;</Declaration>
+ at end
+
+ at implementation NSMutableArray
+{
+//! This is private ivar
+ NSString *NickName;
+// CHECK: <Declaration>NSString *NickName</Declaration>
+}
+
+- (NSString *)WithLabel:(NSString *)label {
+ return 0;
+}
+ at synthesize Name = Name;
+ at end
More information about the cfe-commits
mailing list