[cfe-commits] r151942 - in /cfe/trunk: include/clang/Sema/DelayedDiagnostic.h lib/Sema/DelayedDiagnostic.cpp lib/Sema/SemaDeclAttr.cpp test/SemaObjC/warn-forward-class-attr-deprecated.m
Fariborz Jahanian
fjahanian at apple.com
Fri Mar 2 13:50:02 PST 2012
Author: fjahanian
Date: Fri Mar 2 15:50:02 2012
New Revision: 151942
URL: http://llvm.org/viewvc/llvm-project?rev=151942&view=rev
Log:
objc: When issue diagnostic about deprecated method, also
issue the note if it is because message is sent to a forward class
declaration in delayed diagnostic. // rdar://10290322
Added:
cfe/trunk/test/SemaObjC/warn-forward-class-attr-deprecated.m
Modified:
cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
cfe/trunk/lib/Sema/DelayedDiagnostic.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/include/clang/Sema/DelayedDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DelayedDiagnostic.h?rev=151942&r1=151941&r2=151942&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/DelayedDiagnostic.h (original)
+++ cfe/trunk/include/clang/Sema/DelayedDiagnostic.h Fri Mar 2 15:50:02 2012
@@ -122,8 +122,9 @@
void Destroy();
static DelayedDiagnostic makeDeprecation(SourceLocation Loc,
- const NamedDecl *D,
- StringRef Msg);
+ const NamedDecl *D,
+ const ObjCInterfaceDecl *UnknownObjCClass,
+ StringRef Msg);
static DelayedDiagnostic makeAccess(SourceLocation Loc,
const AccessedEntity &Entity) {
@@ -187,12 +188,17 @@
assert(Kind == ForbiddenType && "not a forbidden-type diagnostic");
return QualType::getFromOpaquePtr(ForbiddenTypeData.OperandType);
}
+
+ const ObjCInterfaceDecl *getUnknownObjCClass() const {
+ return DeprecationData.UnknownObjCClass;
+ }
private:
union {
/// Deprecation.
struct {
const NamedDecl *Decl;
+ const ObjCInterfaceDecl *UnknownObjCClass;
const char *Message;
size_t MessageLen;
} DeprecationData;
Modified: cfe/trunk/lib/Sema/DelayedDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DelayedDiagnostic.cpp?rev=151942&r1=151941&r2=151942&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DelayedDiagnostic.cpp (original)
+++ cfe/trunk/lib/Sema/DelayedDiagnostic.cpp Fri Mar 2 15:50:02 2012
@@ -20,13 +20,15 @@
using namespace sema;
DelayedDiagnostic DelayedDiagnostic::makeDeprecation(SourceLocation Loc,
- const NamedDecl *D,
- StringRef Msg) {
+ const NamedDecl *D,
+ const ObjCInterfaceDecl *UnknownObjCClass,
+ StringRef Msg) {
DelayedDiagnostic DD;
DD.Kind = Deprecation;
DD.Triggered = false;
DD.Loc = Loc;
DD.DeprecationData.Decl = D;
+ DD.DeprecationData.UnknownObjCClass = UnknownObjCClass;
char *MessageData = 0;
if (Msg.size()) {
MessageData = new char [Msg.size()];
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=151942&r1=151941&r2=151942&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Mar 2 15:50:02 2012
@@ -4121,6 +4121,11 @@
Diag(DD.Loc, diag::warn_deprecated_message)
<< DD.getDeprecationDecl()->getDeclName()
<< DD.getDeprecationMessage();
+ else if (DD.getUnknownObjCClass()) {
+ Diag(DD.Loc, diag::warn_deprecated_fwdclass_message)
+ << DD.getDeprecationDecl()->getDeclName();
+ Diag(DD.getUnknownObjCClass()->getLocation(), diag::note_forward_class);
+ }
else
Diag(DD.Loc, diag::warn_deprecated)
<< DD.getDeprecationDecl()->getDeclName();
@@ -4131,7 +4136,9 @@
const ObjCInterfaceDecl *UnknownObjCClass) {
// Delay if we're currently parsing a declaration.
if (DelayedDiagnostics.shouldDelayDiagnostics()) {
- DelayedDiagnostics.add(DelayedDiagnostic::makeDeprecation(Loc, D, Message));
+ DelayedDiagnostics.add(DelayedDiagnostic::makeDeprecation(Loc, D,
+ UnknownObjCClass,
+ Message));
return;
}
Added: cfe/trunk/test/SemaObjC/warn-forward-class-attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/warn-forward-class-attr-deprecated.m?rev=151942&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/warn-forward-class-attr-deprecated.m (added)
+++ cfe/trunk/test/SemaObjC/warn-forward-class-attr-deprecated.m Fri Mar 2 15:50:02 2012
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://10290322
+
+ at class ABGroupImportFilesScope; // expected-note {{forward declaration of class here}}
+
+ at interface I1
+- (id) filenames __attribute__((deprecated));
+ at end
+
+ at interface I2
+- (id) Meth : (ABGroupImportFilesScope*) scope;
+- (id) filenames __attribute__((deprecated));
+- (id)initWithAccount: (id)account filenames:(id)filenames;
+ at end
+
+ at implementation I2
+- (id) Meth : (ABGroupImportFilesScope*) scope
+{
+ id p = [self initWithAccount : 0 filenames :[scope filenames]]; // expected-warning {{'filenames' maybe deprecated because receiver type is unknown}}
+ return 0;
+}
+- (id) filenames { return 0; }
+- (id)initWithAccount: (id)account filenames:(id)filenames { return 0; }
+ at end
More information about the cfe-commits
mailing list