[PATCH] D34871: [OpenCL] Add function name to extension diagnostic

2017-06-30 Thread Joey Gouly via Phabricator via cfe-commits
joey added a comment.

Thanks!

Making that change, going to re-run the tests and then I'll commit.


https://reviews.llvm.org/D34871



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


[PATCH] D34871: [OpenCL] Add function name to extension diagnostic

2017-06-30 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM.
Just one minor comment.
Thanks.




Comment at: clang/Sema/Sema.h:8435
   /// \return true if type is disabled.
-  bool checkOpenCLDisabledDecl(const Decl , const Expr );
+  bool checkOpenCLDisabledDecl(const FunctionDecl , const Expr );
 

I think it's better to use NamedDecl to allow this function be used for 
declarations other than FunctionDecl.


https://reviews.llvm.org/D34871



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


[PATCH] D34871: [OpenCL] Add function name to extension diagnostic

2017-06-30 Thread Joey Gouly via Phabricator via cfe-commits
joey created this revision.
Herald added subscribers: Anastasia, yaxunl.

Slightly improve the diagnostic by including the function name.

This has been separated out from https://reviews.llvm.org/D33945.


https://reviews.llvm.org/D34871

Files:
  Sema/Sema.cpp
  SemaOpenCL/extension-begin.cl
  clang/Basic/DiagnosticSemaKinds.td
  clang/Sema/Sema.h


Index: SemaOpenCL/extension-begin.cl
===
--- SemaOpenCL/extension-begin.cl
+++ SemaOpenCL/extension-begin.cl
@@ -46,7 +46,7 @@
   const struct A test_A_local; // expected-error {{use of type 'struct A' 
requires my_ext extension to be enabled}}
   TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 
'struct A') requires my_ext extension to be enabled}}
   PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 
'const struct A *') requires my_ext extension to be enabled}}
-  f(); // expected-error {{use of declaration requires my_ext extension to be 
enabled}}
+  f(); // expected-error {{use of declaration 'f' requires my_ext extension to 
be enabled}}
   g(0); // expected-error {{no matching function for call to 'g'}}
 // expected-note@-26 {{candidate disabled due to OpenCL extension}}
 // expected-note@-22 {{candidate function not viable: requires 0 
arguments, but 1 was provided}}
Index: Sema/Sema.cpp
===
--- Sema/Sema.cpp
+++ Sema/Sema.cpp
@@ -1688,7 +1688,8 @@
QT, OpenCLTypeExtMap);
 }
 
-bool Sema::checkOpenCLDisabledDecl(const Decl , const Expr ) {
-  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), "",
+bool Sema::checkOpenCLDisabledDecl(const FunctionDecl , const Expr ) {
+  IdentifierInfo *FnName = D.getIdentifier();
+  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), FnName,
OpenCLDeclExtMap, 1, 
D.getSourceRange());
 }
Index: clang/Sema/Sema.h
===
--- clang/Sema/Sema.h
+++ clang/Sema/Sema.h
@@ -8432,7 +8432,7 @@
   /// is disabled due to required OpenCL extensions being disabled. If so,
   /// emit diagnostics.
   /// \return true if type is disabled.
-  bool checkOpenCLDisabledDecl(const Decl , const Expr );
+  bool checkOpenCLDisabledDecl(const FunctionDecl , const Expr );
 
   
//======//
   // OpenMP directives and clauses.
Index: clang/Basic/DiagnosticSemaKinds.td
===
--- clang/Basic/DiagnosticSemaKinds.td
+++ clang/Basic/DiagnosticSemaKinds.td
@@ -8404,7 +8404,7 @@
 def err_opencl_variadic_function : Error<
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extension : Error<
-  "use of %select{type |declaration}0%1 requires %2 extension to be enabled">;
+  "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<


Index: SemaOpenCL/extension-begin.cl
===
--- SemaOpenCL/extension-begin.cl
+++ SemaOpenCL/extension-begin.cl
@@ -46,7 +46,7 @@
   const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
   TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
   PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}}
-  f(); // expected-error {{use of declaration requires my_ext extension to be enabled}}
+  f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}}
   g(0); // expected-error {{no matching function for call to 'g'}}
 // expected-note@-26 {{candidate disabled due to OpenCL extension}}
 // expected-note@-22 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
Index: Sema/Sema.cpp
===
--- Sema/Sema.cpp
+++ Sema/Sema.cpp
@@ -1688,7 +1688,8 @@
QT, OpenCLTypeExtMap);
 }
 
-bool Sema::checkOpenCLDisabledDecl(const Decl , const Expr ) {
-  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), "",
+bool Sema::checkOpenCLDisabledDecl(const FunctionDecl , const Expr ) {
+  IdentifierInfo *FnName = D.getIdentifier();
+  return checkOpenCLDisabledTypeOrDecl(, E.getLocStart(), FnName,
OpenCLDeclExtMap, 1, D.getSourceRange());
 }
Index: clang/Sema/Sema.h
===
--- clang/Sema/Sema.h
+++ clang/Sema/Sema.h
@@ -8432,7 +8432,7 @@
   /// is disabled due to required