From 5946f351db8a3b018e75d0752cea74c2026054b0 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Mon, 19 May 2014 22:51:11 +0000 Subject: [PATCH] Get ARCMT/GC-check-warn-nsalloc.m working 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 | 2 +- lib/ARCMigrate/ARCMT.cpp | 7 +++---- lib/ARCMigrate/TransGCCalls.cpp | 2 +- test/ARCMT/GC-check-warn-nsalloc.m | 9 +++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index 0430b1dc27..b6260627c7 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -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>, 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">; } diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index 178ec84e20..88ff50fcf9 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -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); diff --git a/lib/ARCMigrate/TransGCCalls.cpp b/lib/ARCMigrate/TransGCCalls.cpp index 401e788084..3a236d34cd 100644 --- a/lib/ARCMigrate/TransGCCalls.cpp +++ b/lib/ARCMigrate/TransGCCalls.cpp @@ -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; } diff --git a/test/ARCMT/GC-check-warn-nsalloc.m b/test/ARCMT/GC-check-warn-nsalloc.m index 6be05b6a7a..ec3cd0ce33 100644 --- a/test/ARCMT/GC-check-warn-nsalloc.m +++ b/test/ARCMT/GC-check-warn-nsalloc.m @@ -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); } -- 2.50.1