[cfe-commits] r161528 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/Parser/MicrosoftExtensions.c test/Sema/MicrosoftExtensions.c test/Sema/attr-deprecated-message.c test/Sema/attr-deprecated.c test/Sema/attr-unavailable-message.c test/Sema/typeof-use-deprecated.c test/SemaCXX/attr-deprecated.cpp test/SemaObjC/protocol-attribute.m
Eli Friedman
eli.friedman at gmail.com
Wed Aug 8 14:52:41 PDT 2012
Author: efriedma
Date: Wed Aug 8 16:52:41 2012
New Revision: 161528
URL: http://llvm.org/viewvc/llvm-project?rev=161528&view=rev
Log:
Unify the codepaths for emitting deprecation warnings. The test changes are just to account for us emitting notes more consistently.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.c
cfe/trunk/test/Sema/MicrosoftExtensions.c
cfe/trunk/test/Sema/attr-deprecated-message.c
cfe/trunk/test/Sema/attr-deprecated.c
cfe/trunk/test/Sema/attr-unavailable-message.c
cfe/trunk/test/Sema/typeof-use-deprecated.c
cfe/trunk/test/SemaCXX/attr-deprecated.cpp
cfe/trunk/test/SemaObjC/protocol-attribute.m
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Aug 8 16:52:41 2012
@@ -4650,24 +4650,36 @@
return false;
}
+static void
+DoEmitDeprecationWarning(Sema &S, const NamedDecl *D, StringRef Message,
+ SourceLocation Loc,
+ const ObjCInterfaceDecl *UnknownObjCClass) {
+ DeclarationName Name = D->getDeclName();
+ if (!Message.empty()) {
+ S.Diag(Loc, diag::warn_deprecated_message) << Name << Message;
+ S.Diag(D->getLocation(),
+ isa<ObjCMethodDecl>(D) ? diag::note_method_declared_at
+ : diag::note_previous_decl) << Name;
+ } else if (!UnknownObjCClass) {
+ S.Diag(Loc, diag::warn_deprecated) << D->getDeclName();
+ S.Diag(D->getLocation(),
+ isa<ObjCMethodDecl>(D) ? diag::note_method_declared_at
+ : diag::note_previous_decl) << Name;
+ } else {
+ S.Diag(Loc, diag::warn_deprecated_fwdclass_message) << Name;
+ S.Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
+ }
+}
+
void Sema::HandleDelayedDeprecationCheck(DelayedDiagnostic &DD,
Decl *Ctx) {
if (isDeclDeprecated(Ctx))
return;
DD.Triggered = true;
- if (!DD.getDeprecationMessage().empty())
- 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();
+ DoEmitDeprecationWarning(*this, DD.getDeprecationDecl(),
+ DD.getDeprecationMessage(), DD.Loc,
+ DD.getUnknownObjCClass());
}
void Sema::EmitDeprecationWarning(NamedDecl *D, StringRef Message,
@@ -4684,23 +4696,5 @@
// Otherwise, don't warn if our current context is deprecated.
if (isDeclDeprecated(cast<Decl>(getCurLexicalContext())))
return;
- if (!Message.empty()) {
- Diag(Loc, diag::warn_deprecated_message) << D->getDeclName()
- << Message;
- Diag(D->getLocation(),
- isa<ObjCMethodDecl>(D) ? diag::note_method_declared_at
- : diag::note_previous_decl) << D->getDeclName();
- }
- else {
- if (!UnknownObjCClass) {
- Diag(Loc, diag::warn_deprecated) << D->getDeclName();
- Diag(D->getLocation(),
- isa<ObjCMethodDecl>(D) ? diag::note_method_declared_at
- : diag::note_previous_decl) << D->getDeclName();
- }
- else {
- Diag(Loc, diag::warn_deprecated_fwdclass_message) << D->getDeclName();
- Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
- }
- }
+ DoEmitDeprecationWarning(*this, D, Message, Loc, UnknownObjCClass);
}
Modified: cfe/trunk/test/Parser/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.c?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.c Wed Aug 8 16:52:41 2012
@@ -54,8 +54,8 @@
typedef enum E { e1 };
-enum __declspec(deprecated) E2 { i, j, k };
-__declspec(deprecated) enum E3 { a, b, c } e;
+enum __declspec(deprecated) E2 { i, j, k }; // expected-note {{declared here}}
+__declspec(deprecated) enum E3 { a, b, c } e; // expected-note {{declared here}}
void deprecated_enum_test(void)
{
@@ -94,7 +94,7 @@
struct S7 {
int foo() { return 12; }
- __declspec(property(get=foo) deprecated) int t;
+ __declspec(property(get=foo) deprecated) int t; // expected-note {{declared here}}
};
/* Technically, this is legal (though it does nothing) */
Modified: cfe/trunk/test/Sema/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/Sema/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Sema/MicrosoftExtensions.c Wed Aug 8 16:52:41 2012
@@ -88,7 +88,7 @@
} BB;
__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' declared here}}
-struct __declspec(deprecated) DS1 { int i; float f; };
+struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{declared here}}
#define MY_TEXT "This is also deprecated"
__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}}
Modified: cfe/trunk/test/Sema/attr-deprecated-message.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated-message.c?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-deprecated-message.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated-message.c Wed Aug 8 16:52:41 2012
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
// rdar: // 6734520
-typedef int INT1 __attribute__((deprecated("Please avoid INT1")));
+typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); // expected-note 3 {{'INT1' declared here}}
typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2")));
@@ -12,10 +12,10 @@
INT1 should_be_unavailable; // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
INT1a should_not_be_deprecated;
-INT1 f1(void) __attribute__ ((deprecated("Please avoid f1")));
+INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); // expected-note {{'f1' declared here}}
INT1 f2(void); // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
-typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color")));
+typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color"))); // expected-note {{'Color' declared here}}
Color c1; // expected-warning {{'Color' is deprecated: Please avoid Color}}
Modified: cfe/trunk/test/Sema/attr-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-deprecated.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated.c Wed Aug 8 16:52:41 2012
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-int f() __attribute__((deprecated)); // expected-note {{declared here}}
+int f() __attribute__((deprecated)); // expected-note 2 {{declared here}}
void g() __attribute__((deprecated));
void g(); // expected-note {{declared here}}
@@ -23,7 +23,7 @@
}
int old_fn() __attribute__ ((deprecated));
-int old_fn();
+int old_fn(); // expected-note {{declared here}}
int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}}
int old_fn() {
@@ -32,7 +32,7 @@
struct foo {
- int x __attribute__((deprecated)); // expected-note {{declared here}}
+ int x __attribute__((deprecated)); // expected-note 3 {{declared here}}
};
void test1(struct foo *F) {
@@ -41,11 +41,11 @@
struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}}
}
-typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 3 {{declared here}}
+typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 10 {{declared here}}
foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
struct __attribute__((deprecated,
- invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
+ invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} expected-note 2 {{declared here}}
struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}
@@ -102,7 +102,7 @@
test19;
// rdar://problem/8518751
-enum __attribute__((deprecated)) Test20 {
+enum __attribute__((deprecated)) Test20 { // expected-note {{declared here}}
test20_a __attribute__((deprecated)), // expected-note {{declared here}}
test20_b // expected-note {{declared here}}
};
Modified: cfe/trunk/test/Sema/attr-unavailable-message.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-unavailable-message.c?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-unavailable-message.c (original)
+++ cfe/trunk/test/Sema/attr-unavailable-message.c Wed Aug 8 16:52:41 2012
@@ -29,7 +29,7 @@
// rdar://10201690
enum foo {
- a = 1,
+ a = 1, // expected-note {{declared here}}
b __attribute__((deprecated())) = 2, // expected-note {{declared here}}
c = 3
}__attribute__((deprecated()));
Modified: cfe/trunk/test/Sema/typeof-use-deprecated.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typeof-use-deprecated.c?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/Sema/typeof-use-deprecated.c (original)
+++ cfe/trunk/test/Sema/typeof-use-deprecated.c Wed Aug 8 16:52:41 2012
@@ -1,25 +1,25 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}}
+struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}} expected-note 2 {{'s' declared here}}
typeof(x) y; // expected-warning {{'s' is deprecated}}
-union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}}
+union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}} expected-note 2 {{'un' declared here}}
typeof( u) z; // expected-warning {{'un' is deprecated}}
-enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}}
+enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}} expected-note 2 {{'E' declared here}}
typeof( e) w; // expected-warning {{'E' is deprecated}}
-struct foo { int x; } __attribute__((deprecated));
-typedef struct foo bar __attribute__((deprecated));
+struct foo { int x; } __attribute__((deprecated)); // expected-note {{'foo' declared here}}
+typedef struct foo bar __attribute__((deprecated)); // expected-note {{'bar' declared here}}
bar x1; // expected-warning {{'bar' is deprecated}}
int main() { typeof(x1) y; } // expected-warning {{'foo' is deprecated}}
struct gorf { int x; };
-typedef struct gorf T __attribute__((deprecated));
+typedef struct gorf T __attribute__((deprecated)); // expected-note {{'T' declared here}}
T t; // expected-warning {{'T' is deprecated}}
void wee() { typeof(t) y; }
Modified: cfe/trunk/test/SemaCXX/attr-deprecated.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-deprecated.cpp?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/attr-deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-deprecated.cpp Wed Aug 8 16:52:41 2012
@@ -163,7 +163,7 @@
namespace test5 {
struct A {
- operator int() __attribute__((deprecated)); // expected-note 2 {{declared here}}
+ operator int() __attribute__((deprecated)); // expected-note 3 {{declared here}}
operator long();
};
void test1(A a) {
Modified: cfe/trunk/test/SemaObjC/protocol-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/protocol-attribute.m?rev=161528&r1=161527&r2=161528&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/protocol-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/protocol-attribute.m Wed Aug 8 16:52:41 2012
@@ -6,7 +6,7 @@
Class <FwProto> cFw = 0; // expected-error {{'FwProto' is unavailable}}
-__attribute ((deprecated)) @protocol MyProto1 // expected-note 5 {{declared here}}
+__attribute ((deprecated)) @protocol MyProto1 // expected-note 7 {{declared here}}
@end
@protocol Proto2 <MyProto1> // expected-warning {{'MyProto1' is deprecated}}
More information about the cfe-commits
mailing list