Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 1 | //===--- TransGCAttrs.cpp - Transformations to ARC mode --------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "Transforms.h" |
| 11 | #include "Internals.h" |
Benjamin Kramer | 4ab984e | 2012-07-04 20:19:54 +0000 | [diff] [blame] | 12 | #include "clang/AST/ASTContext.h" |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 13 | #include "clang/Basic/SourceManager.h" |
Benjamin Kramer | 4ab984e | 2012-07-04 20:19:54 +0000 | [diff] [blame] | 14 | #include "clang/Lex/Lexer.h" |
Argyrios Kyrtzidis | e80d4f2 | 2011-11-07 18:40:29 +0000 | [diff] [blame] | 15 | #include "clang/Sema/SemaDiagnostic.h" |
Benjamin Kramer | 4903802 | 2012-02-04 13:45:25 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/SmallString.h" |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/TinyPtrVector.h" |
Benjamin Kramer | 4ab984e | 2012-07-04 20:19:54 +0000 | [diff] [blame] | 18 | #include "llvm/Support/SaveAndRestore.h" |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 19 | |
| 20 | using namespace clang; |
| 21 | using namespace arcmt; |
| 22 | using namespace trans; |
| 23 | |
| 24 | namespace { |
| 25 | |
| 26 | /// \brief Collects all the places where GC attributes __strong/__weak occur. |
| 27 | class GCAttrsCollector : public RecursiveASTVisitor<GCAttrsCollector> { |
| 28 | MigrationContext &MigrateCtx; |
| 29 | bool FullyMigratable; |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 30 | std::vector<ObjCPropertyDecl *> &AllProps; |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 31 | |
| 32 | typedef RecursiveASTVisitor<GCAttrsCollector> base; |
| 33 | public: |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 34 | GCAttrsCollector(MigrationContext &ctx, |
| 35 | std::vector<ObjCPropertyDecl *> &AllProps) |
| 36 | : MigrateCtx(ctx), FullyMigratable(false), |
| 37 | AllProps(AllProps) { } |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 38 | |
| 39 | bool shouldWalkTypesOfTypeLocs() const { return false; } |
| 40 | |
| 41 | bool VisitAttributedTypeLoc(AttributedTypeLoc TL) { |
| 42 | handleAttr(TL); |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | bool TraverseDecl(Decl *D) { |
| 47 | if (!D || D->isImplicit()) |
| 48 | return true; |
| 49 | |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 50 | SaveAndRestore<bool> Save(FullyMigratable, isMigratable(D)); |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 51 | |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 52 | if (ObjCPropertyDecl *PropD = dyn_cast<ObjCPropertyDecl>(D)) { |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 53 | lookForAttribute(PropD, PropD->getTypeSourceInfo()); |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 54 | AllProps.push_back(PropD); |
| 55 | } else if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) { |
| 56 | lookForAttribute(DD, DD->getTypeSourceInfo()); |
| 57 | } |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 58 | return base::TraverseDecl(D); |
| 59 | } |
| 60 | |
| 61 | void lookForAttribute(Decl *D, TypeSourceInfo *TInfo) { |
| 62 | if (!TInfo) |
| 63 | return; |
| 64 | TypeLoc TL = TInfo->getTypeLoc(); |
| 65 | while (TL) { |
David Blaikie | 6adc78e | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 66 | if (QualifiedTypeLoc QL = TL.getAs<QualifiedTypeLoc>()) { |
| 67 | TL = QL.getUnqualifiedLoc(); |
| 68 | } else if (AttributedTypeLoc Attr = TL.getAs<AttributedTypeLoc>()) { |
| 69 | if (handleAttr(Attr, D)) |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 70 | break; |
David Blaikie | 6adc78e | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 71 | TL = Attr.getModifiedLoc(); |
| 72 | } else if (ArrayTypeLoc Arr = TL.getAs<ArrayTypeLoc>()) { |
| 73 | TL = Arr.getElementLoc(); |
| 74 | } else if (PointerTypeLoc PT = TL.getAs<PointerTypeLoc>()) { |
| 75 | TL = PT.getPointeeLoc(); |
| 76 | } else if (ReferenceTypeLoc RT = TL.getAs<ReferenceTypeLoc>()) |
| 77 | TL = RT.getPointeeLoc(); |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 78 | else |
| 79 | break; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | bool handleAttr(AttributedTypeLoc TL, Decl *D = 0) { |
| 84 | if (TL.getAttrKind() != AttributedType::attr_objc_ownership) |
| 85 | return false; |
| 86 | |
| 87 | SourceLocation Loc = TL.getAttrNameLoc(); |
| 88 | unsigned RawLoc = Loc.getRawEncoding(); |
| 89 | if (MigrateCtx.AttrSet.count(RawLoc)) |
| 90 | return true; |
| 91 | |
| 92 | ASTContext &Ctx = MigrateCtx.Pass.Ctx; |
| 93 | SourceManager &SM = Ctx.getSourceManager(); |
Argyrios Kyrtzidis | e80d4f2 | 2011-11-07 18:40:29 +0000 | [diff] [blame] | 94 | if (Loc.isMacroID()) |
| 95 | Loc = SM.getImmediateExpansionRange(Loc).first; |
Dylan Noblesmith | 2c1dd27 | 2012-02-05 02:13:05 +0000 | [diff] [blame] | 96 | SmallString<32> Buf; |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 97 | bool Invalid = false; |
| 98 | StringRef Spell = Lexer::getSpelling( |
| 99 | SM.getSpellingLoc(TL.getAttrEnumOperandLoc()), |
David Blaikie | bbafb8a | 2012-03-11 07:00:24 +0000 | [diff] [blame] | 100 | Buf, SM, Ctx.getLangOpts(), &Invalid); |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 101 | if (Invalid) |
| 102 | return false; |
| 103 | MigrationContext::GCAttrOccurrence::AttrKind Kind; |
| 104 | if (Spell == "strong") |
| 105 | Kind = MigrationContext::GCAttrOccurrence::Strong; |
| 106 | else if (Spell == "weak") |
| 107 | Kind = MigrationContext::GCAttrOccurrence::Weak; |
| 108 | else |
| 109 | return false; |
| 110 | |
| 111 | MigrateCtx.AttrSet.insert(RawLoc); |
| 112 | MigrateCtx.GCAttrs.push_back(MigrationContext::GCAttrOccurrence()); |
| 113 | MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs.back(); |
| 114 | |
| 115 | Attr.Kind = Kind; |
Argyrios Kyrtzidis | e80d4f2 | 2011-11-07 18:40:29 +0000 | [diff] [blame] | 116 | Attr.Loc = Loc; |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 117 | Attr.ModifiedType = TL.getModifiedLoc().getType(); |
| 118 | Attr.Dcl = D; |
| 119 | Attr.FullyMigratable = FullyMigratable; |
| 120 | return true; |
| 121 | } |
| 122 | |
| 123 | bool isMigratable(Decl *D) { |
| 124 | if (isa<TranslationUnitDecl>(D)) |
| 125 | return false; |
| 126 | |
| 127 | if (isInMainFile(D)) |
| 128 | return true; |
| 129 | |
| 130 | if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) |
| 131 | return FD->hasBody(); |
| 132 | |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 133 | if (ObjCContainerDecl *ContD = dyn_cast<ObjCContainerDecl>(D)) |
| 134 | return hasObjCImpl(ContD); |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 135 | |
| 136 | if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) { |
Aaron Ballman | 2b124d1 | 2014-03-13 16:36:16 +0000 | [diff] [blame^] | 137 | for (const auto *MI : RD->methods()) { |
David Blaikie | 2d7c57e | 2012-04-30 02:36:29 +0000 | [diff] [blame] | 138 | if (MI->isOutOfLine()) |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 139 | return true; |
| 140 | } |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | return isMigratable(cast<Decl>(D->getDeclContext())); |
| 145 | } |
| 146 | |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 147 | static bool hasObjCImpl(Decl *D) { |
| 148 | if (!D) |
| 149 | return false; |
| 150 | if (ObjCContainerDecl *ContD = dyn_cast<ObjCContainerDecl>(D)) { |
| 151 | if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(ContD)) |
| 152 | return ID->getImplementation() != 0; |
| 153 | if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContD)) |
| 154 | return CD->getImplementation() != 0; |
| 155 | if (isa<ObjCImplDecl>(ContD)) |
| 156 | return true; |
| 157 | return false; |
| 158 | } |
| 159 | return false; |
| 160 | } |
| 161 | |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 162 | bool isInMainFile(Decl *D) { |
| 163 | if (!D) |
| 164 | return false; |
| 165 | |
Aaron Ballman | 86c9390 | 2014-03-06 23:45:36 +0000 | [diff] [blame] | 166 | for (auto I : D->redecls()) |
David Blaikie | b15de1e | 2012-05-01 00:48:43 +0000 | [diff] [blame] | 167 | if (!isInMainFile(I->getLocation())) |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 168 | return false; |
| 169 | |
| 170 | return true; |
| 171 | } |
| 172 | |
| 173 | bool isInMainFile(SourceLocation Loc) { |
| 174 | if (Loc.isInvalid()) |
| 175 | return false; |
| 176 | |
| 177 | SourceManager &SM = MigrateCtx.Pass.Ctx.getSourceManager(); |
| 178 | return SM.isInFileID(SM.getExpansionLoc(Loc), SM.getMainFileID()); |
| 179 | } |
| 180 | }; |
| 181 | |
| 182 | } // anonymous namespace |
| 183 | |
Argyrios Kyrtzidis | f233dac | 2011-11-06 18:58:23 +0000 | [diff] [blame] | 184 | static void errorForGCAttrsOnNonObjC(MigrationContext &MigrateCtx) { |
| 185 | TransformActions &TA = MigrateCtx.Pass.TA; |
| 186 | |
| 187 | for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) { |
| 188 | MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i]; |
| 189 | if (Attr.FullyMigratable && Attr.Dcl) { |
| 190 | if (Attr.ModifiedType.isNull()) |
| 191 | continue; |
| 192 | if (!Attr.ModifiedType->isObjCRetainableType()) { |
| 193 | TA.reportError("GC managed memory will become unmanaged in ARC", |
| 194 | Attr.Loc); |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
Argyrios Kyrtzidis | e80d4f2 | 2011-11-07 18:40:29 +0000 | [diff] [blame] | 200 | static void checkWeakGCAttrs(MigrationContext &MigrateCtx) { |
| 201 | TransformActions &TA = MigrateCtx.Pass.TA; |
| 202 | |
| 203 | for (unsigned i = 0, e = MigrateCtx.GCAttrs.size(); i != e; ++i) { |
| 204 | MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs[i]; |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 205 | if (Attr.Kind == MigrationContext::GCAttrOccurrence::Weak) { |
Argyrios Kyrtzidis | e80d4f2 | 2011-11-07 18:40:29 +0000 | [diff] [blame] | 206 | if (Attr.ModifiedType.isNull() || |
| 207 | !Attr.ModifiedType->isObjCRetainableType()) |
| 208 | continue; |
| 209 | if (!canApplyWeak(MigrateCtx.Pass.Ctx, Attr.ModifiedType, |
| 210 | /*AllowOnUnknownClass=*/true)) { |
| 211 | Transaction Trans(TA); |
Argyrios Kyrtzidis | 2519a08 | 2011-11-08 02:02:38 +0000 | [diff] [blame] | 212 | if (!MigrateCtx.RemovedAttrSet.count(Attr.Loc.getRawEncoding())) |
| 213 | TA.replaceText(Attr.Loc, "__weak", "__unsafe_unretained"); |
Argyrios Kyrtzidis | e80d4f2 | 2011-11-07 18:40:29 +0000 | [diff] [blame] | 214 | TA.clearDiagnostic(diag::err_arc_weak_no_runtime, |
| 215 | diag::err_arc_unsupported_weak_class, |
| 216 | Attr.Loc); |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 222 | typedef llvm::TinyPtrVector<ObjCPropertyDecl *> IndivPropsTy; |
| 223 | |
| 224 | static void checkAllAtProps(MigrationContext &MigrateCtx, |
| 225 | SourceLocation AtLoc, |
| 226 | IndivPropsTy &IndProps) { |
| 227 | if (IndProps.empty()) |
| 228 | return; |
| 229 | |
| 230 | for (IndivPropsTy::iterator |
| 231 | PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) { |
| 232 | QualType T = (*PI)->getType(); |
| 233 | if (T.isNull() || !T->isObjCRetainableType()) |
| 234 | return; |
| 235 | } |
| 236 | |
| 237 | SmallVector<std::pair<AttributedTypeLoc, ObjCPropertyDecl *>, 4> ATLs; |
| 238 | bool hasWeak = false, hasStrong = false; |
Argyrios Kyrtzidis | eca1f36 | 2011-11-28 02:04:36 +0000 | [diff] [blame] | 239 | ObjCPropertyDecl::PropertyAttributeKind |
| 240 | Attrs = ObjCPropertyDecl::OBJC_PR_noattr; |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 241 | for (IndivPropsTy::iterator |
| 242 | PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) { |
| 243 | ObjCPropertyDecl *PD = *PI; |
Argyrios Kyrtzidis | eca1f36 | 2011-11-28 02:04:36 +0000 | [diff] [blame] | 244 | Attrs = PD->getPropertyAttributesAsWritten(); |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 245 | TypeSourceInfo *TInfo = PD->getTypeSourceInfo(); |
| 246 | if (!TInfo) |
| 247 | return; |
| 248 | TypeLoc TL = TInfo->getTypeLoc(); |
David Blaikie | 6adc78e | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 249 | if (AttributedTypeLoc ATL = |
| 250 | TL.getAs<AttributedTypeLoc>()) { |
| 251 | ATLs.push_back(std::make_pair(ATL, PD)); |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 252 | if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Weak) { |
| 253 | hasWeak = true; |
| 254 | } else if (TInfo->getType().getObjCLifetime() == Qualifiers::OCL_Strong) |
| 255 | hasStrong = true; |
| 256 | else |
| 257 | return; |
| 258 | } |
| 259 | } |
| 260 | if (ATLs.empty()) |
| 261 | return; |
| 262 | if (hasWeak && hasStrong) |
| 263 | return; |
| 264 | |
| 265 | TransformActions &TA = MigrateCtx.Pass.TA; |
| 266 | Transaction Trans(TA); |
| 267 | |
| 268 | if (GCAttrsCollector::hasObjCImpl( |
| 269 | cast<Decl>(IndProps.front()->getDeclContext()))) { |
| 270 | if (hasWeak) |
| 271 | MigrateCtx.AtPropsWeak.insert(AtLoc.getRawEncoding()); |
| 272 | |
| 273 | } else { |
| 274 | StringRef toAttr = "strong"; |
| 275 | if (hasWeak) { |
| 276 | if (canApplyWeak(MigrateCtx.Pass.Ctx, IndProps.front()->getType(), |
| 277 | /*AllowOnUnkwownClass=*/true)) |
| 278 | toAttr = "weak"; |
| 279 | else |
| 280 | toAttr = "unsafe_unretained"; |
| 281 | } |
Argyrios Kyrtzidis | eca1f36 | 2011-11-28 02:04:36 +0000 | [diff] [blame] | 282 | if (Attrs & ObjCPropertyDecl::OBJC_PR_assign) |
| 283 | MigrateCtx.rewritePropertyAttribute("assign", toAttr, AtLoc); |
| 284 | else |
| 285 | MigrateCtx.addPropertyAttribute(toAttr, AtLoc); |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | for (unsigned i = 0, e = ATLs.size(); i != e; ++i) { |
| 289 | SourceLocation Loc = ATLs[i].first.getAttrNameLoc(); |
| 290 | if (Loc.isMacroID()) |
| 291 | Loc = MigrateCtx.Pass.Ctx.getSourceManager() |
| 292 | .getImmediateExpansionRange(Loc).first; |
| 293 | TA.remove(Loc); |
| 294 | TA.clearDiagnostic(diag::err_objc_property_attr_mutually_exclusive, AtLoc); |
| 295 | TA.clearDiagnostic(diag::err_arc_inconsistent_property_ownership, |
| 296 | ATLs[i].second->getLocation()); |
Argyrios Kyrtzidis | 2519a08 | 2011-11-08 02:02:38 +0000 | [diff] [blame] | 297 | MigrateCtx.RemovedAttrSet.insert(Loc.getRawEncoding()); |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | |
| 301 | static void checkAllProps(MigrationContext &MigrateCtx, |
| 302 | std::vector<ObjCPropertyDecl *> &AllProps) { |
| 303 | typedef llvm::TinyPtrVector<ObjCPropertyDecl *> IndivPropsTy; |
| 304 | llvm::DenseMap<unsigned, IndivPropsTy> AtProps; |
| 305 | |
| 306 | for (unsigned i = 0, e = AllProps.size(); i != e; ++i) { |
| 307 | ObjCPropertyDecl *PD = AllProps[i]; |
| 308 | if (PD->getPropertyAttributesAsWritten() & |
Argyrios Kyrtzidis | 3fc3dcd | 2011-11-28 00:23:12 +0000 | [diff] [blame] | 309 | (ObjCPropertyDecl::OBJC_PR_assign | |
| 310 | ObjCPropertyDecl::OBJC_PR_readonly)) { |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 311 | SourceLocation AtLoc = PD->getAtLoc(); |
| 312 | if (AtLoc.isInvalid()) |
| 313 | continue; |
| 314 | unsigned RawAt = AtLoc.getRawEncoding(); |
| 315 | AtProps[RawAt].push_back(PD); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | for (llvm::DenseMap<unsigned, IndivPropsTy>::iterator |
| 320 | I = AtProps.begin(), E = AtProps.end(); I != E; ++I) { |
| 321 | SourceLocation AtLoc = SourceLocation::getFromRawEncoding(I->first); |
| 322 | IndivPropsTy &IndProps = I->second; |
| 323 | checkAllAtProps(MigrateCtx, AtLoc, IndProps); |
| 324 | } |
| 325 | } |
| 326 | |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 327 | void GCAttrsTraverser::traverseTU(MigrationContext &MigrateCtx) { |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 328 | std::vector<ObjCPropertyDecl *> AllProps; |
| 329 | GCAttrsCollector(MigrateCtx, AllProps).TraverseDecl( |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 330 | MigrateCtx.Pass.Ctx.getTranslationUnitDecl()); |
Argyrios Kyrtzidis | f233dac | 2011-11-06 18:58:23 +0000 | [diff] [blame] | 331 | |
Argyrios Kyrtzidis | f233dac | 2011-11-06 18:58:23 +0000 | [diff] [blame] | 332 | errorForGCAttrsOnNonObjC(MigrateCtx); |
Argyrios Kyrtzidis | 722d21c | 2011-11-07 18:46:46 +0000 | [diff] [blame] | 333 | checkAllProps(MigrateCtx, AllProps); |
Argyrios Kyrtzidis | 2519a08 | 2011-11-08 02:02:38 +0000 | [diff] [blame] | 334 | checkWeakGCAttrs(MigrateCtx); |
Argyrios Kyrtzidis | 0c233fa | 2011-11-06 18:58:17 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | void MigrationContext::dumpGCAttrs() { |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 338 | llvm::errs() << "\n################\n"; |
Argyrios Kyrtzidis | 0c233fa | 2011-11-06 18:58:17 +0000 | [diff] [blame] | 339 | for (unsigned i = 0, e = GCAttrs.size(); i != e; ++i) { |
| 340 | GCAttrOccurrence &Attr = GCAttrs[i]; |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 341 | llvm::errs() << "KIND: " |
Argyrios Kyrtzidis | 0c233fa | 2011-11-06 18:58:17 +0000 | [diff] [blame] | 342 | << (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak"); |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 343 | llvm::errs() << "\nLOC: "; |
Argyrios Kyrtzidis | 0c233fa | 2011-11-06 18:58:17 +0000 | [diff] [blame] | 344 | Attr.Loc.dump(Pass.Ctx.getSourceManager()); |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 345 | llvm::errs() << "\nTYPE: "; |
| 346 | Attr.ModifiedType.dump(); |
| 347 | if (Attr.Dcl) { |
| 348 | llvm::errs() << "DECL:\n"; |
| 349 | Attr.Dcl->dump(); |
| 350 | } else { |
| 351 | llvm::errs() << "DECL: NONE"; |
| 352 | } |
| 353 | llvm::errs() << "\nMIGRATABLE: " << Attr.FullyMigratable; |
| 354 | llvm::errs() << "\n----------------\n"; |
| 355 | } |
| 356 | llvm::errs() << "\n################\n"; |
Argyrios Kyrtzidis | e43ae79 | 2011-11-06 18:58:03 +0000 | [diff] [blame] | 357 | } |