]> granicus.if.org Git - clang/commitdiff
[documenting declaration]: Remove arc liftime qualifiers
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 1 May 2013 20:53:21 +0000 (20:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 1 May 2013 20:53:21 +0000 (20:53 +0000)
when doccumenting declrations in comments.
// rdar://13757500

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180880 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
include/clang/AST/Type.h
lib/AST/DeclPrinter.cpp
test/Index/comment-unqualified-objc-pointer.m

index c56f7a830e1c8176516de5cc15e846e22bd8e3e9..65f29c4815f6ceda4acd0876f53e96bc75c18d11 100644 (file)
@@ -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;
 
index 67188c1c736aa608b6813bf5d6a41eaf9c480e81..39f10d3393bac57773db7eb58e4641ffdeff0ac7 100644 (file)
@@ -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())
index fc990238cb8356cefcfa0dad1f3336bc755ae383..ba590d61c8dc1e2ff4a30fe61b88f711750a0a02 100644 (file)
@@ -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 << ';';
index 2378845f9bfcb819e4d4b5fac949c1eba2925e7f..546d4fa9f0777e4f7f458e2dbff41ce4833f9299 100644 (file)
@@ -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;