@@ -1391,6 +1391,13 @@ void DeclPrinter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *AID) {
1391
1391
1392
1392
// / PrintObjCPropertyDecl - print a property declaration.
1393
1393
// /
1394
+ // / Print attributes in the following order:
1395
+ // / - class
1396
+ // / - nonatomic | atomic
1397
+ // / - assign | retain | strong | copy | weak | unsafe_unretained
1398
+ // / - readwrite | readonly
1399
+ // / - getter & setter
1400
+ // / - nullability
1394
1401
void DeclPrinter::VisitObjCPropertyDecl (ObjCPropertyDecl *PDecl) {
1395
1402
if (PDecl->getPropertyImplementation () == ObjCPropertyDecl::Required)
1396
1403
Out << " @required\n " ;
@@ -1402,58 +1409,69 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
1402
1409
Out << " @property" ;
1403
1410
if (PDecl->getPropertyAttributes () != ObjCPropertyDecl::OBJC_PR_noattr) {
1404
1411
bool first = true ;
1405
- Out << " (" ;
1406
- if (PDecl->getPropertyAttributes () &
1407
- ObjCPropertyDecl::OBJC_PR_readonly) {
1408
- Out << (first ? ' ' : ' ,' ) << " readonly" ;
1412
+ Out << " (" ;
1413
+ if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_class) {
1414
+ Out << (first ? " " : " , " ) << " class" ;
1409
1415
first = false ;
1410
1416
}
1411
1417
1412
- if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_getter) {
1413
- Out << (first ? ' ' : ' , ' ) << " getter = " ;
1414
- PDecl-> getGetterName (). print (Out) ;
1418
+ if (PDecl->getPropertyAttributes () &
1419
+ ObjCPropertyDecl::OBJC_PR_nonatomic) {
1420
+ Out << (first ? " " : " , " ) << " nonatomic " ;
1415
1421
first = false ;
1416
1422
}
1417
- if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_setter) {
1418
- Out << (first ? ' ' : ' , ' ) << " setter = " ;
1419
- PDecl-> getSetterName (). print (Out) ;
1423
+ if (PDecl->getPropertyAttributes () &
1424
+ ObjCPropertyDecl::OBJC_PR_atomic) {
1425
+ Out << (first ? " " : " , " ) << " atomic " ;
1420
1426
first = false ;
1421
1427
}
1422
1428
1423
1429
if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_assign) {
1424
- Out << (first ? ' ' : ' ,' ) << " assign" ;
1425
- first = false ;
1426
- }
1427
-
1428
- if (PDecl->getPropertyAttributes () &
1429
- ObjCPropertyDecl::OBJC_PR_readwrite) {
1430
- Out << (first ? ' ' : ' ,' ) << " readwrite" ;
1430
+ Out << (first ? " " : " , " ) << " assign" ;
1431
1431
first = false ;
1432
1432
}
1433
-
1434
1433
if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_retain) {
1435
- Out << (first ? ' ' : ' , ' ) << " retain" ;
1434
+ Out << (first ? " " : " , " ) << " retain" ;
1436
1435
first = false ;
1437
1436
}
1438
1437
1439
1438
if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_strong) {
1440
- Out << (first ? ' ' : ' , ' ) << " strong" ;
1439
+ Out << (first ? " " : " , " ) << " strong" ;
1441
1440
first = false ;
1442
1441
}
1443
-
1444
1442
if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_copy) {
1445
- Out << (first ? ' ' : ' ,' ) << " copy" ;
1443
+ Out << (first ? " " : " , " ) << " copy" ;
1444
+ first = false ;
1445
+ }
1446
+ if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_weak) {
1447
+ Out << (first ? " " : " , " ) << " weak" ;
1448
+ first = false ;
1449
+ }
1450
+ if (PDecl->getPropertyAttributes ()
1451
+ & ObjCPropertyDecl::OBJC_PR_unsafe_unretained) {
1452
+ Out << (first ? " " : " , " ) << " unsafe_unretained" ;
1446
1453
first = false ;
1447
1454
}
1448
1455
1449
1456
if (PDecl->getPropertyAttributes () &
1450
- ObjCPropertyDecl::OBJC_PR_nonatomic ) {
1451
- Out << (first ? ' ' : ' , ' ) << " nonatomic " ;
1457
+ ObjCPropertyDecl::OBJC_PR_readwrite ) {
1458
+ Out << (first ? " " : " , " ) << " readwrite " ;
1452
1459
first = false ;
1453
1460
}
1454
1461
if (PDecl->getPropertyAttributes () &
1455
- ObjCPropertyDecl::OBJC_PR_atomic) {
1456
- Out << (first ? ' ' : ' ,' ) << " atomic" ;
1462
+ ObjCPropertyDecl::OBJC_PR_readonly) {
1463
+ Out << (first ? " " : " , " ) << " readonly" ;
1464
+ first = false ;
1465
+ }
1466
+
1467
+ if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_getter) {
1468
+ Out << (first ? " " : " , " ) << " getter = " ;
1469
+ PDecl->getGetterName ().print (Out);
1470
+ first = false ;
1471
+ }
1472
+ if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_setter) {
1473
+ Out << (first ? " " : " , " ) << " setter = " ;
1474
+ PDecl->getSetterName ().print (Out);
1457
1475
first = false ;
1458
1476
}
1459
1477
@@ -1463,25 +1481,24 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
1463
1481
if (*nullability == NullabilityKind::Unspecified &&
1464
1482
(PDecl->getPropertyAttributes () &
1465
1483
ObjCPropertyDecl::OBJC_PR_null_resettable)) {
1466
- Out << (first ? ' ' : ' , ' ) << " null_resettable" ;
1484
+ Out << (first ? " " : " , " ) << " null_resettable" ;
1467
1485
} else {
1468
- Out << (first ? ' ' : ' , ' )
1486
+ Out << (first ? " " : " , " )
1469
1487
<< getNullabilitySpelling (*nullability, true );
1470
1488
}
1471
1489
first = false ;
1472
1490
}
1473
1491
}
1474
1492
1475
- if (PDecl->getPropertyAttributes () & ObjCPropertyDecl::OBJC_PR_class) {
1476
- Out << (first ? ' ' : ' ,' ) << " class" ;
1477
- first = false ;
1478
- }
1479
-
1480
1493
(void ) first; // Silence dead store warning due to idiomatic code.
1481
- Out << " )" ;
1494
+ Out << " )" ;
1482
1495
}
1483
- Out << ' ' << PDecl->getASTContext ().getUnqualifiedObjCPointerType (T).
1484
- getAsString (Policy) << ' ' << *PDecl;
1496
+ std::string TypeStr = PDecl->getASTContext ().getUnqualifiedObjCPointerType (T).
1497
+ getAsString (Policy);
1498
+ Out << ' ' << TypeStr;
1499
+ if (!StringRef (TypeStr).endswith (" *" ))
1500
+ Out << ' ' ;
1501
+ Out << *PDecl;
1485
1502
if (Policy.PolishForDeclaration )
1486
1503
Out << ' ;' ;
1487
1504
}
0 commit comments