Skip to content

Commit

Permalink
[SYCL] Use kernel types with the global namespace specifier.
Browse files Browse the repository at this point in the history
That allows to avoid ambiguity in integration header for kernel
types if namespaces with the same names are defined on different
levels.

Signed-off-by: Vladimir Lazarev <vladimir.lazarev@intel.com>
  • Loading branch information
vladimirlaz committed Jan 22, 2019
1 parent d97c89d commit 58a7b24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "TreeTransform.h"
#include "clang/AST/AST.h"
#include "clang/AST/QualTypeNames.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Sema/Sema.h"
Expand Down Expand Up @@ -705,7 +706,10 @@ void Sema::ConstructSYCLKernel(FunctionDecl *KernelCallerFunc) {
// Get Name for our kernel.
const TemplateArgumentList *TemplateArgs =
KernelCallerFunc->getTemplateSpecializationArgs();
QualType KernelNameType = TemplateArgs->get(0).getAsType();
QualType KernelNameType = TypeName::getFullyQualifiedType(
TemplateArgs->get(0).getAsType(),
getASTContext(),
true);
std::string Name = constructKernelName(KernelNameType);
populateIntHeader(getSyclIntegrationHeader(), Name, KernelNameType, LE);

Expand Down
12 changes: 6 additions & 6 deletions clang/test/CodeGenSYCL/integration_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// CHECK: static constexpr
// CHECK-NEXT: const char* const kernel_names[] = {
// CHECK-NEXT: "first_kernel",
// CHECK-NEXT: "second_namespace::second_kernel<char>",
// CHECK-NEXT: "third_kernel<1, int, point< X> >"
// CHECK-NEXT: "::second_namespace::second_kernel<char>",
// CHECK-NEXT: "::third_kernel<1, int, ::point<X> >"
// CHECK-NEXT: };
//
// CHECK: static constexpr
Expand All @@ -27,12 +27,12 @@
// CHECK-NEXT: { kernel_param_kind_t::kind_accessor, 2016, 5 },
// CHECK-NEXT: { kernel_param_kind_t::kind_scalar, 1, 5 },
// CHECK-EMPTY:
// CHECK-NEXT: //--- second_namespace::second_kernel<char>
// CHECK-NEXT: //--- ::second_namespace::second_kernel<char>
// CHECK-NEXT: { kernel_param_kind_t::kind_scalar, 4, 0 },
// CHECK-NEXT: { kernel_param_kind_t::kind_accessor, 2016, 4 },
// CHECK-NEXT: { kernel_param_kind_t::kind_scalar, 1, 4 },
// CHECK-EMPTY:
// CHECK-NEXT: //--- third_kernel<1, int, point< X> >
// CHECK-NEXT: //--- ::third_kernel<1, int, ::point<X> >
// CHECK-NEXT: { kernel_param_kind_t::kind_scalar, 4, 0 },
// CHECK-NEXT: { kernel_param_kind_t::kind_accessor, 2016, 4 },
// CHECK-NEXT: { kernel_param_kind_t::kind_scalar, 1, 4 },
Expand All @@ -41,8 +41,8 @@
//
// CHECK: template <class KernelNameType> struct KernelInfo;
// CHECK: template <> struct KernelInfo<class first_kernel> {
// CHECK: template <> struct KernelInfo<class second_namespace::second_kernel<char>> {
// CHECK: template <> struct KernelInfo<class third_kernel<1, int, struct point<struct X> >> {
// CHECK: template <> struct KernelInfo<::second_namespace::second_kernel<char>> {
// CHECK: template <> struct KernelInfo<::third_kernel<1, int, ::point<X> >> {

namespace cl {
namespace sycl {
Expand Down

0 comments on commit 58a7b24

Please sign in to comment.