diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-13 22:07:09 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-08-13 22:07:09 +0000 |
commit | a3402fe23c88f2d0c17a4795cd7902ab35df15e7 (patch) | |
tree | f9e04bdf3b793320c3c9ef82eec73722f6852eb5 /lib/ARCMigrate | |
parent | 293b7c598947b73d71b24d2c7e665bfc26ae1e49 (diff) |
Model type attributes as regular Attrs.
Specifically, AttributedType now tracks a regular attr::Kind rather than
having its own parallel Kind enumeration, and AttributedTypeLoc now
holds an Attr* instead of holding an ad-hoc collection of Attr fields.
Differential Revision: https://reviews.llvm.org/D50526
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate')
-rw-r--r-- | lib/ARCMigrate/TransGCAttrs.cpp | 15 | ||||
-rw-r--r-- | lib/ARCMigrate/Transforms.cpp | 2 |
2 files changed, 6 insertions, 11 deletions
diff --git a/lib/ARCMigrate/TransGCAttrs.cpp b/lib/ARCMigrate/TransGCAttrs.cpp index fb45cd92c1..06f8a23e7e 100644 --- a/lib/ARCMigrate/TransGCAttrs.cpp +++ b/lib/ARCMigrate/TransGCAttrs.cpp @@ -81,10 +81,11 @@ public: } bool handleAttr(AttributedTypeLoc TL, Decl *D = nullptr) { - if (TL.getAttrKind() != AttributedType::attr_objc_ownership) + auto *OwnershipAttr = TL.getAttrAs<ObjCOwnershipAttr>(); + if (!OwnershipAttr) return false; - SourceLocation Loc = TL.getAttrNameLoc(); + SourceLocation Loc = OwnershipAttr->getLocation(); unsigned RawLoc = Loc.getRawEncoding(); if (MigrateCtx.AttrSet.count(RawLoc)) return true; @@ -93,13 +94,7 @@ public: SourceManager &SM = Ctx.getSourceManager(); if (Loc.isMacroID()) Loc = SM.getImmediateExpansionRange(Loc).getBegin(); - SmallString<32> Buf; - bool Invalid = false; - StringRef Spell = Lexer::getSpelling( - SM.getSpellingLoc(TL.getAttrEnumOperandLoc()), - Buf, SM, Ctx.getLangOpts(), &Invalid); - if (Invalid) - return false; + StringRef Spell = OwnershipAttr->getKind()->getName(); MigrationContext::GCAttrOccurrence::AttrKind Kind; if (Spell == "strong") Kind = MigrationContext::GCAttrOccurrence::Strong; @@ -284,7 +279,7 @@ static void checkAllAtProps(MigrationContext &MigrateCtx, } for (unsigned i = 0, e = ATLs.size(); i != e; ++i) { - SourceLocation Loc = ATLs[i].first.getAttrNameLoc(); + SourceLocation Loc = ATLs[i].first.getAttr()->getLocation(); if (Loc.isMacroID()) Loc = MigrateCtx.Pass.Ctx.getSourceManager() .getImmediateExpansionRange(Loc) diff --git a/lib/ARCMigrate/Transforms.cpp b/lib/ARCMigrate/Transforms.cpp index 4a7af28588..a403744de7 100644 --- a/lib/ARCMigrate/Transforms.cpp +++ b/lib/ARCMigrate/Transforms.cpp @@ -359,7 +359,7 @@ MigrationContext::~MigrationContext() { bool MigrationContext::isGCOwnedNonObjC(QualType T) { while (!T.isNull()) { if (const AttributedType *AttrT = T->getAs<AttributedType>()) { - if (AttrT->getAttrKind() == AttributedType::attr_objc_ownership) + if (AttrT->getAttrKind() == attr::ObjCOwnership) return !AttrT->getModifiedType()->isObjCRetainableType(); } |