]> granicus.if.org Git - clang/commitdiff
Get ARCMT/GC-check-warn-nsalloc.m working
authorAlp Toker <alp@nuanti.com>
Mon, 19 May 2014 22:51:11 +0000 (22:51 +0000)
committerAlp Toker <alp@nuanti.com>
Mon, 19 May 2014 22:51:11 +0000 (22:51 +0000)
The -no-ns-alloc-error migration option now causes the diagnostic to be ignored
completely. If this isn't desired, the error can be downgraded to a warning
using the usual -Wno-error=arcmt-ns-alloc.

Note that we can't use -verify right now on this test because
VerifyDiagnosticConsumer gets confused by multiple SourceManager instances,
which is presumably the reason it was XFAILed in the first place and why the
regression wasn't detected. We'll grep instead for now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209172 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticCommonKinds.td
lib/ARCMigrate/ARCMT.cpp
lib/ARCMigrate/TransGCCalls.cpp
test/ARCMT/GC-check-warn-nsalloc.m

index 0430b1dc27a59ec48d75205be3fd9f8d2b9c601b..b6260627c7372715f8e672aecbfdca93f2e34b14 100644 (file)
@@ -143,7 +143,7 @@ def warn_mt_message : Warning<"[rewriter] %0">;
 def note_mt_message : Note<"[rewriter] %0">;
 
 // ARCMigrate
-def err_arcmt_nsalloc_realloc : Error<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">;
+def warn_arcmt_nsalloc_realloc : Warning<"[rewriter] call returns pointer to GC managed memory; it will become unmanaged in ARC">, InGroup<DiagGroup<"arcmt-ns-alloc">>, DefaultError;
 def err_arcmt_nsinvocation_ownership : Error<"NSInvocation's %0 is not safe to be used with an object with ownership other than __unsafe_unretained">;
 
 }
index 178ec84e20113ece6327b135dc05fb0320a0a38a..88ff50fcf96331a85e4cfcb5a64839504e025108 100644 (file)
@@ -311,10 +311,9 @@ bool arcmt::checkForManualIssues(CompilerInvocation &origCI,
   MigrationPass pass(Ctx, OrigGCMode, Unit->getSema(), testAct, capturedDiags,
                      ARCMTMacroLocs);
   pass.setNoFinalizeRemoval(NoFinalizeRemoval);
-  Diags->setDiagnosticMapping(diag::err_arcmt_nsalloc_realloc,
-                              NoNSAllocReallocError ? diag::MAP_WARNING
-                                                    : diag::MAP_ERROR,
-                              SourceLocation());
+  if (NoNSAllocReallocError)
+    Diags->setDiagnosticMapping(diag::warn_arcmt_nsalloc_realloc,
+                                diag::MAP_IGNORE, SourceLocation());
 
   for (unsigned i=0, e = transforms.size(); i != e; ++i)
     transforms[i](pass);
index 401e788084473b430fc1aceaa30bbe8e7072c60c..3a236d34cd4bfd3c2198b95ee294b205b499546a 100644 (file)
@@ -38,7 +38,7 @@ public:
     TransformActions &TA = MigrateCtx.Pass.TA;
 
     if (MigrateCtx.isGCOwnedNonObjC(E->getType())) {
-      TA.report(E->getLocStart(), diag::err_arcmt_nsalloc_realloc,
+      TA.report(E->getLocStart(), diag::warn_arcmt_nsalloc_realloc,
                 E->getSourceRange());
       return true;
     }
index 6be05b6a7a914ae1d1a2a50b2a7edc3aaf1c0c52..ec3cd0ce334ee77e5ab2577b035284ad5e17fa81 100644 (file)
@@ -1,11 +1,12 @@
-// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s
-// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s
+// RUN: %clang_cc1 -arcmt-check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s | not grep warning
+// RUN: %clang_cc1 -arcmt-check -Wno-error=arcmt-ns-alloc -triple x86_64-apple-darwin10 -fobjc-gc-only %s 2>&1 | grep 'warning: \[rewriter\] call returns pointer to GC managed memory'
+// RUN: %clang_cc1 -arcmt-check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s | not grep warning
+// TODO: Investigate VerifyDiagnosticConsumer failures on these tests when using -verify.
 // rdar://10532541
-// XFAIL: *
 
 typedef unsigned NSUInteger;
 void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
 
 void test1() {
-  NSAllocateCollectable(100, 0); // expected-warning {{call returns pointer to GC managed memory; it will become unmanaged in ARC}}
+  NSAllocateCollectable(100, 0);
 }