r186850 - [arcmt] Only disable ARC in the second compilation if there were actually ARC errors in the checking phase.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Jul 22 11:13:55 PDT 2013
Author: akirtzidis
Date: Mon Jul 22 13:13:54 2013
New Revision: 186850
URL: http://llvm.org/viewvc/llvm-project?rev=186850&view=rev
Log:
[arcmt] Only disable ARC in the second compilation if there were actually ARC errors in the checking phase.
rdar://14490204
Modified:
cfe/trunk/include/clang/ARCMigrate/ARCMT.h
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/test/ARCMT/checking-in-arc.m
Modified: cfe/trunk/include/clang/ARCMigrate/ARCMT.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ARCMigrate/ARCMT.h?rev=186850&r1=186849&r2=186850&view=diff
==============================================================================
--- cfe/trunk/include/clang/ARCMigrate/ARCMT.h (original)
+++ cfe/trunk/include/clang/ARCMigrate/ARCMT.h Mon Jul 22 13:13:54 2013
@@ -97,6 +97,8 @@ class MigrationProcess {
FileRemapper Remapper;
public:
+ bool HadARCErrors;
+
MigrationProcess(const CompilerInvocation &CI, DiagnosticConsumer *diagClient,
StringRef outputDir = StringRef());
Modified: cfe/trunk/lib/ARCMigrate/ARCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMT.cpp?rev=186850&r1=186849&r2=186850&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ARCMT.cpp Mon Jul 22 13:13:54 2013
@@ -270,6 +270,8 @@ bool arcmt::checkForManualIssues(Compile
return true;
}
+ bool hadARCErrors = capturedDiags.hasErrors();
+
// Don't filter diagnostics anymore.
Diags->setClient(DiagClient, /*ShouldOwnClient=*/false);
@@ -321,12 +323,14 @@ bool arcmt::checkForManualIssues(Compile
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();
}
@@ -377,9 +381,14 @@ static bool applyTransforms(CompilerInvo
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);
}
}
@@ -548,7 +557,7 @@ MigrationProcess::RewriteListener::~Rewr
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(
@@ -591,6 +600,8 @@ bool MigrationProcess::applyTransform(Tr
}
Unit->setOwnsRemappedFileBuffers(false); // FileRemapper manages that.
+ HadARCErrors = HadARCErrors || capturedDiags.hasErrors();
+
// Don't filter diagnostics anymore.
Diags->setClient(DiagClient, /*ShouldOwnClient=*/false);
Modified: cfe/trunk/test/ARCMT/checking-in-arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking-in-arc.m?rev=186850&r1=186849&r2=186850&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/checking-in-arc.m (original)
+++ cfe/trunk/test/ARCMT/checking-in-arc.m Mon Jul 22 13:13:54 2013
@@ -45,3 +45,7 @@ extern const CFStringRef kUTTypeRTF;
@implementation Test
@end
+
+#if ! __has_feature(objc_arc)
+#error This file must be compiled with ARC (set -fobjc_arc flag on file)
+#endif
More information about the cfe-commits
mailing list