r188714 - ObjectiveC migrator: Start inserting
Fariborz Jahanian
fjahanian at apple.com
Mon Aug 19 15:00:51 PDT 2013
Author: fjahanian
Date: Mon Aug 19 17:00:50 2013
New Revision: 188714
URL: http://llvm.org/viewvc/llvm-project?rev=188714&view=rev
Log:
ObjectiveC migrator: Start inserting
CF_IMPLICIT_BRIDGING_ENABLE/CF_IMPLICIT_BRIDGING_DISABLED
pair. wip.
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=188714&r1=188713&r2=188714&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Mon Aug 19 17:00:50 2013
@@ -791,23 +791,45 @@ AuditedType (QualType AT) {
void ObjCMigrateASTConsumer::migrateCFFunctions(
ASTContext &Ctx,
const FunctionDecl *FuncDecl) {
+ if (FuncDecl->hasAttr<CFAuditedTransferAttr>()) {
+ assert(CFFunctionIBCandidates.empty() &&
+ "Cannot have audited functions inside user "
+ "provided CF_IMPLICIT_BRIDGING_ENABLE");
+ return;
+ }
+
// Finction must be annotated first.
bool Audited = migrateAddFunctionAnnotation(Ctx, FuncDecl);
if (Audited)
CFFunctionIBCandidates.push_back(FuncDecl);
+ else if (!CFFunctionIBCandidates.empty()) {
+ if (!Ctx.Idents.get("CF_IMPLICIT_BRIDGING_ENABLED").hasMacroDefinition()) {
+ CFFunctionIBCandidates.clear();
+ return;
+ }
+ // Insert CF_IMPLICIT_BRIDGING_ENABLE/CF_IMPLICIT_BRIDGING_DISABLED
+ const FunctionDecl *FirstFD = CFFunctionIBCandidates[0];
+ const FunctionDecl *LastFD =
+ CFFunctionIBCandidates[CFFunctionIBCandidates.size()-1];
+ const char *PragmaString = "\nCF_IMPLICIT_BRIDGING_ENABLED\n";
+ edit::Commit commit(*Editor);
+ commit.insertBefore(FirstFD->getLocStart(), PragmaString);
+ PragmaString = "\nCF_IMPLICIT_BRIDGING_DISABLED\n";
+ commit.insertAfterToken(LastFD->getLocEnd(), PragmaString);
+ Editor->commit(commit);
+
+ CFFunctionIBCandidates.clear();
+ }
+ // FIXME. Also must insert CF_IMPLICIT_BRIDGING_ENABLE/CF_IMPLICIT_BRIDGING_DISABLED
+ // when leaving current file.
}
bool ObjCMigrateASTConsumer::migrateAddFunctionAnnotation(
ASTContext &Ctx,
const FunctionDecl *FuncDecl) {
- // Check that if it is already under CF_IMPLICIT_BRIDGING_ENABLE
- // and do nothing. FIXME. This may have to go to the caller.
- if (FuncDecl->hasAttr<CFAuditedTransferAttr>())
- return false;
if (FuncDecl->hasBody())
return false;
CallEffects CE = CallEffects::getEffect(FuncDecl);
-
if (!FuncDecl->getAttr<CFReturnsRetainedAttr>() &&
!FuncDecl->getAttr<CFReturnsNotRetainedAttr>()) {
RetEffect Ret = CE.getReturnValue();
@@ -838,16 +860,15 @@ bool ObjCMigrateASTConsumer::migrateAddF
if (AE == DecRefMsg /*NSConsumed annotated*/ ||
AE == DecRef /*CFConsumed annotated*/)
continue;
- if (AE != DoNothing)
+
+ if (AE != DoNothing && AE != MayEscape)
return false;
const ParmVarDecl *pd = *pi;
QualType AT = pd->getType();
if (!AuditedType(AT))
return false;
}
- // At this point, function is audited.
- // FIXME. for now return false.
- return false;
+ return true;
}
void ObjCMigrateASTConsumer::migrateObjCMethodDeclAnnotation(
More information about the cfe-commits
mailing list