003 File Manager
Current Path:
/usr/src/contrib/llvm-project/clang/lib/ARCMigrate
usr
/
src
/
contrib
/
llvm-project
/
clang
/
lib
/
ARCMigrate
/
📁
..
📄
ARCMT.cpp
(21.93 KB)
📄
ARCMTActions.cpp
(2.44 KB)
📄
FileRemapper.cpp
(8.26 KB)
📄
Internals.h
(5.47 KB)
📄
ObjCMT.cpp
(81.85 KB)
📄
PlistReporter.cpp
(3.64 KB)
📄
TransAPIUses.cpp
(3.49 KB)
📄
TransARCAssign.cpp
(2.25 KB)
📄
TransAutoreleasePool.cpp
(14.26 KB)
📄
TransBlockObjCVariable.cpp
(4.55 KB)
📄
TransEmptyStatementsAndDealloc.cpp
(7 KB)
📄
TransGCAttrs.cpp
(11.29 KB)
📄
TransGCCalls.cpp
(2.54 KB)
📄
TransProperties.cpp
(12.35 KB)
📄
TransProtectedScope.cpp
(6.02 KB)
📄
TransRetainReleaseDealloc.cpp
(13.65 KB)
📄
TransUnbridgedCasts.cpp
(15.85 KB)
📄
TransUnusedInitDelegate.cpp
(2.2 KB)
📄
TransZeroOutPropsInDealloc.cpp
(6.71 KB)
📄
TransformActions.cpp
(23.07 KB)
📄
Transforms.cpp
(17.72 KB)
📄
Transforms.h
(6.72 KB)
Editing: TransGCCalls.cpp
//===--- TransGCCalls.cpp - Transformations to ARC mode -------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "Transforms.h" #include "Internals.h" #include "clang/AST/ASTContext.h" #include "clang/Sema/SemaDiagnostic.h" using namespace clang; using namespace arcmt; using namespace trans; namespace { class GCCollectableCallsChecker : public RecursiveASTVisitor<GCCollectableCallsChecker> { MigrationContext &MigrateCtx; IdentifierInfo *NSMakeCollectableII; IdentifierInfo *CFMakeCollectableII; public: GCCollectableCallsChecker(MigrationContext &ctx) : MigrateCtx(ctx) { IdentifierTable &Ids = MigrateCtx.Pass.Ctx.Idents; NSMakeCollectableII = &Ids.get("NSMakeCollectable"); CFMakeCollectableII = &Ids.get("CFMakeCollectable"); } bool shouldWalkTypesOfTypeLocs() const { return false; } bool VisitCallExpr(CallExpr *E) { TransformActions &TA = MigrateCtx.Pass.TA; if (MigrateCtx.isGCOwnedNonObjC(E->getType())) { TA.report(E->getBeginLoc(), diag::warn_arcmt_nsalloc_realloc, E->getSourceRange()); return true; } Expr *CEE = E->getCallee()->IgnoreParenImpCasts(); if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) { if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(DRE->getDecl())) { if (!FD->getDeclContext()->getRedeclContext()->isFileContext()) return true; if (FD->getIdentifier() == NSMakeCollectableII) { Transaction Trans(TA); TA.clearDiagnostic(diag::err_unavailable, diag::err_unavailable_message, diag::err_ovl_deleted_call, // ObjC++ DRE->getSourceRange()); TA.replace(DRE->getSourceRange(), "CFBridgingRelease"); } else if (FD->getIdentifier() == CFMakeCollectableII) { TA.reportError("CFMakeCollectable will leak the object that it " "receives in ARC", DRE->getLocation(), DRE->getSourceRange()); } } } return true; } }; } // anonymous namespace void GCCollectableCallsTraverser::traverseBody(BodyContext &BodyCtx) { GCCollectableCallsChecker(BodyCtx.getMigrationContext()) .TraverseStmt(BodyCtx.getTopStmt()); }
Upload File
Create Folder