r180880 - [documenting declaration]: Remove arc liftime qualifiers
Fariborz Jahanian
fjahanian at apple.com
Wed May 1 13:53:21 PDT 2013
Author: fjahanian
Date: Wed May 1 15:53:21 2013
New Revision: 180880
URL: http://llvm.org/viewvc/llvm-project?rev=180880&view=rev
Log:
[documenting declaration]: Remove arc liftime qualifiers
when doccumenting declrations in comments.
// rdar://13757500
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Index/comment-unqualified-objc-pointer.m
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=180880&r1=180879&r2=180880&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 1 15:53:21 2013
@@ -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;
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=180880&r1=180879&r2=180880&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed May 1 15:53:21 2013
@@ -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::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())
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=180880&r1=180879&r2=180880&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Wed May 1 15:53:21 2013
@@ -617,7 +617,7 @@ void DeclPrinter::VisitFieldDecl(FieldDe
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 *
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(Ob
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(Ob
// 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::VisitObjCImplementatio
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
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(
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(
(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 << ';';
Modified: 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=180880&r1=180879&r2=180880&view=diff
==============================================================================
--- cfe/trunk/test/Index/comment-unqualified-objc-pointer.m (original)
+++ cfe/trunk/test/Index/comment-unqualified-objc-pointer.m Wed May 1 15:53:21 2013
@@ -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;
More information about the cfe-commits
mailing list