ObjectiveC migrator. Introduce a new print policy for
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 9 Oct 2013 17:37:28 +0000 (17:37 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 9 Oct 2013 17:37:28 +0000 (17:37 +0000)
suppression of strong lifetime qualifiers when
inferring property. // rdar://15082812

llvm-svn: 192305

clang/include/clang/AST/PrettyPrinter.h
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/AST/TypePrinter.cpp
clang/test/ARCMT/objcmt-property.m.result

index adfd1ac..7642699 100644 (file)
@@ -39,8 +39,8 @@ struct PrintingPolicy {
       SuppressTagKeyword(false), SuppressTag(false), SuppressScope(false),
       SuppressUnwrittenScope(false), SuppressInitializers(false),
       ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
-      SuppressStrongLifetime(false), Bool(LO.Bool),
-      TerseOutput(false), PolishForDeclaration(false),
+      SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
+      Bool(LO.Bool), TerseOutput(false), PolishForDeclaration(false),
       MSWChar(LO.MicrosoftExt && !LO.WChar) { }
 
   /// \brief What language we're printing.
@@ -132,6 +132,10 @@ struct PrintingPolicy {
   /// ARC.
   unsigned SuppressStrongLifetime : 1;
   
+  /// \brief When true, suppress printing of lifetime qualifier in
+  /// ARC.
+  unsigned SuppressLifetimeQualifiers : 1;
+  
   /// \brief Whether we can use 'bool' rather than '_Bool', even if the language
   /// doesn't actually have 'bool' (because, e.g., it is defined as a macro).
   unsigned Bool : 1;
index 8d5395a..f1ab4fc 100644 (file)
@@ -324,6 +324,7 @@ static bool rewriteToObjCProperty(const ObjCMethodDecl *Getter,
   PropertyString += " ";
   PrintingPolicy SubPolicy(Context.getPrintingPolicy());
   SubPolicy.SuppressStrongLifetime = true;
+  SubPolicy.SuppressLifetimeQualifiers = true;
   std::string TypeString = RT.getAsString(SubPolicy);
   if (LengthOfPrefix > 0) {
     // property name must strip off "is" and lower case the first character
index ec7559c..571e3db 100644 (file)
@@ -36,7 +36,8 @@ namespace {
   public:
     explicit IncludeStrongLifetimeRAII(PrintingPolicy &Policy) 
       : Policy(Policy), Old(Policy.SuppressStrongLifetime) {
-      Policy.SuppressStrongLifetime = false;
+        if (!Policy.SuppressLifetimeQualifiers)
+          Policy.SuppressStrongLifetime = false;
     }
     
     ~IncludeStrongLifetimeRAII() {
index 29559bf..bd9b38b 100644 (file)
@@ -223,7 +223,7 @@ DEPRECATED
 @property (nonatomic, readonly) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
 @property (nonatomic, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
 
-@property (nonatomic, readonly) id (*expressionFuncptr)(__strong id, NSArray *__strong, NSMutableDictionary *__strong);
-@property (nonatomic) id (*MyFuncptr)(__strong id, NSArray *__strong, NSMutableDictionary *__strong);
+@property (nonatomic, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
+@property (nonatomic) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
 
 @end