]> granicus.if.org Git - clang/commitdiff
DeclObjC: Move computing the type of self into a separate function (NFC).
authorAdrian Prantl <aprantl@apple.com>
Wed, 8 Jul 2015 22:15:59 +0000 (22:15 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 8 Jul 2015 22:15:59 +0000 (22:15 +0000)
This function will be used for emitting debug info.

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

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 89d97920600cbc3f62171b0ed999b8ec4114dd6a..c42764b6f3bf185536122f1b47b4c79af1867e3d 100644 (file)
@@ -403,6 +403,11 @@ public:
   /// have already been created.
   void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID);
 
+  /// \return the type for \c self and set \arg selfIsPseudoStrong and
+  /// \arg selfIsConsumed accordingly.
+  QualType getSelfType(ASTContext &Context, const ObjCInterfaceDecl *OID,
+                       bool &selfIsPseudoStrong, bool &selfIsConsumed);
+
   ImplicitParamDecl * getSelfDecl() const { return SelfDecl; }
   void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; }
   ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
index 927988f960adfa4fb2c35b953d83e2b1bf387af9..280c412ae8ff3431e428ccc8fc9d972bf7d1c084 100644 (file)
@@ -945,9 +945,13 @@ ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const {
   return family;
 }
 
-void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
-                                          const ObjCInterfaceDecl *OID) {
+QualType ObjCMethodDecl::getSelfType(ASTContext &Context,
+                                     const ObjCInterfaceDecl *OID,
+                                     bool &selfIsPseudoStrong,
+                                     bool &selfIsConsumed) {
   QualType selfTy;
+  selfIsPseudoStrong = false;
+  selfIsConsumed = false;
   if (isInstanceMethod()) {
     // There may be no interface context due to error in declaration
     // of the interface (which has been reported). Recover gracefully.
@@ -960,9 +964,6 @@ void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
   } else // we have a factory method.
     selfTy = Context.getObjCClassType();
 
-  bool selfIsPseudoStrong = false;
-  bool selfIsConsumed = false;
-  
   if (Context.getLangOpts().ObjCAutoRefCount) {
     if (isInstanceMethod()) {
       selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
@@ -986,7 +987,14 @@ void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
       selfIsPseudoStrong = true;
     }
   }
+  return selfTy;
+}
 
+void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
+                                          const ObjCInterfaceDecl *OID) {
+  bool selfIsPseudoStrong, selfIsConsumed;
+  QualType selfTy =
+    getSelfType(Context, OID, selfIsPseudoStrong, selfIsConsumed);
   ImplicitParamDecl *self
     = ImplicitParamDecl::Create(Context, this, SourceLocation(),
                                 &Context.Idents.get("self"), selfTy);