return true;
}
+ bool hadARCErrors = capturedDiags.hasErrors();
+
// Don't filter diagnostics anymore.
Diags->setClient(DiagClient, /*ShouldOwnClient=*/false);
DiagClient->EndSourceFile();
errRec.FinishCapture();
- // If we are migrating code that gets the '-fobjc-arc' flag, make sure
- // to remove it so that we don't get errors from normal compilation.
- origCI.getLangOpts()->ObjCAutoRefCount = false;
- // Disable auto-synthesize to avoid "@synthesize of 'weak' property is only
- // allowed in ARC" errors.
- origCI.getLangOpts()->ObjCDefaultSynthProperties = false;
+ if (hadARCErrors) {
+ // If we are migrating code that gets the '-fobjc-arc' flag, make sure
+ // to remove it so that we don't get errors from normal compilation.
+ origCI.getLangOpts()->ObjCAutoRefCount = false;
+ // Disable auto-synthesize to avoid "@synthesize of 'weak' property is only
+ // allowed in ARC" errors.
+ origCI.getLangOpts()->ObjCDefaultSynthProperties = false;
+ }
return capturedDiags.hasErrors() || testAct.hasReportedErrors();
}
origCI.getLangOpts()->ObjCAutoRefCount = true;
return migration.getRemapper().overwriteOriginal(*Diags);
} else {
- // If we are migrating code that gets the '-fobjc-arc' flag, make sure
- // to remove it so that we don't get errors from normal compilation.
- origCI.getLangOpts()->ObjCAutoRefCount = false;
+ if (migration.HadARCErrors) {
+ // If we are migrating code that gets the '-fobjc-arc' flag, make sure
+ // to remove it so that we don't get errors from normal compilation.
+ origCI.getLangOpts()->ObjCAutoRefCount = false;
+ // Disable auto-synthesize to avoid "@synthesize of 'weak' property is only
+ // allowed in ARC" errors.
+ origCI.getLangOpts()->ObjCDefaultSynthProperties = false;
+ }
return migration.getRemapper().flushToDisk(outputDir, *Diags);
}
}
MigrationProcess::MigrationProcess(const CompilerInvocation &CI,
DiagnosticConsumer *diagClient,
StringRef outputDir)
- : OrigCI(CI), DiagClient(diagClient) {
+ : OrigCI(CI), DiagClient(diagClient), HadARCErrors(false) {
if (!outputDir.empty()) {
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
}
Unit->setOwnsRemappedFileBuffers(false); // FileRemapper manages that.
+ HadARCErrors = HadARCErrors || capturedDiags.hasErrors();
+
// Don't filter diagnostics anymore.
Diags->setClient(DiagClient, /*ShouldOwnClient=*/false);