r321775 - PR35815: Separate out the ns-consumed diagnostic into an error and
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 3 15:52:42 PST 2018
Author: arphaman
Date: Wed Jan 3 15:52:42 2018
New Revision: 321775
URL: http://llvm.org/viewvc/llvm-project?rev=321775&view=rev
Log:
PR35815: Separate out the ns-consumed diagnostic into an error and
a warning
This commit separates out the warn_nsconsumed_attribute_mismatch and
warn_nsreturns_retained_attribute_mismatch diagnostic into a warning and error.
This is needed to avoid a module import regression introduced by r313717 that
turned these errors into warnings and started promoting them only when needed,
which caused an error when importing a module as it had different warning
settings.
rdar://36265651
Added:
cfe/trunk/test/SemaObjC/Inputs/module.map
cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=321775&r1=321774&r2=321775&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jan 3 15:52:42 2018
@@ -8300,12 +8300,16 @@ def err_c99_array_usage_cxx : Error<
"feature, not permitted in C++">;
def err_type_unsupported : Error<
"%0 is not supported on this target">;
-def warn_nsconsumed_attribute_mismatch : Warning<
+def err_nsconsumed_attribute_mismatch : Error<
"overriding method has mismatched ns_consumed attribute on its"
- " parameter">, InGroup<NSConsumedMismatch>;
-def warn_nsreturns_retained_attribute_mismatch : Warning<
+ " parameter">;
+def err_nsreturns_retained_attribute_mismatch : Error<
"overriding method has mismatched ns_returns_%select{not_retained|retained}0"
- " attributes">, InGroup<NSReturnsMismatch>;
+ " attributes">;
+def warn_nsconsumed_attribute_mismatch : Warning<
+ err_nsconsumed_attribute_mismatch.Text>, InGroup<NSConsumedMismatch>;
+def warn_nsreturns_retained_attribute_mismatch : Warning<
+ err_nsreturns_retained_attribute_mismatch.Text>, InGroup<NSReturnsMismatch>;
def note_getter_unavailable : Note<
"or because setter is declared here, but no getter method %0 is found">;
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=321775&r1=321774&r2=321775&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Jan 3 15:52:42 2018
@@ -156,23 +156,23 @@ void Sema::CheckObjCMethodOverride(ObjCM
Diag(Overridden->getLocation(),
diag::note_related_result_type_overridden);
}
- if (getLangOpts().ObjCAutoRefCount) {
- Diags.setSeverity(diag::warn_nsreturns_retained_attribute_mismatch,
- diag::Severity::Error, SourceLocation());
- Diags.setSeverity(diag::warn_nsconsumed_attribute_mismatch,
- diag::Severity::Error, SourceLocation());
- }
if ((NewMethod->hasAttr<NSReturnsRetainedAttr>() !=
Overridden->hasAttr<NSReturnsRetainedAttr>())) {
Diag(NewMethod->getLocation(),
- diag::warn_nsreturns_retained_attribute_mismatch) << 1;
+ getLangOpts().ObjCAutoRefCount
+ ? diag::err_nsreturns_retained_attribute_mismatch
+ : diag::warn_nsreturns_retained_attribute_mismatch)
+ << 1;
Diag(Overridden->getLocation(), diag::note_previous_decl) << "method";
}
if ((NewMethod->hasAttr<NSReturnsNotRetainedAttr>() !=
Overridden->hasAttr<NSReturnsNotRetainedAttr>())) {
Diag(NewMethod->getLocation(),
- diag::warn_nsreturns_retained_attribute_mismatch) << 0;
+ getLangOpts().ObjCAutoRefCount
+ ? diag::err_nsreturns_retained_attribute_mismatch
+ : diag::warn_nsreturns_retained_attribute_mismatch)
+ << 0;
Diag(Overridden->getLocation(), diag::note_previous_decl) << "method";
}
@@ -185,7 +185,10 @@ void Sema::CheckObjCMethodOverride(ObjCM
ParmVarDecl *newDecl = (*ni);
if (newDecl->hasAttr<NSConsumedAttr>() !=
oldDecl->hasAttr<NSConsumedAttr>()) {
- Diag(newDecl->getLocation(), diag::warn_nsconsumed_attribute_mismatch);
+ Diag(newDecl->getLocation(),
+ getLangOpts().ObjCAutoRefCount
+ ? diag::err_nsconsumed_attribute_mismatch
+ : diag::warn_nsconsumed_attribute_mismatch);
Diag(oldDecl->getLocation(), diag::note_previous_decl) << "parameter";
}
Added: cfe/trunk/test/SemaObjC/Inputs/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/Inputs/module.map?rev=321775&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/Inputs/module.map (added)
+++ cfe/trunk/test/SemaObjC/Inputs/module.map Wed Jan 3 15:52:42 2018
@@ -0,0 +1,3 @@
+module empty {
+ header "empty.h"
+}
Added: cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m?rev=321775&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m (added)
+++ cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m Wed Jan 3 15:52:42 2018
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -fobjc-arc -verify -fblocks -triple x86_64-apple-darwin10.0.0 -DOBJCARC %s
+// rdar://36265651
+
+ at interface A
+-(void) m:(id)p; // expected-note {{parameter declared here}}
+ at end
+
+ at interface B : A
+-(void) m:(__attribute__((ns_consumed)) id)p; // expected-error {{overriding method has mismatched ns_consumed attribute on its parameter}}
+ at end
+
+ at import empty;
More information about the cfe-commits
mailing list