[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-07 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked 3 inline comments as done.
Mordante added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

Mordante wrote:
> aaron.ballman wrote:
> > Mordante wrote:
> > > aaron.ballman wrote:
> > > > This attribute also exists with this spelling in C2x, FWIW.
> > > True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also 
> > > include `CPlusPlus14`. Do you prefer a different name for the Boolean?
> > I'm talking about C2x, not C++2a. The name for the variable is fine, but we 
> > should prefer `[[deprecated]]` in C2x mode to `__attribute__((deprecated))`.
> > 
> > I think the correct predicate is: 
> > `getLangOpts().DoubleSquareBracketAttributes` -- if the user says they want 
> > to use double-square bracket attributes, we should probably prefer them to 
> > GNU-style attributes.
> Ah sorry I misread. I'll have a look at C2x. Thanks for the information.
`getLangOpts().DoubleSquareBracketAttributes` will not work since it includes 
C++11, which doesn't support `[[deprecated]]`, so I will just test for C++14 
and C2x.
(I had a look at the proper syntax in C2x and found N2334 ;-))


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71141/new/

https://reviews.llvm.org/D71141



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

aaron.ballman wrote:
> Mordante wrote:
> > aaron.ballman wrote:
> > > This attribute also exists with this spelling in C2x, FWIW.
> > True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also include 
> > `CPlusPlus14`. Do you prefer a different name for the Boolean?
> I'm talking about C2x, not C++2a. The name for the variable is fine, but we 
> should prefer `[[deprecated]]` in C2x mode to `__attribute__((deprecated))`.
> 
> I think the correct predicate is: 
> `getLangOpts().DoubleSquareBracketAttributes` -- if the user says they want 
> to use double-square bracket attributes, we should probably prefer them to 
> GNU-style attributes.
Ah sorry I misread. I'll have a look at C2x. Thanks for the information.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71141/new/

https://reviews.llvm.org/D71141



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

Mordante wrote:
> aaron.ballman wrote:
> > This attribute also exists with this spelling in C2x, FWIW.
> True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also include 
> `CPlusPlus14`. Do you prefer a different name for the Boolean?
I'm talking about C2x, not C++2a. The name for the variable is fine, but we 
should prefer `[[deprecated]]` in C2x mode to `__attribute__((deprecated))`.

I think the correct predicate is: `getLangOpts().DoubleSquareBracketAttributes` 
-- if the user says they want to use double-square bracket attributes, we 
should probably prefer them to GNU-style attributes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71141/new/

https://reviews.llvm.org/D71141



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

aaron.ballman wrote:
> This attribute also exists with this spelling in C2x, FWIW.
True, but unless I'm mistaken `CPlusPlus17` and `CPlusPlus2a` also include 
`CPlusPlus14`. Do you prefer a different name for the Boolean?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71141/new/

https://reviews.llvm.org/D71141



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/CommentSema.cpp:693
+StringRef AttributeSpelling =
+CPlusPlus14 ? "[[deprecated]]" : "__attribute__((deprecated))";
 if (PP) {

This attribute also exists with this spelling in C2x, FWIW.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71141/new/

https://reviews.llvm.org/D71141



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71141: [Wdocumentation] Use C++14 deprecated attribute

2019-12-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added a reviewer: gribozavr2.
Mordante added a project: clang.

This replaces the non-standard `__attribute__((deprecated))` with the standard 
`[[deprecated]]` when compiling in C++14 mode.

Discovered while looking at https://bugs.llvm.org/show_bug.cgi?id=43753

Depends: D71140 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71141

Files:
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation-fixits.cpp
  clang/test/Sema/warn-documentation.cpp

Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -612,6 +612,12 @@
 /// \deprecated Bbb
 void test_deprecated_1(int a) __attribute__((deprecated));
 
+#if __cplusplus >= 201402L
+/// Aaa
+/// \deprecated Bbb
+[[deprecated]] void test_deprecated_no_warning_std14(int a);
+#endif
+
 // We don't want \deprecated to warn about empty paragraph.  It is fine to use
 // \deprecated by itself without explanations.
 
Index: clang/test/Sema/warn-documentation-fixits.cpp
===
--- clang/test/Sema/warn-documentation-fixits.cpp
+++ clang/test/Sema/warn-documentation-fixits.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 %s
+// RUN  %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -DATTRIBUTE="__attribute__((deprecated))" %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 -DATTRIBUTE="[[deprecated]]" %s
 
 // expected-warning@+1 {{parameter 'ZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
 /// \param ZZ Blah blah.
@@ -96,6 +96,14 @@
 /// \deprecated
 void test_deprecated_9(int a);
 
+#if __cplusplus >= 201402L
+#define ATTRIBUTE_DEPRECATED [[deprecated]]
+
+// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
+/// \deprecated
+void test_deprecated_10(int a);
+#endif
+
 // rdar://12381408
 // expected-warning@+2  {{unknown command tag name 'retur'; did you mean 'return'?}}
 /// \brief testing fixit
@@ -119,16 +127,17 @@
 // CHECK: fix-it:"{{.*}}":{10:12-10:15}:"aaa"
 // CHECK: fix-it:"{{.*}}":{14:13-14:23}:"T"
 // CHECK: fix-it:"{{.*}}":{19:13-19:18}:"SomeTy"
-// CHECK: fix-it:"{{.*}}":{26:1-26:1}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{30:1-30:1}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{35:3-35:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{39:3-39:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{47:3-47:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{51:3-51:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{76:3-76:3}:"__attribute__((deprecated)) "
-// CHECK: fix-it:"{{.*}}":{81:3-81:3}:"__attribute__((deprecated)) "
-// CHECK14: fix-it:"{{.*}}":{87:3-87:3}:"__attribute__((deprecated)) "
+// CHECK: fix-it:"{{.*}}":{26:1-26:1}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{30:1-30:1}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{35:3-35:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{39:3-39:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{47:3-47:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{51:3-51:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{76:3-76:3}:"[[ATTRIBUTE]] "
+// CHECK: fix-it:"{{.*}}":{81:3-81:3}:"[[ATTRIBUTE]] "
+// CHECK14: fix-it:"{{.*}}":{87:3-87:3}:"[[ATTRIBUTE]] "
 // CHECK: fix-it:"{{.*}}":{97:1-97:1}:"MY_ATTR_DEPRECATED "
-// CHECK: fix-it:"{{.*}}":{102:6-102:11}:"return"
-// CHECK: fix-it:"{{.*}}":{106:6-106:11}:"foobar"
-// CHECK: fix-it:"{{.*}}":{115:6-115:12}:"endcode"
+// CHECK14: fix-it:"{{.*}}":{104:1-104:1}:"ATTRIBUTE_DEPRECATED "
+// CHECK: fix-it:"{{.*}}":{110:6-110:11}:"return"
+// CHECK: fix-it:"{{.*}}":{114:6-114:11}:"foobar"
+// CHECK: fix-it:"{{.*}}":{123:6-123:12}:"endcode"
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -688,17 +688,33 @@
 FD->doesThisDeclarationHaveABody())