[PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

2017-05-05 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r302255, thanks!


https://reviews.llvm.org/D32879



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


Re: [PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

2017-05-04 Thread Aaron Ballman via cfe-commits
On May 4, 2017 4:55 PM, "Nico Weber via Phabricator" <
revi...@reviews.llvm.org> wrote:

thakis created this revision.
Herald added a subscriber: javed.absar.

https://reviews.llvm.org/D32879

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Parser/MicrosoftExtensions.cpp
  test/Parser/ms-square-bracket-attributes.mm
  test/SemaCXX/ms-uuid.cpp


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
-Wno-deprecated-declarations

 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/ms-square-bracket-attributes.mm
===
--- test/Parser/ms-square-bracket-attributes.mm
+++ test/Parser/ms-square-bracket-attributes.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
-Wno-deprecated-declarations

 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -60,7 +60,7 @@
 struct __declspec(uuid("00A0---C000-0049"))
 struct_with_uuid2;

-[uuid("00A0---C000-0049")] struct struct_with_uuid3;
+[uuid("00A0---C000-0049")] struct struct_with_uuid3;
// expected-warning{{specifying uuid as ATL attribute is deprecated, use
__declspec instead}}

 struct
 struct_with_uuid2 {} ;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5079,6 +5079,15 @@
 }
   }

+  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if
it's
+  // the only thing in the [] list, the [] too), and add an insertion of
+  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the
commas
+  // separating attributes nor of the [ and the ] are in the AST.
+  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]]
etc"
+  // on cfe-dev.
+  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
+S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
+
   UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
  Attr.getAttributeSpellingListIndex(),
StrRef);
   if (UA)
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -4151,8 +4151,6 @@
   }

   if (!T.consumeClose()) {
-// FIXME: Warn that this syntax is deprecated, with a Fix-It suggesting
-// using __declspec(uuid()) instead.
 Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()),
nullptr,
  SourceLocation(), ArgExprs.data(), ArgExprs.size(),
  AttributeList::AS_Microsoft);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -730,6 +730,9 @@
 def warn_pragma_unused_undeclared_var : Warning<
   "undeclared variable %0 used as an argument for '#pragma unused'">,
   InGroup;
+def warn_atl_uuid_deprecated : Warning<
+  "specifying uuid as ATL attribute is deprecated, use __declspec
instead">,


as an ATL attribute

Please quoute uuid.

Replace the comma with a semicolon.

+  InGroup;
 def warn_pragma_unused_expected_var_arg : Warning<
   "only variables can be arguments to '#pragma unused'">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

2017-05-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D32879



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


[PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

2017-05-04 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
Herald added a subscriber: javed.absar.

https://reviews.llvm.org/D32879

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Parser/MicrosoftExtensions.cpp
  test/Parser/ms-square-bracket-attributes.mm
  test/SemaCXX/ms-uuid.cpp


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
-Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/ms-square-bracket-attributes.mm
===
--- test/Parser/ms-square-bracket-attributes.mm
+++ test/Parser/ms-square-bracket-attributes.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s 
-Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -60,7 +60,7 @@
 struct __declspec(uuid("00A0---C000-0049"))
 struct_with_uuid2;
 
-[uuid("00A0---C000-0049")] struct struct_with_uuid3;
+[uuid("00A0---C000-0049")] struct struct_with_uuid3; // 
expected-warning{{specifying uuid as ATL attribute is deprecated, use 
__declspec instead}}
 
 struct
 struct_with_uuid2 {} ;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5079,6 +5079,15 @@
 }
   }
 
+  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if it's
+  // the only thing in the [] list, the [] too), and add an insertion of
+  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the commas
+  // separating attributes nor of the [ and the ] are in the AST.
+  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]] etc"
+  // on cfe-dev.
+  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
+S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
+
   UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
  Attr.getAttributeSpellingListIndex(), StrRef);
   if (UA)
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -4151,8 +4151,6 @@
   }
 
   if (!T.consumeClose()) {
-// FIXME: Warn that this syntax is deprecated, with a Fix-It suggesting
-// using __declspec(uuid()) instead.
 Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()), 
nullptr,
  SourceLocation(), ArgExprs.data(), ArgExprs.size(),
  AttributeList::AS_Microsoft);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -730,6 +730,9 @@
 def warn_pragma_unused_undeclared_var : Warning<
   "undeclared variable %0 used as an argument for '#pragma unused'">,
   InGroup;
+def warn_atl_uuid_deprecated : Warning<
+  "specifying uuid as ATL attribute is deprecated, use __declspec instead">,
+  InGroup;
 def warn_pragma_unused_expected_var_arg : Warning<
   "only variables can be arguments to '#pragma unused'">,
   InGroup;


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/ms-square-bracket-attributes.mm
===
--- test/Parser/ms-square-bracket-attributes.mm
+++ test/Parser/ms-square-bracket-attributes.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s -Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -60,7 +60,7 @@
 struct __declspec(uuid("00A0---C000-0049"))
 struct_with_uuid2;
 
-[uuid("00A0---C000-0049")] struct struct_with_uuid3;