summaryrefslogtreecommitdiffstats
path: root/clang/lib/ARCMigrate
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-08-20 21:47:29 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-08-20 21:47:29 +0000
commite43e2b3667f9bc29c23be5235b53a7d7afcdb181 (patch)
tree8177f2851e33d4a877198dcd8700e48a12b163b7 /clang/lib/ARCMigrate
parent210ccfe3db1b4d6f1a9ea9cc9b6232f161766a29 (diff)
downloadbcm5719-llvm-e43e2b3667f9bc29c23be5235b53a7d7afcdb181.tar.gz
bcm5719-llvm-e43e2b3667f9bc29c23be5235b53a7d7afcdb181.zip
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 This reinstates r339623, reverted in r339638, with a fix to not fail template instantiation if we instantiate a QualType with no associated type source information and we encounter an AttributedType. llvm-svn: 340215
Diffstat (limited to 'clang/lib/ARCMigrate')
-rw-r--r--clang/lib/ARCMigrate/TransGCAttrs.cpp15
-rw-r--r--clang/lib/ARCMigrate/Transforms.cpp2
2 files changed, 6 insertions, 11 deletions
diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp
index ef36dcabb56..7697d3f048e 100644
--- a/clang/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/clang/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/clang/lib/ARCMigrate/Transforms.cpp b/clang/lib/ARCMigrate/Transforms.cpp
index 4a7af285887..a403744de70 100644
--- a/clang/lib/ARCMigrate/Transforms.cpp
+++ b/clang/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();
}
OpenPOWER on IntegriCloud