diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-05-01 20:53:21 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-05-01 20:53:21 +0000 |
commit | a3ae52b63aff9d4478084e40b1f683f45eb06ab7 (patch) | |
tree | fd101b6df82cb56b1599a95aba528c79ef07b2db | |
parent | bcbf872e857d804a46559b8b2289306d1fab3f3b (diff) | |
download | clang-a3ae52b63aff9d4478084e40b1f683f45eb06ab7.tar.gz clang-a3ae52b63aff9d4478084e40b1f683f45eb06ab7.tar.bz2 clang-a3ae52b63aff9d4478084e40b1f683f45eb06ab7.tar.xz |
[documenting declaration]: Remove arc liftime qualifiers
when doccumenting declrations in comments.
// rdar://13757500
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180880 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/ASTContext.h | 13 | ||||
-rw-r--r-- | include/clang/AST/Type.h | 9 | ||||
-rw-r--r-- | lib/AST/DeclPrinter.cpp | 16 | ||||
-rw-r--r-- | test/Index/comment-unqualified-objc-pointer.m | 6 |
4 files changed, 23 insertions, 21 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index c56f7a830e..65f29c4815 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -1452,7 +1452,18 @@ public: qs.addObjCLifetime(lifetime); return getQualifiedType(type, qs); } - + + /// getUnqualifiedObjCPointerType - Returns version of + /// Objective-C pointer type with lifetime qualifier removed. + QualType getUnqualifiedObjCPointerType(QualType type) const { + if (!type.getTypePtr()->isObjCObjectPointerType() || + !type.getQualifiers().hasObjCLifetime()) + return type; + Qualifiers Qs = type.getQualifiers(); + Qs.removeObjCLifetime(); + return getQualifiedType(type.getUnqualifiedType(), Qs); + } + DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const; diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 67188c1c73..39f10d3393 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -853,10 +853,6 @@ 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) { @@ -4651,11 +4647,6 @@ inline QualType QualType::getUnqualifiedType() const { 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()) diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index fc990238cb..ba590d61c8 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -617,7 +617,7 @@ void DeclPrinter::VisitFieldDecl(FieldDecl *D) { if (!Policy.SuppressSpecifiers && D->isModulePrivate()) Out << "__module_private__ "; - Out << D->getType().getUnqualifiedObjCPointerType(). + Out << D->getASTContext().getUnqualifiedObjCPointerType(D->getType()). stream(Policy, D->getName()); if (D->isBitField()) { @@ -662,7 +662,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { Out << "__module_private__ "; } - QualType T = D->getType().getUnqualifiedObjCPointerType(); + QualType T = D->getASTContext().getUnqualifiedObjCPointerType(D->getType()); if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) T = Parm->getOriginalType(); T.print(Out, Policy, D->getName()); @@ -911,7 +911,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) { else Out << "+ "; if (!OMD->getResultType().isNull()) - Out << '(' << OMD->getResultType().getUnqualifiedObjCPointerType(). + Out << '(' << OMD->getASTContext().getUnqualifiedObjCPointerType(OMD->getResultType()). getAsString(Policy) << ")"; std::string name = OMD->getSelector().getAsString(); @@ -921,7 +921,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) { // FIXME: selector is missing here! pos = name.find_first_of(':', lastPos); Out << " " << name.substr(lastPos, pos - lastPos); - Out << ":(" << (*PI)->getType().getUnqualifiedObjCPointerType(). + Out << ":(" << (*PI)->getASTContext().getUnqualifiedObjCPointerType((*PI)->getType()). getAsString(Policy) << ')' << **PI; lastPos = pos + 1; } @@ -955,7 +955,7 @@ void DeclPrinter::VisitObjCImplementationDecl(ObjCImplementationDecl *OID) { Indentation += Policy.Indentation; for (ObjCImplementationDecl::ivar_iterator I = OID->ivar_begin(), E = OID->ivar_end(); I != E; ++I) { - Indent() << I->getType().getUnqualifiedObjCPointerType(). + Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()). getAsString(Policy) << ' ' << **I << ";\n"; } Indentation -= Policy.Indentation; @@ -994,7 +994,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) { Indentation += Policy.Indentation; for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(), E = OID->ivar_end(); I != E; ++I) { - Indent() << I->getType().getUnqualifiedObjCPointerType(). + Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()). getAsString(Policy) << ' ' << **I << ";\n"; } Indentation -= Policy.Indentation; @@ -1046,7 +1046,7 @@ void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) { Indentation += Policy.Indentation; for (ObjCCategoryDecl::ivar_iterator I = PID->ivar_begin(), E = PID->ivar_end(); I != E; ++I) { - Indent() << I->getType().getUnqualifiedObjCPointerType(). + Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()). getAsString(Policy) << ' ' << **I << ";\n"; } Indentation -= Policy.Indentation; @@ -1133,7 +1133,7 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) { (void) first; // Silence dead store warning due to idiomatic code. Out << " )"; } - Out << ' ' << PDecl->getType().getUnqualifiedObjCPointerType(). + Out << ' ' << PDecl->getASTContext().getUnqualifiedObjCPointerType(PDecl->getType()). getAsString(Policy) << ' ' << *PDecl; if (Policy.PolishForDeclaration) Out << ';'; diff --git a/test/Index/comment-unqualified-objc-pointer.m b/test/Index/comment-unqualified-objc-pointer.m index 2378845f9b..546d4fa9f0 100644 --- a/test/Index/comment-unqualified-objc-pointer.m +++ b/test/Index/comment-unqualified-objc-pointer.m @@ -14,8 +14,8 @@ NSString *Name; } //! This is WithLabel comment. -- (NSString *)WithLabel:(NSString *)label; -// CHECK: <Declaration>- (NSString *)WithLabel:(NSString *)label;</Declaration> +- (NSString *)WithLabel:(NSString * const)label; +// CHECK: <Declaration>- (NSString *)WithLabel:(NSString *const)label;</Declaration> //! This is a property to get the Name. @property (copy) NSString *Name; @@ -29,7 +29,7 @@ // CHECK: <Declaration>NSString *NickName</Declaration> } -- (NSString *)WithLabel:(NSString *)label { +- (NSString *)WithLabel:(NSString * const)label { return 0; } @synthesize Name = Name; |